Skip to content

Commit 6567ae5

Browse files
authored
Mark validations info related types are experimental (#61862)
* Mark validations info related types are experimental * Remove comment from emitted code
1 parent 1b3ec6e commit 6567ae5

File tree

30 files changed

+52
-1
lines changed

30 files changed

+52
-1
lines changed

docs/list-of-diagnostics.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
| __`ASP0026`__ | [Authorize] overridden by [AllowAnonymous] from farther away |
3535
| __`ASP0027`__ | Unnecessary public Program class declaration |
3636
| __`ASP0028`__ | Consider using ListenAnyIP() instead of Listen(IPAddress.Any) |
37+
| __`ASP0029`__ | Experimental warning for validations resolver APIs |
3738

3839
### API (`API1000-API1003`)
3940

src/Http/Http.Abstractions/src/Validation/IValidatableInfo.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Http.Validation;
57

68
/// <summary>
79
/// Represents an interface for validating a value.
810
/// </summary>
11+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
912
public interface IValidatableInfo
1013
{
1114
/// <summary>

src/Http/Http.Abstractions/src/Validation/IValidatableInfoResolver.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Http.Validation;
1010
/// Provides an interface for resolving the validation information associated
1111
/// with a given <seealso cref="Type"/> or <seealso cref="ParameterInfo"/>.
1212
/// </summary>
13+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1314
public interface IValidatableInfoResolver
1415
{
1516
/// <summary>

src/Http/Http.Abstractions/src/Validation/RuntimeValidatableParameterInfoResolver.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Http.Abstractions/src/Validation/ValidatableParameterInfo.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
using System.Collections;
55
using System.ComponentModel.DataAnnotations;
66
using System.Diagnostics;
7+
using System.Diagnostics.CodeAnalysis;
78

89
namespace Microsoft.AspNetCore.Http.Validation;
910

1011
/// <summary>
1112
/// Contains validation information for a parameter.
1213
/// </summary>
14+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1315
public abstract class ValidatableParameterInfo : IValidatableInfo
1416
{
1517
private RequiredAttribute? _requiredAttribute;

src/Http/Http.Abstractions/src/Validation/ValidatablePropertyInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Microsoft.AspNetCore.Http.Validation;
1010
/// <summary>
1111
/// Contains validation information for a member of a type.
1212
/// </summary>
13+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1314
public abstract class ValidatablePropertyInfo : IValidatableInfo
1415
{
1516
private RequiredAttribute? _requiredAttribute;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
46
namespace Microsoft.AspNetCore.Http.Validation;
57

68
/// <summary>
79
/// Indicates that a type is validatable to support discovery by the
810
/// validations generator.
911
/// </summary>
1012
[AttributeUsage(AttributeTargets.Class)]
13+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1114
public sealed class ValidatableTypeAttribute : Attribute
1215
{
1316
}

src/Http/Http.Abstractions/src/Validation/ValidatableTypeInfo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ namespace Microsoft.AspNetCore.Http.Validation;
1111
/// <summary>
1212
/// Contains validation information for a type.
1313
/// </summary>
14+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1415
public abstract class ValidatableTypeInfo : IValidatableInfo
1516
{
1617
private readonly int _membersCount;

src/Http/Http.Abstractions/src/Validation/ValidateContext.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.ComponentModel.DataAnnotations;
5+
using System.Diagnostics.CodeAnalysis;
56

67
namespace Microsoft.AspNetCore.Http.Validation;
78

89
/// <summary>
910
/// Represents the context for validating a validatable object.
1011
/// </summary>
12+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
1113
public sealed class ValidateContext
1214
{
1315
/// <summary>

src/Http/Http.Abstractions/src/Validation/ValidationOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public class ValidationOptions
1919
/// Source-generated resolvers are typically inserted at the beginning of this list
2020
/// to ensure they are checked before any runtime-based resolvers.
2121
/// </remarks>
22+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
2223
public IList<IValidatableInfoResolver> Resolvers { get; } = [];
2324

2425
/// <summary>
@@ -35,6 +36,7 @@ public class ValidationOptions
3536
/// <param name="validatableTypeInfo">When this method returns, contains the validation information for the specified type,
3637
/// if the type was found; otherwise, null.</param>
3738
/// <returns>true if validation information was found for the specified type; otherwise, false.</returns>
39+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
3840
public bool TryGetValidatableTypeInfo(Type type, [NotNullWhen(true)] out IValidatableInfo? validatableTypeInfo)
3941
{
4042
foreach (var resolver in Resolvers)
@@ -56,6 +58,7 @@ public bool TryGetValidatableTypeInfo(Type type, [NotNullWhen(true)] out IValida
5658
/// <param name="validatableInfo">When this method returns, contains the validation information for the specified parameter,
5759
/// if validation information was found; otherwise, null.</param>
5860
/// <returns>true if validation information was found for the specified parameter; otherwise, false.</returns>
61+
[Experimental("ASP0029", UrlFormat = "https://aka.ms/aspnet/analyzer/{0}")]
5962
public bool TryGetValidatableParameterInfo(ParameterInfo parameterInfo, [NotNullWhen(true)] out IValidatableInfo? validatableInfo)
6063
{
6164
foreach (var resolver in Resolvers)

src/Http/Http.Abstractions/src/Validation/ValidationServiceCollectionExtensions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ public static IServiceCollection AddValidation(this IServiceCollection services,
2525
configureOptions(options);
2626
}
2727
// Support ParameterInfo resolution at runtime
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.
2829
options.Resolvers.Add(new RuntimeValidatableParameterInfoResolver());
30+
#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.
2931
});
3032
return services;
3133
}

src/Http/Http.Abstractions/test/Validation/ValidatableInfoResolverTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Http.Abstractions/test/Validation/ValidatableParameterInfoTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Http.Abstractions/test/Validation/ValidatableTypeInfoTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Http.Extensions/gen/Microsoft.AspNetCore.Http.ValidationsGenerator/Emitters/ValidationsGenerator.Emitter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ private static string Emit(InterceptableLocation addValidation, ImmutableArray<V
3737
// </auto-generated>
3838
//------------------------------------------------------------------------------
3939
#nullable enable
40+
#pragma warning disable ASP0029
4041
4142
namespace System.Runtime.CompilerServices
4243
{

src/Http/Http.Extensions/test/ValidationsGenerator/ValidationsGenerator.ValidatableType.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

@@ -12,6 +14,8 @@ public partial class ValidationsGeneratorTests : ValidationsGeneratorTestBase
1214
public async Task CanValidateTypesWithAttribute()
1315
{
1416
var source = """
17+
#pragma warning disable ASP0029
18+
1519
using System;
1620
using System.ComponentModel.DataAnnotations;
1721
using System.Collections.Generic;
@@ -374,4 +378,4 @@ async Task ValidInputProducesNoWarnings(IValidatableInfo validatableInfo)
374378
}
375379
});
376380
}
377-
}
381+
}

src/Http/Http.Extensions/test/ValidationsGenerator/ValidationsGeneratorTestBase.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateComplexTypes#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateIValidatableObject#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateParameters#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidatePolymorphicTypes#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateRecordTypes#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateRecursiveTypes#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateTypeWithParsableProperties#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.CanValidateTypesWithAttribute#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http.Extensions/test/ValidationsGenerator/snapshots/ValidationsGeneratorTests.DoesNotEmitForExemptTypes#ValidatableInfoResolver.g.verified.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// </auto-generated>
1010
//------------------------------------------------------------------------------
1111
#nullable enable
12+
#pragma warning disable ASP0029
1213

1314
namespace System.Runtime.CompilerServices
1415
{

src/Http/Http/perf/Microbenchmarks/ValidatableTypesBenchmark.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/Routing/src/RouteEndpointDataSource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,9 @@ private RouteEndpointBuilder CreateRouteEndpointBuilder(
239239

240240
// Initialize this route endpoint builder with validation convention if validation options
241241
// are registered and validation is not disabled on the endpoint.
242+
#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.
242243
var hasValidationResolvers = builder.ApplicationServices.GetService<IOptions<ValidationOptions>>() is { Value: { } options } && options.Resolvers.Count > 0;
244+
#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.
243245
var hasDisableValidationMetadata = builder.Metadata.OfType<IDisableValidationMetadata>().FirstOrDefault() is not null;
244246
if (hasValidationResolvers && !hasDisableValidationMetadata)
245247
{

src/Http/Routing/src/ValidationEndpointFilterFactory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#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+
13
// Licensed to the .NET Foundation under one or more agreements.
24
// The .NET Foundation licenses this file to you under the MIT license.
35

src/Http/samples/MinimalValidationSample/Program.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
app.Run();
2727

2828
// Define validatable types with the ValidatableType attribute
29+
#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.
2930
[ValidatableType]
31+
#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.
3032
public class Customer
3133
{
3234
[Required]

0 commit comments

Comments
 (0)