You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Split RuntimeValidatableInfoResolver into separate parameter and type resolvers, mark type resolver as experimental, revert ValidationServiceCollectionExtensions changes
#pragma warning disable ASP0029// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
2
+
3
+
// Licensed to the .NET Foundation under one or more agreements.
4
+
// The .NET Foundation licenses this file to you under the MIT license.
Copy file name to clipboardExpand all lines: src/Validation/src/RuntimeValidatableTypeInfoResolver.cs
+22-95Lines changed: 22 additions & 95 deletions
Original file line number
Diff line number
Diff line change
@@ -5,70 +5,48 @@
5
5
6
6
usingSystem.Collections.Concurrent;
7
7
usingSystem.ComponentModel.DataAnnotations;
8
-
usingSystem.Diagnostics;
9
8
usingSystem.Diagnostics.CodeAnalysis;
10
-
usingSystem.IO.Pipelines;
11
9
usingSystem.Linq;
12
10
usingSystem.Reflection;
13
-
usingSystem.Security.Claims;
14
11
usingSystem.Text.Json.Serialization;
15
12
usingMicrosoft.Extensions.DependencyInjection;
16
13
17
14
namespaceMicrosoft.Extensions.Validation;
18
15
19
-
[RequiresUnreferencedCode("RuntimeValidatableInfoResolver uses reflection to inspect types, properties, and attributes at runtime, including JsonDerivedTypeAttribute and record constructors. Trimming or AOT compilation may remove members required for validation.")]
/// Experimental runtime implementation of <see cref="IValidatableInfoResolver"/> for type validation.
18
+
/// </summary>
19
+
/// <remarks>
20
+
/// This is an experimental API and may change in future versions.
21
+
/// </remarks>
22
+
[RequiresUnreferencedCode("RuntimeValidatableTypeInfoResolver uses reflection to inspect types, properties, and attributes at runtime, including JsonDerivedTypeAttribute and record constructors. Trimming or AOT compilation may remove members required for validation.")]
@@ -17,12 +16,6 @@ public static class ValidationServiceCollectionExtensions
17
16
/// <param name="services">The <see cref="IServiceCollection" /> to add the services to.</param>
18
17
/// <param name="configureOptions">An optional action to configure the <see cref="ValidationOptions"/>.</param>
19
18
/// <returns>The <see cref="IServiceCollection" /> for chaining.</returns>
20
-
/// <remarks>
21
-
/// This API enables both the source-generated and runtime-based implementation of the built-in validation resolver.
22
-
/// It is not recommended for use in applications where native AoT compat is required. In those
23
-
/// scenarios, it is recommend to use <see cref="ValidationServiceCollectionExtensions.AddValidationCore(IServiceCollection, Action{ValidationOptions}?)" />.
24
-
/// </remarks>
25
-
[RequiresUnreferencedCode("AddValidation enables the RuntimeValidatableInfoResolver by default which is not compatible with trimming or AOT compilation.")]
@@ -31,33 +24,11 @@ public static IServiceCollection AddValidation(this IServiceCollection services,
31
24
{
32
25
configureOptions(options);
33
26
}
34
-
// Support both ParameterInfo and TypeInfo resolution at runtime
27
+
// Support ParameterInfo resolution at runtime
35
28
#pragma warning disable ASP0029// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning restore ASP0029// Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
38
31
});
39
32
returnservices;
40
33
}
41
-
42
-
/// <summary>
43
-
/// Adds the validation services to the specified <see cref="IServiceCollection" />.
44
-
/// </summary>
45
-
/// <param name="services">The <see cref="IServiceCollection" /> to add the services to.</param>
46
-
/// <param name="configureOptions">An optional action to configure the <see cref="ValidationOptions"/>.</param>
47
-
/// <returns>The <see cref="IServiceCollection" /> for chaining.</returns>
48
-
/// <remarks>
49
-
/// This API only enables the source generator-based implementation of the built-in validation resolver, by default
50
-
/// and is recommended for use in applications where native AoT compat is required.
0 commit comments