diff --git a/Directory.Build.targets b/Directory.Build.targets index c96d110b2dd..ff17457a836 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -16,7 +16,17 @@ false - + + $(NoWarn);CS0436 + + $(NoWarn);IL2026;IL2087;IL2067;IL2075;IL2091;IL2072;IL2090;CA1825;IL2070;IL2098;IL2057 @@ -35,14 +45,14 @@ $(NoWarn);CA1062 - + $(NoWarn);ASP0019 - + $(NoWarn);RS1024 @@ -66,7 +76,9 @@ - + + <_Parameter1>TBD + diff --git a/eng/MSBuild/Generators.props b/eng/MSBuild/Generators.props index 580c36c5592..52f47521cfe 100644 --- a/eng/MSBuild/Generators.props +++ b/eng/MSBuild/Generators.props @@ -7,10 +7,6 @@ - - - - diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/DiagDescriptors.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/DiagDescriptors.cs deleted file mode 100644 index 25a4bbe69c4..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/DiagDescriptors.cs +++ /dev/null @@ -1,98 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; -using Microsoft.Gen.Shared; - -namespace Microsoft.Gen.OptionsValidation; - -internal sealed class DiagDescriptors : DiagDescriptorsBase -{ - private const string Category = "OptionsValidation"; - - // Skipping R9G100 - - public static DiagnosticDescriptor CantUseWithGenericTypes { get; } = Make( - id: "R9G101", - title: Resources.CantUseWithGenericTypesTitle, - messageFormat: Resources.CantUseWithGenericTypesMessage, - category: Category); - - public static DiagnosticDescriptor NoEligibleMember { get; } = Make( - id: "R9G102", - title: Resources.NoEligibleMemberTitle, - messageFormat: Resources.NoEligibleMemberMessage, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning); - - public static DiagnosticDescriptor NoEligibleMembersFromValidator { get; } = Make( - id: "R9G103", - title: Resources.NoEligibleMembersFromValidatorTitle, - messageFormat: Resources.NoEligibleMembersFromValidatorMessage, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning); - - public static DiagnosticDescriptor DoesntImplementIValidateOptions { get; } = Make( - id: "R9G104", - title: Resources.DoesntImplementIValidateOptionsTitle, - messageFormat: Resources.DoesntImplementIValidateOptionsMessage, - category: Category); - - public static DiagnosticDescriptor AlreadyImplementsValidateMethod { get; } = Make( - id: "R9G105", - title: Resources.AlreadyImplementsValidateMethodTitle, - messageFormat: Resources.AlreadyImplementsValidateMethodMessage, - category: Category); - - public static DiagnosticDescriptor MemberIsInaccessible { get; } = Make( - id: "R9G106", - title: Resources.MemberIsInaccessibleTitle, - messageFormat: Resources.MemberIsInaccessibleMessage, - category: Category); - - public static DiagnosticDescriptor NotEnumerableType { get; } = Make( - id: "R9G107", - title: Resources.NotEnumerableTypeTitle, - messageFormat: Resources.NotEnumerableTypeMessage, - category: Category); - - public static DiagnosticDescriptor ValidatorsNeedSimpleConstructor { get; } = Make( - id: "R9G108", - title: Resources.ValidatorsNeedSimpleConstructorTitle, - messageFormat: Resources.ValidatorsNeedSimpleConstructorMessage, - category: Category); - - public static DiagnosticDescriptor CantBeStaticClass { get; } = Make( - id: "R9G109", - title: Resources.CantBeStaticClassTitle, - messageFormat: Resources.CantBeStaticClassMessage, - category: Category); - - public static DiagnosticDescriptor NullValidatorType { get; } = Make( - id: "R9G110", - title: Resources.NullValidatorTypeTitle, - messageFormat: Resources.NullValidatorTypeMessage, - category: Category); - - public static DiagnosticDescriptor CircularTypeReferences { get; } = Make( - id: "R9G111", - title: Resources.CircularTypeReferencesTitle, - messageFormat: Resources.CircularTypeReferencesMessage, - category: Category); - - // 112 is available for reuse - - public static DiagnosticDescriptor PotentiallyMissingTransitiveValidation { get; } = Make( - id: "R9G113", - title: Resources.PotentiallyMissingTransitiveValidationTitle, - messageFormat: Resources.PotentiallyMissingTransitiveValidationMessage, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning); - - public static DiagnosticDescriptor PotentiallyMissingEnumerableValidation { get; } = Make( - id: "R9G114", - title: Resources.PotentiallyMissingEnumerableValidationTitle, - messageFormat: Resources.PotentiallyMissingEnumerableValidationMessage, - category: Category, - defaultSeverity: DiagnosticSeverity.Warning); -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Emitter.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Emitter.cs deleted file mode 100644 index c7103aec951..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Emitter.cs +++ /dev/null @@ -1,368 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using Microsoft.Gen.OptionsValidation.Model; -using Microsoft.Gen.Shared; - -namespace Microsoft.Gen.OptionsValidation; - -// Stryker disable all - -/// -/// Emits option validation. -/// -internal sealed class Emitter : EmitterBase -{ - private const string StaticValidationAttributeHolderClassName = "__Attributes"; - private const string StaticValidatorHolderClassName = "__Validators"; - private const string StaticFieldHolderClassesNamespace = "__OptionValidationStaticInstances"; - private const string StaticValidationAttributeHolderClassFQN = $"global::{StaticFieldHolderClassesNamespace}.{StaticValidationAttributeHolderClassName}"; - private const string StaticValidatorHolderClassFQN = $"global::{StaticFieldHolderClassesNamespace}.{StaticValidatorHolderClassName}"; - private sealed record StaticFieldInfo(string FieldTypeFQN, int FieldOrder, string FieldName, IList InstantiationLines); - - public string Emit( - IEnumerable validatorTypes, - CancellationToken cancellationToken) - { - var staticValidationAttributesDict = new Dictionary(); - var staticValidatorsDict = new Dictionary(); - - foreach (var vt in validatorTypes.OrderBy(static lt => lt.Namespace + "." + lt.Name)) - { - cancellationToken.ThrowIfCancellationRequested(); - GenValidatorType(vt, ref staticValidationAttributesDict, ref staticValidatorsDict); - } - - GenStaticClassWithStaticReadonlyFields(staticValidationAttributesDict.Values, StaticFieldHolderClassesNamespace, StaticValidationAttributeHolderClassName); - GenStaticClassWithStaticReadonlyFields(staticValidatorsDict.Values, StaticFieldHolderClassesNamespace, StaticValidatorHolderClassName); - - return Capture(); - } - - private void GenValidatorType(ValidatorType vt, ref Dictionary staticValidationAttributesDict, ref Dictionary staticValidatorsDict) - { - OutLn("#pragma warning disable CS0618 // Type or member is obsolete"); - - if (vt.Namespace.Length > 0) - { - OutLn($"namespace {vt.Namespace}"); - OutOpenBrace(); - } - - foreach (var p in vt.ParentTypes) - { - OutLn(p); - OutOpenBrace(); - } - - if (vt.IsSynthetic) - { - OutGeneratedCodeAttribute(); - OutLn($"internal sealed partial {vt.DeclarationKeyword} {vt.Name}"); - } - else - { - OutLn($"partial {vt.DeclarationKeyword} {vt.Name}"); - } - - OutOpenBrace(); - - for (var i = 0; i < vt.ModelsToValidate.Count; i++) - { - var modelToValidate = vt.ModelsToValidate[i]; - - GenModelValidationMethod(modelToValidate, vt.IsSynthetic, ref staticValidationAttributesDict, ref staticValidatorsDict); - } - - OutCloseBrace(); - - foreach (var _ in vt.ParentTypes) - { - OutCloseBrace(); - } - - if (vt.Namespace.Length > 0) - { - OutCloseBrace(); - } - } - - private void GenStaticClassWithStaticReadonlyFields(IEnumerable staticFields, string classNamespace, string className) - { - OutLn($"namespace {classNamespace}"); - OutOpenBrace(); - - OutGeneratedCodeAttribute(); - OutLn($"file static class {className}"); - OutOpenBrace(); - - var staticValidationAttributes = staticFields - .OrderBy(x => x.FieldOrder) - .ToArray(); - - for (var i = 0; i < staticValidationAttributes.Length; i++) - { - var attributeInstance = staticValidationAttributes[i]; - OutIndent(); - Out($"internal static readonly {attributeInstance.FieldTypeFQN} {attributeInstance.FieldName} = "); - for (var j = 0; j < attributeInstance.InstantiationLines.Count; j++) - { - var line = attributeInstance.InstantiationLines[j]; - Out(line); - if (j != attributeInstance.InstantiationLines.Count - 1) - { - OutLn(); - OutIndent(); - } - else - { - Out(';'); - } - } - - OutLn(); - - if (i != staticValidationAttributes.Length - 1) - { - OutLn(); - } - } - - OutCloseBrace(); - - OutCloseBrace(); - } - - private void GenModelSelfValidationIfNecessary(ValidatedModel modelToValidate) - { - if (modelToValidate.SelfValidates) - { - OutLn($"builder.AddResults(((global::System.ComponentModel.DataAnnotations.IValidatableObject)options).Validate(context));"); - OutLn(); - } - } - - private void GenModelValidationMethod( - ValidatedModel modelToValidate, - bool makeStatic, - ref Dictionary staticValidationAttributesDict, - ref Dictionary staticValidatorsDict) - { - OutLn($"/// "); - OutLn($"/// Validates a specific named options instance (or all when is )."); - OutLn($"/// "); - OutLn($"/// The name of the options instance being validated."); - OutLn($"/// The options instance."); - OutLn($"/// Validation result."); - OutGeneratedCodeAttribute(); - - OutLn($"public {(makeStatic ? "static " : string.Empty)}global::Microsoft.Extensions.Options.ValidateOptionsResult Validate(string? name, {modelToValidate.Name} options)"); - OutOpenBrace(); - OutLn($"var baseName = (string.IsNullOrEmpty(name) ? \"{modelToValidate.SimpleName}\" : name) + \".\";"); - OutLn($"var builder = new global::Microsoft.Extensions.Options.ValidateOptionsResultBuilder();"); - OutLn($"var context = new global::System.ComponentModel.DataAnnotations.ValidationContext(options);"); - OutLn(); - - foreach (var vm in modelToValidate.MembersToValidate) - { - if (vm.ValidationAttributes.Count > 0) - { - GenMemberValidation(vm, ref staticValidationAttributesDict); - OutLn(); - } - - if (vm.TransValidatorType != null) - { - GenTransitiveValidation(vm, ref staticValidatorsDict); - OutLn(); - } - - if (vm.EnumerationValidatorType != null) - { - GenEnumerationValidation(vm, ref staticValidatorsDict); - OutLn(); - } - } - - GenModelSelfValidationIfNecessary(modelToValidate); - OutLn($"return builder.Build();"); - OutCloseBrace(); - } - - private void GenMemberValidation(ValidatedMember vm, - ref Dictionary staticValidationAttributesDict) - { - OutLn($"context.MemberName = \"{vm.Name}\";"); - OutLn($"context.DisplayName = baseName + \"{vm.Name}\";"); - - foreach (var attr in vm.ValidationAttributes) - { - var staticValidationAttributeInstance = GetOrAddStaticValidationAttribute(ref staticValidationAttributesDict, attr); - - OutLn($"builder.AddResult({StaticValidationAttributeHolderClassFQN}.{staticValidationAttributeInstance.FieldName}.GetValidationResult(options.{vm.Name}, context));"); - } - } - - private StaticFieldInfo GetOrAddStaticValidationAttribute(ref Dictionary staticValidationAttributesDict, ValidationAttributeInfo attr) - { - var attrInstantiationStatementLines = new List(); - - if (attr.ConstructorArguments.Count > 0) - { - attrInstantiationStatementLines.Add($"new {attr.AttributeName}("); - - for (var i = 0; i < attr.ConstructorArguments.Count; i++) - { - if (i != attr.ConstructorArguments.Count - 1) - { - attrInstantiationStatementLines.Add($"{GetPaddingString(1)}{attr.ConstructorArguments[i]},"); - } - else - { - attrInstantiationStatementLines.Add($"{GetPaddingString(1)}{attr.ConstructorArguments[i]})"); - } - } - } - else - { - attrInstantiationStatementLines.Add($"new {attr.AttributeName}()"); - } - - if (attr.Properties.Count > 0) - { - attrInstantiationStatementLines.Add("{"); - - var propertiesOrderedByKey = attr.Properties - .OrderBy(p => p.Key) - .ToArray(); - - for (var i = 0; i < propertiesOrderedByKey.Length; i++) - { - var prop = propertiesOrderedByKey[i]; - var notLast = i != propertiesOrderedByKey.Length - 1; - attrInstantiationStatementLines.Add($"{GetPaddingString(1)}{prop.Key} = {prop.Value}{(notLast ? "," : string.Empty)}"); - } - - attrInstantiationStatementLines.Add("}"); - } - - var instantiationStatement = string.Join(Environment.NewLine, attrInstantiationStatementLines); - - if (!staticValidationAttributesDict.TryGetValue(instantiationStatement, out var staticValidationAttributeInstance)) - { - var fieldNumber = staticValidationAttributesDict.Count + 1; - staticValidationAttributeInstance = new StaticFieldInfo( - FieldTypeFQN: attr.AttributeName, - FieldOrder: fieldNumber, - FieldName: $"A{fieldNumber}", - InstantiationLines: attrInstantiationStatementLines); - - staticValidationAttributesDict.Add(instantiationStatement, staticValidationAttributeInstance); - } - - return staticValidationAttributeInstance; - } - - private void GenTransitiveValidation(ValidatedMember vm, ref Dictionary staticValidatorsDict) - { - string callSequence; - if (vm.TransValidateTypeIsSynthetic) - { - callSequence = vm.TransValidatorType!; - } - else - { - var staticValidatorInstance = GetOrAddStaticValidator(ref staticValidatorsDict, vm.TransValidatorType!); - - callSequence = $"{StaticValidatorHolderClassFQN}.{staticValidatorInstance.FieldName}"; - } - - var valueAccess = (vm.IsNullable && vm.IsValueType) ? ".Value" : string.Empty; - - if (vm.IsNullable) - { - OutLn($"if (options.{vm.Name} != null)"); - OutLn($"{{"); - OutLn($" builder.AddResult({callSequence}.Validate(baseName + \"{vm.Name}\", options.{vm.Name}{valueAccess}));"); - OutLn($"}}"); - } - else - { - OutLn($"builder.AddResult({callSequence}.Validate(baseName + \"{vm.Name}\", options.{vm.Name}{valueAccess}));"); - } - } - - private void GenEnumerationValidation(ValidatedMember vm, ref Dictionary staticValidatorsDict) - { - var valueAccess = (vm.IsValueType && vm.IsNullable) ? ".Value" : string.Empty; - var enumeratedValueAccess = (vm.EnumeratedIsNullable && vm.EnumeratedIsValueType) ? ".Value" : string.Empty; - string callSequence; - if (vm.EnumerationValidatorTypeIsSynthetic) - { - callSequence = vm.EnumerationValidatorType!; - } - else - { - var staticValidatorInstance = GetOrAddStaticValidator(ref staticValidatorsDict, vm.EnumerationValidatorType!); - - callSequence = $"{StaticValidatorHolderClassFQN}.{staticValidatorInstance.FieldName}"; - } - - if (vm.IsNullable) - { - OutLn($"if (options.{vm.Name} != null)"); - } - - OutOpenBrace(); - - OutLn($"var count = 0;"); - OutLn($"foreach (var o in options.{vm.Name}{valueAccess})"); - OutOpenBrace(); - - if (vm.EnumeratedIsNullable) - { - OutLn($"if (o is not null)"); - OutLn($"{{"); - OutLn($" builder.AddResult({callSequence}.Validate(baseName + $\"{vm.Name}[{{count++}}]\", o{enumeratedValueAccess}));"); - OutLn($"}}"); - - if (!vm.EnumeratedMayBeNull) - { - OutLn($"else"); - OutLn($"{{"); - OutLn($" builder.AddError(baseName + $\"{vm.Name}[{{count++}}] is null\");"); - OutLn($"}}"); - } - } - else - { - OutLn($"builder.AddResult({callSequence}.Validate(baseName + $\"{vm.Name}[{{count++}}]\", o{enumeratedValueAccess}));"); - } - - OutCloseBrace(); - OutCloseBrace(); - } - -#pragma warning disable CA1822 // Mark members as static: static should come before non-static, but we want the method to be here - private StaticFieldInfo GetOrAddStaticValidator(ref Dictionary staticValidatorsDict, string validatorTypeFQN) -#pragma warning restore CA1822 - { - if (!staticValidatorsDict.TryGetValue(validatorTypeFQN, out var staticValidatorInstance)) - { - var fieldNumber = staticValidatorsDict.Count + 1; - staticValidatorInstance = new StaticFieldInfo( - FieldTypeFQN: validatorTypeFQN, - FieldOrder: fieldNumber, - FieldName: $"V{fieldNumber}", - InstantiationLines: new[] { $"new {validatorTypeFQN}()" }); - - staticValidatorsDict.Add(validatorTypeFQN, staticValidatorInstance); - } - - return staticValidatorInstance; - } -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Generator.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Generator.cs deleted file mode 100644 index 3f0a49c5a3d..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Generator.cs +++ /dev/null @@ -1,100 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if ROSLYN_4_0_OR_GREATER - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; -using Microsoft.Gen.Shared; - -namespace Microsoft.Gen.OptionsValidation; - -[Generator] -[ExcludeFromCodeCoverage] -public class Generator : IIncrementalGenerator -{ - private static readonly HashSet _attributeNames = new() - { - SymbolLoader.OptionsValidatorAttribute, - }; - - public void Initialize(IncrementalGeneratorInitializationContext context) - { - GeneratorUtilities.Initialize(context, _attributeNames, HandleAnnotatedTypes); - } - - private static void HandleAnnotatedTypes(Compilation compilation, IEnumerable nodes, SourceProductionContext context) - { - if (!SymbolLoader.TryLoad(compilation, out var symbolHolder)) - { - // Not eligible compilation - return; - } - - var parser = new Parser(compilation, context.ReportDiagnostic, symbolHolder!, context.CancellationToken); - - var validatorTypes = parser.GetValidatorTypes(nodes.OfType()); - if (validatorTypes.Count > 0) - { - var emitter = new Emitter(); - var result = emitter.Emit(validatorTypes, context.CancellationToken); - - context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8)); - } - } -} - -#else - -using System.Diagnostics.CodeAnalysis; -using System.Text; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.Text; -using Microsoft.Gen.Shared; - -namespace Microsoft.Gen.OptionsValidation; - -/// -/// Generates for classes that are marked with . -/// -[Generator] -[ExcludeFromCodeCoverage] -public class Generator : ISourceGenerator -{ - public void Initialize(GeneratorInitializationContext context) - { - context.RegisterForSyntaxNotifications(TypeDeclarationSyntaxReceiver.Create); - } - - public void Execute(GeneratorExecutionContext context) - { - var receiver = context.SyntaxReceiver as TypeDeclarationSyntaxReceiver; - if (receiver == null || receiver.TypeDeclarations.Count == 0) - { - // nothing to do yet - return; - } - - if (!SymbolLoader.TryLoad(context.Compilation, out var symbolHolder)) - { - // Not eligible compilation - return; - } - - var parser = new Parser(context.Compilation, context.ReportDiagnostic, symbolHolder!, context.CancellationToken); - var validatorTypes = parser.GetValidatorTypes(receiver.TypeDeclarations); - if (validatorTypes.Count > 0) - { - var emitter = new Emitter(); - var result = emitter.Emit(validatorTypes, context.CancellationToken); - context.AddSource("Validators.g.cs", SourceText.From(result, Encoding.UTF8)); - } - } -} - -#endif diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedMember.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedMember.cs deleted file mode 100644 index 0ffe9385e8f..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedMember.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; - -namespace Microsoft.Gen.OptionsValidation.Model; - -internal sealed record class ValidatedMember( - string Name, - List ValidationAttributes, - string? TransValidatorType, - bool TransValidateTypeIsSynthetic, - string? EnumerationValidatorType, - bool EnumerationValidatorTypeIsSynthetic, - bool IsNullable, - bool IsValueType, - bool EnumeratedIsNullable, - bool EnumeratedIsValueType, - bool EnumeratedMayBeNull); diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedModel.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedModel.cs deleted file mode 100644 index 8b354f5d235..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatedModel.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; - -namespace Microsoft.Gen.OptionsValidation.Model; - -internal sealed record class ValidatedModel( - string Name, - string SimpleName, - bool SelfValidates, - List MembersToValidate); diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidationAttributeInfo.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidationAttributeInfo.cs deleted file mode 100644 index 111073d1aa3..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidationAttributeInfo.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; - -namespace Microsoft.Gen.OptionsValidation.Model; - -internal sealed record class ValidationAttributeInfo(string AttributeName) -{ - public List ConstructorArguments { get; } = new(); - public Dictionary Properties { get; } = new(); -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatorType.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatorType.cs deleted file mode 100644 index 27c5caaa634..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Model/ValidatorType.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; - -namespace Microsoft.Gen.OptionsValidation.Model; - -internal sealed record class ValidatorType( - string Namespace, - string Name, - string NameWithoutGenerics, - string DeclarationKeyword, - List ParentTypes, - bool IsSynthetic, - IList ModelsToValidate); diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Parser.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Parser.cs deleted file mode 100644 index 4b27c09597a..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Parser.cs +++ /dev/null @@ -1,696 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.Gen.OptionsValidation.Model; -using Microsoft.Gen.Shared; - -namespace Microsoft.Gen.OptionsValidation; - -/// -/// Holds an internal parser class that extracts necessary information for generating IValidateOptions. -/// -internal sealed class Parser -{ - private const int NumValidationMethodArgs = 2; - - private readonly CancellationToken _cancellationToken; - private readonly Compilation _compilation; - private readonly Action _reportDiagnostic; - private readonly SymbolHolder _symbolHolder; - private readonly Dictionary _synthesizedValidators = new(SymbolEqualityComparer.Default); - private readonly HashSet _visitedModelTypes = new(SymbolEqualityComparer.Default); - - public Parser( - Compilation compilation, - Action reportDiagnostic, - SymbolHolder symbolHolder, - CancellationToken cancellationToken) - { - _compilation = compilation; - _cancellationToken = cancellationToken; - _reportDiagnostic = reportDiagnostic; - _symbolHolder = symbolHolder; - } - - public IReadOnlyList GetValidatorTypes(IEnumerable classes) - { - var results = new List(); - - foreach (var group in classes.GroupBy(x => x.SyntaxTree)) - { - SemanticModel? sm = null; - foreach (var typeDec in group) - { - _cancellationToken.ThrowIfCancellationRequested(); - sm ??= _compilation.GetSemanticModel(typeDec.SyntaxTree); - - var validatorType = sm.GetDeclaredSymbol(typeDec) as ITypeSymbol; - if (validatorType != null) - { -#if !ROSLYN_4_0_OR_GREATER - if (!IsAnnotated(validatorType)) - { - continue; - } -#endif - if (validatorType.IsStatic) - { - Diag(DiagDescriptors.CantBeStaticClass, typeDec.GetLocation()); - continue; - } - - _visitedModelTypes.Clear(); - - var modelTypes = GetModelTypes(validatorType); - if (modelTypes.Count == 0) - { - // validator doesn't implement IValidateOptions - Diag(DiagDescriptors.DoesntImplementIValidateOptions, typeDec.GetLocation(), validatorType.Name); - continue; - } - - var modelsValidatorTypeValidates = new List(modelTypes.Count); - - foreach (var modelType in modelTypes) - { - if (modelType.Kind == SymbolKind.ErrorType) - { - // the compiler will report this error for us - continue; - } - else - { - // keep track of the models we look at, to detect loops - _ = _visitedModelTypes.Add(modelType.WithNullableAnnotation(NullableAnnotation.None)); - } - - if (AlreadyImplementsValidateMethod(validatorType, modelType)) - { - // this type already implements a validation function, we can't auto-generate a new one - Diag(DiagDescriptors.AlreadyImplementsValidateMethod, typeDec.GetLocation(), validatorType.Name); - continue; - } - - var membersToValidate = GetMembersToValidate(modelType, true); - if (membersToValidate.Count == 0) - { - // this type lacks any eligible members - Diag(DiagDescriptors.NoEligibleMembersFromValidator, typeDec.GetLocation(), modelType.ToString(), validatorType.ToString()); - continue; - } - - modelsValidatorTypeValidates.Add(new ValidatedModel( - GetFQN(modelType), - modelType.Name, - ModelSelfValidates(modelType), - membersToValidate)); - } - - string keyword = GetTypeKeyword(validatorType); - - // following code establishes the containment hierarchy for the generated type in terms of nested types - - var parents = new List(); - var parent = typeDec.Parent as TypeDeclarationSyntax; - - while (parent != null && IsAllowedKind(parent.Kind())) - { - parents.Add($"partial {GetTypeKeyword(parent)} {parent.Identifier}{parent.TypeParameterList} {parent.ConstraintClauses}"); - parent = parent.Parent as TypeDeclarationSyntax; - } - - parents.Reverse(); - - results.Add(new ValidatorType( - validatorType.ContainingNamespace.IsGlobalNamespace ? string.Empty : validatorType.ContainingNamespace.ToString(), - GetMinimalFQN(validatorType), - GetMinimalFQNWithoutGenerics(validatorType), - keyword, - parents, - false, - modelsValidatorTypeValidates)); - } - } - } - - results.AddRange(_synthesizedValidators.Values); - _synthesizedValidators.Clear(); - - return results; - } - - private static bool IsAllowedKind(SyntaxKind kind) => - kind == SyntaxKind.ClassDeclaration || - kind == SyntaxKind.StructDeclaration || -#if ROSLYN_4_0_OR_GREATER - kind == SyntaxKind.RecordStructDeclaration || -#endif - kind == SyntaxKind.RecordDeclaration; - - private static string GetTypeKeyword(ITypeSymbol type) - { -#if ROSLYN_4_0_OR_GREATER - if (type.IsReferenceType) - { - return type.IsRecord ? "record class" : "class"; - } - - return type.IsRecord ? "record struct" : "struct"; -#else - return type.IsReferenceType ? "class" : "struct"; -#endif - } - - private static string GetTypeKeyword(TypeDeclarationSyntax type) => - type.Kind() switch - { - SyntaxKind.ClassDeclaration => "class", - SyntaxKind.RecordDeclaration => "record class", -#if ROSLYN_4_0_OR_GREATER - SyntaxKind.RecordStructDeclaration => "record struct", -#endif - _ => type.Keyword.ValueText, - }; - - private static string GetFQN(ISymbol type) - => type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat.WithMiscellaneousOptions(SymbolDisplayMiscellaneousOptions.IncludeNullableReferenceTypeModifier)); - - private static string GetMinimalFQN(ISymbol type) - => type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat.AddGenericsOptions(SymbolDisplayGenericsOptions.IncludeTypeParameters)); - - private static string GetMinimalFQNWithoutGenerics(ISymbol type) - => type.ToDisplayString(SymbolDisplayFormat.MinimallyQualifiedFormat.WithGenericsOptions(SymbolDisplayGenericsOptions.None)); - - /// - /// Checks whether the given validator already implement the IValidationOptions>T< interface. - /// - private static bool AlreadyImplementsValidateMethod(INamespaceOrTypeSymbol validatorType, ISymbol modelType) - => validatorType - .GetMembers("Validate") - .Where(m => m.Kind == SymbolKind.Method) - .Select(m => (IMethodSymbol)m) - .Any(m => m.Parameters.Length == NumValidationMethodArgs - && m.Parameters[0].Type.SpecialType == SpecialType.System_String - && SymbolEqualityComparer.Default.Equals(m.Parameters[1].Type, modelType)); - - /// - /// Checks whether the given type contain any unbound generic type arguments. - /// - private static bool HasOpenGenerics(ITypeSymbol type, out string genericType) - { - if (type is INamedTypeSymbol mt) - { - if (mt.IsGenericType) - { - foreach (var ta in mt.TypeArguments) - { - if (ta.TypeKind == TypeKind.TypeParameter) - { - genericType = ta.Name; - return true; - } - } - } - } - else if (type is ITypeParameterSymbol) - { - genericType = type.Name; - return true; - } - else if (type is IArrayTypeSymbol ats) - { - return HasOpenGenerics(ats.ElementType, out genericType); - } - - genericType = string.Empty; - return false; - } - -#if !ROSLYN_4_0_OR_GREATER - private bool IsAnnotated(ISymbol type) - { - foreach (var attribute in type.GetAttributes().Where(a => a.AttributeClass != null)) - { - var attributeType = attribute.AttributeClass!; - - if (SymbolEqualityComparer.Default.Equals(attributeType, _symbolHolder.OptionsValidatorSymbol)) - { - return true; - } - } - - return false; - } -#endif - - private ITypeSymbol? GetEnumeratedType(ITypeSymbol type) - { - if (type.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) - { - // extract the T from a Nullable - type = ((INamedTypeSymbol)type).TypeArguments[0]; - } - - foreach (var implementingInterface in type.AllInterfaces) - { - if (SymbolEqualityComparer.Default.Equals(implementingInterface.OriginalDefinition, _compilation.GetSpecialType(SpecialType.System_Collections_Generic_IEnumerable_T))) - { - return implementingInterface.TypeArguments.First(); - } - } - - return null; - } - - private List GetMembersToValidate(ITypeSymbol modelType, bool speculate) - { - // make a list of the most derived members in the model type - - if (modelType.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) - { - // extract the T from a Nullable - modelType = ((INamedTypeSymbol)modelType).TypeArguments[0]; - } - - var members = modelType.GetMembers().ToList(); - var addedMembers = new HashSet(members.Select(m => m.Name)); - var baseType = modelType.BaseType; - while (baseType is not null && baseType.SpecialType != SpecialType.System_Object) - { - var baseMembers = baseType.GetMembers().Where(m => !addedMembers.Contains(m.Name)); - members.AddRange(baseMembers); - addedMembers.UnionWith(baseMembers.Select(m => m.Name)); - baseType = baseType.BaseType; - } - - var membersToValidate = new List(); - foreach (var member in members) - { - var memberInfo = GetMemberInfo(member, speculate); - if (memberInfo != null) - { - if (member.DeclaredAccessibility != Accessibility.Public && member.DeclaredAccessibility != Accessibility.Internal) - { - Diag(DiagDescriptors.MemberIsInaccessible, member.Locations.First(), member.Name); - continue; - } - - membersToValidate.Add(memberInfo); - } - } - - return membersToValidate; - } - - private ValidatedMember? GetMemberInfo(ISymbol member, bool speculate) - { - ITypeSymbol memberType; - switch (member) - { - case IPropertySymbol prop: - memberType = prop.Type; - break; - case IFieldSymbol field: - if (field.AssociatedSymbol != null) - { - // a backing field for a property, don't need those - return null; - } - - memberType = field.Type; - break; - default: - // we only care about properties and fields - return null; - } - - var validationAttrs = new List(); - string? transValidatorTypeName = null; - string? enumerationValidatorTypeName = null; - var enumeratedIsNullable = false; - var enumeratedIsValueType = false; - var enumeratedMayBeNull = false; - var transValidatorIsSynthetic = false; - var enumerationValidatorIsSynthetic = false; - - foreach (var attribute in member.GetAttributes().Where(a => a.AttributeClass != null)) - { - var attributeType = attribute.AttributeClass!; - var attrLoc = attribute.ApplicationSyntaxReference?.GetSyntax().GetLocation(); - - if (SymbolEqualityComparer.Default.Equals(attributeType, _symbolHolder.ValidateObjectMembersAttributeSymbol) - || SymbolEqualityComparer.Default.Equals(attributeType, _symbolHolder.LegacyValidateTransitivelyAttributeSymbol)) - { - if (HasOpenGenerics(memberType, out var genericType)) - { - Diag(DiagDescriptors.CantUseWithGenericTypes, attrLoc, genericType); -#pragma warning disable S1226 // Method parameters, caught exceptions and foreach variables' initial values should not be ignored - speculate = false; -#pragma warning restore S1226 // Method parameters, caught exceptions and foreach variables' initial values should not be ignored - continue; - } - - if (attribute.ConstructorArguments.Length == 1) - { - var transValidatorType = attribute.ConstructorArguments[0].Value as INamedTypeSymbol; - if (transValidatorType != null) - { - if (CanValidate(transValidatorType, memberType)) - { - if (transValidatorType.Constructors.Where(c => !c.Parameters.Any()).Any()) - { - transValidatorTypeName = transValidatorType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - } - else - { - Diag(DiagDescriptors.ValidatorsNeedSimpleConstructor, attrLoc, transValidatorType.Name); - } - } - else - { - Diag(DiagDescriptors.DoesntImplementIValidateOptions, attrLoc, transValidatorType.Name, memberType.Name); - } - } - else - { - Diag(DiagDescriptors.NullValidatorType, attrLoc); - } - } - else if (!_visitedModelTypes.Add(memberType.WithNullableAnnotation(NullableAnnotation.None))) - { - Diag(DiagDescriptors.CircularTypeReferences, attrLoc, memberType.ToString()); - speculate = false; - continue; - } - - if (transValidatorTypeName == null) - { - transValidatorIsSynthetic = true; - transValidatorTypeName = AddSynthesizedValidator(memberType, member); - } - - // pop the stack - _ = _visitedModelTypes.Remove(memberType.WithNullableAnnotation(NullableAnnotation.None)); - } - else if (SymbolEqualityComparer.Default.Equals(attributeType, _symbolHolder.ValidateEnumeratedItemsAttributeSymbol)) - { - var enumeratedType = GetEnumeratedType(memberType); - if (enumeratedType == null) - { - Diag(DiagDescriptors.NotEnumerableType, attrLoc, memberType); - speculate = false; - continue; - } - - enumeratedIsNullable = enumeratedType.IsReferenceType || enumeratedType.NullableAnnotation == NullableAnnotation.Annotated; - enumeratedIsValueType = enumeratedType.IsValueType; - enumeratedMayBeNull = enumeratedType.NullableAnnotation == NullableAnnotation.Annotated; - - if (HasOpenGenerics(enumeratedType, out var genericType)) - { - Diag(DiagDescriptors.CantUseWithGenericTypes, attrLoc, genericType); - speculate = false; - continue; - } - - if (attribute.ConstructorArguments.Length == 1) - { - var enumerationValidatorType = attribute.ConstructorArguments[0].Value as INamedTypeSymbol; - if (enumerationValidatorType != null) - { - if (CanValidate(enumerationValidatorType, enumeratedType)) - { - if (enumerationValidatorType.Constructors.Where(c => c.Parameters.Length == 0).Any()) - { - enumerationValidatorTypeName = enumerationValidatorType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); - } - else - { - Diag(DiagDescriptors.ValidatorsNeedSimpleConstructor, attrLoc, enumerationValidatorType.Name); - } - } - else - { - Diag(DiagDescriptors.DoesntImplementIValidateOptions, attrLoc, enumerationValidatorType.Name, enumeratedType.Name); - } - } - else - { - Diag(DiagDescriptors.NullValidatorType, attrLoc); - } - } - else if (!_visitedModelTypes.Add(enumeratedType.WithNullableAnnotation(NullableAnnotation.None))) - { - Diag(DiagDescriptors.CircularTypeReferences, attrLoc, enumeratedType.ToString()); - speculate = false; - continue; - } - - if (enumerationValidatorTypeName == null) - { - enumerationValidatorIsSynthetic = true; - enumerationValidatorTypeName = AddSynthesizedValidator(enumeratedType, member); - } - - // pop the stack - _ = _visitedModelTypes.Remove(enumeratedType.WithNullableAnnotation(NullableAnnotation.None)); - } - else if (DerivesFrom(attributeType, _symbolHolder.ValidationAttributeSymbol)) - { - var validationAttr = new ValidationAttributeInfo(attributeType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)); - validationAttrs.Add(validationAttr); - - foreach (var constructorArgument in attribute.ConstructorArguments) - { - validationAttr.ConstructorArguments.Add(GetArgumentExpression(constructorArgument.Type!, constructorArgument.Value)); - } - - foreach (var namedArgument in attribute.NamedArguments) - { - validationAttr.Properties.Add(namedArgument.Key, GetArgumentExpression(namedArgument.Value.Type!, namedArgument.Value.Value)); - } - } - } - - // generate a warning if the field/property seems like it should be transitively validated - if (transValidatorTypeName == null && speculate && memberType.SpecialType == SpecialType.None) - { - if (!HasOpenGenerics(memberType, out var genericType)) - { - var membersToValidate = GetMembersToValidate(memberType, false); - if (membersToValidate.Count > 0) - { - Diag(DiagDescriptors.PotentiallyMissingTransitiveValidation, member.GetLocation(), memberType.Name, member.Name); - } - } - } - - // generate a warning if the field/property seems like it should be enumerated - if (enumerationValidatorTypeName == null && speculate) - { - var enumeratedType = GetEnumeratedType(memberType); - if (enumeratedType != null) - { - if (!HasOpenGenerics(enumeratedType, out var genericType)) - { - var membersToValidate = GetMembersToValidate(enumeratedType, false); - if (membersToValidate.Count > 0) - { - Diag(DiagDescriptors.PotentiallyMissingEnumerableValidation, member.GetLocation(), enumeratedType.Name, member.Name); - } - } - } - } - - if (validationAttrs.Count > 0 || transValidatorTypeName != null || enumerationValidatorTypeName != null) - { - return new( - member.Name, - validationAttrs, - transValidatorTypeName, - transValidatorIsSynthetic, - enumerationValidatorTypeName, - enumerationValidatorIsSynthetic, - memberType.IsReferenceType || memberType.NullableAnnotation == NullableAnnotation.Annotated, - memberType.IsValueType, - enumeratedIsNullable, - enumeratedIsValueType, - enumeratedMayBeNull); - } - - return null; - } - - private string? AddSynthesizedValidator(ITypeSymbol modelType, ISymbol member) - { - var mt = modelType.WithNullableAnnotation(NullableAnnotation.None); - if (mt.OriginalDefinition.SpecialType == SpecialType.System_Nullable_T) - { - // extract the T from a Nullable - mt = ((INamedTypeSymbol)mt).TypeArguments[0]; - } - - if (_synthesizedValidators.TryGetValue(mt, out var validator)) - { - return "global::" + validator.Namespace + "." + validator.Name; - } - - var membersToValidate = GetMembersToValidate(mt, true); - if (membersToValidate.Count == 0) - { - // this type lacks any eligible members - Diag(DiagDescriptors.NoEligibleMember, member.GetLocation(), mt.ToString(), member.ToString()); - return null; - } - - var model = new ValidatedModel( - GetFQN(mt), - mt.Name, - false, - membersToValidate); - - var validatorTypeName = "__" + mt.Name + "Validator__"; - - var result = new ValidatorType( - mt.ContainingNamespace.IsGlobalNamespace ? string.Empty : mt.ContainingNamespace.ToString(), - validatorTypeName, - validatorTypeName, - "class", - new List(), - true, - new[] { model }); - - _synthesizedValidators[mt] = result; - return "global::" + (result.Namespace.Length > 0 ? result.Namespace + "." + result.Name : result.Name); - } - - private bool DerivesFrom(ITypeSymbol source, ITypeSymbol dest) - { - var conversion = _compilation.ClassifyConversion(source, dest); - return conversion.IsReference && conversion.IsImplicit; - } - - private bool ModelSelfValidates(ITypeSymbol modelType) - { - foreach (var implementingInterface in modelType.AllInterfaces) - { - if (SymbolEqualityComparer.Default.Equals(implementingInterface.OriginalDefinition, _symbolHolder.IValidatableObjectSymbol)) - { - return true; - } - } - - return false; - } - - private List GetModelTypes(ITypeSymbol validatorType) - { - var result = new List(); - foreach (var implementingInterface in validatorType.AllInterfaces) - { - if (SymbolEqualityComparer.Default.Equals(implementingInterface.OriginalDefinition, _symbolHolder.ValidateOptionsSymbol)) - { - result.Add(implementingInterface.TypeArguments.First()); - } - } - - return result; - } - - private bool CanValidate(ITypeSymbol validatorType, ISymbol modelType) - { - foreach (var implementingInterface in validatorType.AllInterfaces) - { - if (SymbolEqualityComparer.Default.Equals(implementingInterface.OriginalDefinition, _symbolHolder.ValidateOptionsSymbol)) - { - var t = implementingInterface.TypeArguments.First(); - if (SymbolEqualityComparer.Default.Equals(modelType, t)) - { - return true; - } - } - } - - return false; - } - - private string GetArgumentExpression(ITypeSymbol type, object? value) - { - if (value == null) - { - return "null"; - } - - if (type.SpecialType == SpecialType.System_Boolean) - { - return (bool)value ? "true" : "false"; - } - - if (SymbolEqualityComparer.Default.Equals(type, _symbolHolder.TypeSymbol) && - value is INamedTypeSymbol sym) - { - return $"typeof({sym.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)})"; - } - - if (type.SpecialType == SpecialType.System_String) - { - return $@"""{EscapeString(value.ToString())}"""; - } - - if (type.SpecialType == SpecialType.System_Char) - { - return $@"'{EscapeString(value.ToString())}'"; - } - - return $"({type.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}){Convert.ToString(value, CultureInfo.InvariantCulture)}"; - } - - private static readonly char[] _specialChars = { '\n', '\r', '"', '\\' }; - - private static string EscapeString(string s) - { - int index = s.IndexOfAny(_specialChars); - if (index < 0) - { - return s; - } - - var sb = new StringBuilder(s.Length); - _ = sb.Append(s, 0, index); - - while (index < s.Length) - { - _ = s[index] switch - { - '\n' => sb.Append("\\n"), - '\r' => sb.Append("\\r"), - '"' => sb.Append("\\\""), - '\\' => sb.Append("\\\\"), - var other => sb.Append(other), - }; - - index++; - } - - return sb.ToString(); - } - - private void Diag(DiagnosticDescriptor desc, Location? location) - { - _reportDiagnostic(Diagnostic.Create(desc, location, Array.Empty())); - } - - private void Diag(DiagnosticDescriptor desc, Location? location, params object?[]? messageArgs) - { - _reportDiagnostic(Diagnostic.Create(desc, location, messageArgs)); - } -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.Designer.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.Designer.cs deleted file mode 100644 index 0ec5247cbb3..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.Designer.cs +++ /dev/null @@ -1,297 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Gen.OptionsValidation { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Gen.OptionsValidation.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Type {0} already implements the Validate method. - /// - internal static string AlreadyImplementsValidateMethodMessage { - get { - return ResourceManager.GetString("AlreadyImplementsValidateMethodMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A type already includes an implementation of the `Validate` method. - /// - internal static string AlreadyImplementsValidateMethodTitle { - get { - return ResourceManager.GetString("AlreadyImplementsValidateMethodTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to [OptionsValidator] cannot be applied to static class {0}. - /// - internal static string CantBeStaticClassMessage { - get { - return ResourceManager.GetString("CantBeStaticClassMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to `OptionsValidatorAttribute` can't be applied to a static class. - /// - internal static string CantBeStaticClassTitle { - get { - return ResourceManager.GetString("CantBeStaticClassTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't use [ValidateObjectMembers] or [ValidateEnumeratedItems] on fields or properties with open generic type {0}. - /// - internal static string CantUseWithGenericTypesMessage { - get { - return ResourceManager.GetString("CantUseWithGenericTypesMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't use `ValidateObjectMembersAttribute` or `ValidateEnumeratedItemsAttribute` on fields or properties with open generic types. - /// - internal static string CantUseWithGenericTypesTitle { - get { - return ResourceManager.GetString("CantUseWithGenericTypesTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to There is a circular type reference involving type {0} preventing it from being used for static validation. - /// - internal static string CircularTypeReferencesMessage { - get { - return ResourceManager.GetString("CircularTypeReferencesMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Unsupported circular references in model types. - /// - internal static string CircularTypeReferencesTitle { - get { - return ResourceManager.GetString("CircularTypeReferencesTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} does not implement the required IValidateOptions<{1}> interface. - /// - internal static string DoesntImplementIValidateOptionsMessage { - get { - return ResourceManager.GetString("DoesntImplementIValidateOptionsMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A type annotated with `OptionsValidatorAttribute` doesn't implement the necessary interface. - /// - internal static string DoesntImplementIValidateOptionsTitle { - get { - return ResourceManager.GetString("DoesntImplementIValidateOptionsTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't apply validation attributes to private field or property {0}. - /// - internal static string MemberIsInaccessibleMessage { - get { - return ResourceManager.GetString("MemberIsInaccessibleMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Can't validate private fields or properties. - /// - internal static string MemberIsInaccessibleTitle { - get { - return ResourceManager.GetString("MemberIsInaccessibleTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} has no fields or properties to validate, referenced from member {1}. - /// - internal static string NoEligibleMemberMessage { - get { - return ResourceManager.GetString("NoEligibleMemberMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} has no fields or properties to validate, referenced by type {1}. - /// - internal static string NoEligibleMembersFromValidatorMessage { - get { - return ResourceManager.GetString("NoEligibleMembersFromValidatorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A type has no fields or properties to validate. - /// - internal static string NoEligibleMembersFromValidatorTitle { - get { - return ResourceManager.GetString("NoEligibleMembersFromValidatorTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to A member type has no fields or properties to validate. - /// - internal static string NoEligibleMemberTitle { - get { - return ResourceManager.GetString("NoEligibleMemberTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to [ValidateEnumeratedItems] cannot be used on members of type {0} as it doesn't implement IEnumerable<T>. - /// - internal static string NotEnumerableTypeMessage { - get { - return ResourceManager.GetString("NotEnumerableTypeMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member type is not enumerable. - /// - internal static string NotEnumerableTypeTitle { - get { - return ResourceManager.GetString("NotEnumerableTypeTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Null validator type specified in [ValidateObjectMembers] or [ValidateEnumeratedItems] attributes. - /// - internal static string NullValidatorTypeMessage { - get { - return ResourceManager.GetString("NullValidatorTypeMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Null validator type specified for the `ValidateObjectMembersAttribute` or `ValidateEnumeratedItemsAttribute` attributes. - /// - internal static string NullValidatorTypeTitle { - get { - return ResourceManager.GetString("NullValidatorTypeTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} has validation annotations, but member {1} doesn't specify [ValidateEnumeratedItems] which could be an oversight. - /// - internal static string PotentiallyMissingEnumerableValidationMessage { - get { - return ResourceManager.GetString("PotentiallyMissingEnumerableValidationMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member potentially missing enumerable validation. - /// - internal static string PotentiallyMissingEnumerableValidationTitle { - get { - return ResourceManager.GetString("PotentiallyMissingEnumerableValidationTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type {0} has validation annotations, but member {1} doesn't specify [ValidateObjectMembers] which could be an oversight. - /// - internal static string PotentiallyMissingTransitiveValidationMessage { - get { - return ResourceManager.GetString("PotentiallyMissingTransitiveValidationMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Member potentially missing transitive validation. - /// - internal static string PotentiallyMissingTransitiveValidationTitle { - get { - return ResourceManager.GetString("PotentiallyMissingTransitiveValidationTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Validator type {0} doesn't have a parameterless constructor. - /// - internal static string ValidatorsNeedSimpleConstructorMessage { - get { - return ResourceManager.GetString("ValidatorsNeedSimpleConstructorMessage", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Validators used for transitive or enumerable validation must have a constructor with no parameters. - /// - internal static string ValidatorsNeedSimpleConstructorTitle { - get { - return ResourceManager.GetString("ValidatorsNeedSimpleConstructorTitle", resourceCulture); - } - } - } -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.resx b/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.resx deleted file mode 100644 index d9bae1523ae..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/Resources.resx +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Type {0} already implements the Validate method - - - A type already includes an implementation of the `Validate` method - - - [OptionsValidator] cannot be applied to static class {0} - - - `OptionsValidatorAttribute` can't be applied to a static class - - - Can't use [ValidateObjectMembers] or [ValidateEnumeratedItems] on fields or properties with open generic type {0} - - - Can't use `ValidateObjectMembersAttribute` or `ValidateEnumeratedItemsAttribute` on fields or properties with open generic types - - - There is a circular type reference involving type {0} preventing it from being used for static validation - - - Unsupported circular references in model types - - - Type {0} does not implement the required IValidateOptions<{1}> interface - - - A type annotated with `OptionsValidatorAttribute` doesn't implement the necessary interface - - - Can't apply validation attributes to private field or property {0} - - - Can't validate private fields or properties - - - Type {0} has no fields or properties to validate, referenced from member {1} - - - Type {0} has no fields or properties to validate, referenced by type {1} - - - A type has no fields or properties to validate - - - A member type has no fields or properties to validate - - - [ValidateEnumeratedItems] cannot be used on members of type {0} as it doesn't implement IEnumerable<T> - - - Member type is not enumerable - - - Null validator type specified in [ValidateObjectMembers] or [ValidateEnumeratedItems] attributes - - - Null validator type specified for the `ValidateObjectMembersAttribute` or `ValidateEnumeratedItemsAttribute` attributes - - - Type {0} has validation annotations, but member {1} doesn't specify [ValidateEnumeratedItems] which could be an oversight - - - Member potentially missing enumerable validation - - - Type {0} has validation annotations, but member {1} doesn't specify [ValidateObjectMembers] which could be an oversight - - - Member potentially missing transitive validation - - - Validator type {0} doesn't have a parameterless constructor - - - Validators used for transitive or enumerable validation must have a constructor with no parameters - - diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolHolder.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolHolder.cs deleted file mode 100644 index 02d8deb9cd4..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolHolder.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; - -namespace Microsoft.Gen.OptionsValidation; - -/// -/// Holds required symbols for the . -/// -internal sealed record class SymbolHolder( - INamedTypeSymbol OptionsValidatorSymbol, - INamedTypeSymbol ValidationAttributeSymbol, - INamedTypeSymbol DataTypeAttributeSymbol, - INamedTypeSymbol ValidateOptionsSymbol, - INamedTypeSymbol IValidatableObjectSymbol, - INamedTypeSymbol TypeSymbol, - INamedTypeSymbol? LegacyValidateTransitivelyAttributeSymbol, - INamedTypeSymbol? ValidateObjectMembersAttributeSymbol, - INamedTypeSymbol? ValidateEnumeratedItemsAttributeSymbol); diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolLoader.cs b/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolLoader.cs deleted file mode 100644 index 8b365c7f68a..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Common/SymbolLoader.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.CodeAnalysis; - -namespace Microsoft.Gen.OptionsValidation; - -internal static class SymbolLoader -{ - public const string OptionsValidatorAttribute = "Microsoft.Extensions.Options.Validation.OptionsValidatorAttribute"; - internal const string ValidationAttribute = "System.ComponentModel.DataAnnotations.ValidationAttribute"; - internal const string DataTypeAttribute = "System.ComponentModel.DataAnnotations.DataTypeAttribute"; - internal const string IValidatableObjectType = "System.ComponentModel.DataAnnotations.IValidatableObject"; - internal const string IValidateOptionsType = "Microsoft.Extensions.Options.IValidateOptions`1"; - internal const string TypeOfType = "System.Type"; - internal const string LegacyValidateTransitivelyAttribute = "Microsoft.Extensions.Data.Validation.ValidateTransitivelyObjectMembersAttribute"; - internal const string ValidateObjectMembersAttribute = "Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute"; - internal const string ValidateEnumeratedItemsAttribute = "Microsoft.Extensions.Options.Validation.ValidateEnumeratedItemsAttribute"; - - public static bool TryLoad(Compilation compilation, out SymbolHolder? symbolHolder) - { - INamedTypeSymbol? GetSymbol(string metadataName, bool optional = false) - { - var symbol = compilation.GetTypeByMetadataName(metadataName); - if (symbol == null && !optional) - { - return null; - } - - return symbol; - } - - // required - var optionsValidatorSymbol = GetSymbol(OptionsValidatorAttribute); - var validationAttributeSymbol = GetSymbol(ValidationAttribute); - var dataTypeAttributeSymbol = GetSymbol(DataTypeAttribute); - var ivalidatableObjectSymbol = GetSymbol(IValidatableObjectType); - var validateOptionsSymbol = GetSymbol(IValidateOptionsType); - var typeSymbol = GetSymbol(TypeOfType); - -#pragma warning disable S1067 // Expressions should not be too complex - if (optionsValidatorSymbol == null || - validationAttributeSymbol == null || - dataTypeAttributeSymbol == null || - ivalidatableObjectSymbol == null || - validateOptionsSymbol == null || - typeSymbol == null) - { - symbolHolder = default; - return false; - } -#pragma warning restore S1067 // Expressions should not be too complex - - symbolHolder = new( - optionsValidatorSymbol, - validationAttributeSymbol, - dataTypeAttributeSymbol, - validateOptionsSymbol, - ivalidatableObjectSymbol, - typeSymbol, - - // optional - GetSymbol(LegacyValidateTransitivelyAttribute, optional: true), - GetSymbol(ValidateObjectMembersAttribute, optional: true), - GetSymbol(ValidateEnumeratedItemsAttribute, optional: true)); - - return true; - } -} diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Directory.Build.props b/src/Generators/Microsoft.Gen.OptionsValidation/Directory.Build.props deleted file mode 100644 index 882655d5161..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Directory.Build.props +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Microsoft.Gen.OptionsValidation - Code generator to support Microsoft.Extensions.Options.Validation. - Fundamentals - - - - cs - true - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.csproj b/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.csproj deleted file mode 100644 index e1ef356a7da..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.csproj +++ /dev/null @@ -1,28 +0,0 @@ - - - Microsoft.Gen.OptionsValidation - 3.8 - $(MicrosoftCodeAnalysisVersion_3_8) - - - - normal - 94 - 85 - 85 - - - - - True - True - Resources.resx - - - - - - - - - diff --git a/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.csproj b/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.csproj deleted file mode 100644 index 69d0da6a100..00000000000 --- a/src/Generators/Microsoft.Gen.OptionsValidation/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.csproj +++ /dev/null @@ -1,29 +0,0 @@ - - - Microsoft.Gen.OptionsValidation - 4.0 - $(MicrosoftCodeAnalysisVersion_4_0) - $(DefineConstants);ROSLYN_4_0_OR_GREATER - - - - normal - 94 - 85 - 50 - - - - - True - True - Resources.resx - - - - - - - - - diff --git a/src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs b/src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs index 6d7d44a95f8..af31c0f8151 100644 --- a/src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs +++ b/src/LegacySupport/ExperimentalAttribute/ExperimentalAttribute.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if !NET8_0_OR_GREATER + namespace System.Diagnostics.CodeAnalysis; /// @@ -24,30 +26,31 @@ internal sealed class ExperimentalAttribute : Attribute /// /// Initializes a new instance of the class. /// - public ExperimentalAttribute() + /// Human readable explanation for marking experimental API. + public ExperimentalAttribute(string diagnosticId) { - // Intentionally left empty. + DiagnosticId = diagnosticId; } /// - /// Initializes a new instance of the class. + /// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to. /// - /// Human readable explanation for marking experimental API. - public ExperimentalAttribute(string message) - { -#pragma warning disable R9A014 // Use the 'Microsoft.Extensions.Diagnostics.Throws' class instead of explicitly throwing exception for improved performance -#pragma warning disable R9A039 // Remove superfluous null check when compiling in a nullable context -#pragma warning disable R9A060 // Consider removing unnecessary null coalescing (??) since the left-hand value is statically known not to be null -#pragma warning disable SA1101 // Prefix local calls with this - Message = message ?? throw new ArgumentNullException(nameof(message)); -#pragma warning restore SA1101 // Prefix local calls with this -#pragma warning restore R9A060 // Consider removing unnecessary null coalescing (??) since the left-hand value is statically known not to be null -#pragma warning restore R9A039 // Remove superfluous null check when compiling in a nullable context -#pragma warning restore R9A014 // Use the 'Microsoft.Extensions.Diagnostics.Throws' class instead of explicitly throwing exception for improved performance - } + /// The unique diagnostic ID. + /// + /// The diagnostic ID is shown in build output for warnings and errors. + /// This property represents the unique ID that can be used to suppress the warnings or errors, if needed. + /// + public string DiagnosticId { get; } /// - /// Gets a human readable explanation for marking API as experimental. + /// Gets or sets the URL for corresponding documentation. + /// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID. /// - public string? Message { get; } + /// The format string that represents a URL to corresponding documentation. + /// An example format string is https://contoso.com/obsoletion-warnings/{0}. +#pragma warning disable S3996 // URI properties should not be strings + public string? UrlFormat { get; set; } +#pragma warning restore S3996 // URI properties should not be strings } + +#endif diff --git a/src/Libraries/Microsoft.AspNetCore.ConnectionTimeout/Microsoft.AspNetCore.ConnectionTimeout.csproj b/src/Libraries/Microsoft.AspNetCore.ConnectionTimeout/Microsoft.AspNetCore.ConnectionTimeout.csproj index e9d691fe350..56c24014a2c 100644 --- a/src/Libraries/Microsoft.AspNetCore.ConnectionTimeout/Microsoft.AspNetCore.ConnectionTimeout.csproj +++ b/src/Libraries/Microsoft.AspNetCore.ConnectionTimeout/Microsoft.AspNetCore.ConnectionTimeout.csproj @@ -23,7 +23,6 @@ - diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptionsValidator.cs b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptionsValidator.cs index 0e46ce7a346..772c1d7061d 100644 --- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptionsValidator.cs +++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/HeaderParsingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.AspNetCore.HeaderParsing; diff --git a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj index 80a4d8bb74e..af2b631d905 100644 --- a/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj +++ b/src/Libraries/Microsoft.AspNetCore.HeaderParsing/Microsoft.AspNetCore.HeaderParsing.csproj @@ -8,7 +8,6 @@ true - true true true true @@ -23,7 +22,6 @@ - diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Latency/Internal/RequestLatencyTelemetryOptionsValidator.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Latency/Internal/RequestLatencyTelemetryOptionsValidator.cs index 02665354649..ddfe44114dd 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Latency/Internal/RequestLatencyTelemetryOptionsValidator.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Latency/Internal/RequestLatencyTelemetryOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.AspNetCore.Telemetry.Internal; diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/Internal/LoggingOptionsValidator.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/Internal/LoggingOptionsValidator.cs index 851a41a3c8e..2cb7f021047 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/Internal/LoggingOptionsValidator.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/Internal/LoggingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.AspNetCore.Telemetry.Http.Logging; diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/LoggingOptions.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/LoggingOptions.cs index 9eb5339d5c9..5085a820bad 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/LoggingOptions.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Logging/LoggingOptions.cs @@ -67,7 +67,7 @@ public class LoggingOptions /// /// The default value is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode; /// @@ -208,7 +208,7 @@ public class LoggingOptions /// }; /// /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [Required] [SuppressMessage("Usage", "CA2227:Collection properties should be read only", Justification = "Options pattern.")] diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Microsoft.AspNetCore.Telemetry.Middleware.csproj b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Microsoft.AspNetCore.Telemetry.Middleware.csproj index 94d8909aa14..97bb0654713 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Microsoft.AspNetCore.Telemetry.Middleware.csproj +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry.Middleware/Microsoft.AspNetCore.Telemetry.Middleware.csproj @@ -8,7 +8,6 @@ $(NetCoreTargetFrameworks) - true true true false @@ -29,7 +28,6 @@ - diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersEnricherExtensions.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersEnricherExtensions.cs index 5e55a98f1c7..fb01da4fba3 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersEnricherExtensions.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersEnricherExtensions.cs @@ -5,6 +5,7 @@ using System.Diagnostics.CodeAnalysis; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Telemetry.Enrichment; using Microsoft.Shared.Diagnostics; diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptions.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptions.cs index 1f46f1d898a..eaf16a28132 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptions.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptions.cs @@ -20,7 +20,7 @@ public class RequestHeadersLogEnricherOptions /// Default value is an empty dictionary. /// [Required] - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] #pragma warning disable CA2227 // Collection properties should be read only public IDictionary HeadersDataClasses { get; set; } = new Dictionary(); #pragma warning restore CA2227 // Collection properties should be read only diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptionsValidator.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptionsValidator.cs index 43213594e43..86e322270ac 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptionsValidator.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Enrichment.RequestHeaders/RequestHeadersLogEnricherOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.AspNetCore.Telemetry; diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Microsoft.AspNetCore.Telemetry.csproj b/src/Libraries/Microsoft.AspNetCore.Telemetry/Microsoft.AspNetCore.Telemetry.csproj index 94f50e5b3a5..ab52ba161bf 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Microsoft.AspNetCore.Telemetry.csproj +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Microsoft.AspNetCore.Telemetry.csproj @@ -8,7 +8,6 @@ true - true false false false diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingExtensions.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingExtensions.cs index 0a2eaef5181..24f72a1ef9b 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingExtensions.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingExtensions.cs @@ -116,7 +116,7 @@ public static TracerProviderBuilder AddHttpTraceEnricher(this TracerProviderBuil /// The to add this enricher. /// for chaining. /// The argument is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddHttpTraceEnricher(this IServiceCollection services) where T : class, IHttpTraceEnricher { @@ -132,7 +132,7 @@ public static IServiceCollection AddHttpTraceEnricher(this IServiceCollection /// Enricher to be added. /// for chaining. /// The argument or is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddHttpTraceEnricher(this IServiceCollection services, IHttpTraceEnricher enricher) { _ = Throw.IfNull(services); diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingOptions.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingOptions.cs index baf648ebaf6..1b4f1d8a5a6 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingOptions.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/HttpTracingOptions.cs @@ -51,7 +51,7 @@ public class HttpTracingOptions /// /// This property is applicable when the option is enabled. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode; /// diff --git a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/Internal/HttpTracingOptionsValidator.cs b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/Internal/HttpTracingOptionsValidator.cs index 5a7146850a4..69bb8139805 100644 --- a/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/Internal/HttpTracingOptionsValidator.cs +++ b/src/Libraries/Microsoft.AspNetCore.Telemetry/Tracing/Internal/HttpTracingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.AspNetCore.Telemetry.Internal; diff --git a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataValidator.cs b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataValidator.cs index cf8e27ded88..8a129d03b8a 100644 --- a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataValidator.cs +++ b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/ApplicationMetadataValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.AmbientMetadata; diff --git a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj index 0aaa9620fba..7d860c650ba 100644 --- a/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj +++ b/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj @@ -5,10 +5,6 @@ Fundamentals - - true - - normal 100 @@ -16,7 +12,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.AsyncState/IAsyncLocalContext.cs b/src/Libraries/Microsoft.Extensions.AsyncState/IAsyncLocalContext.cs index a180eb275fb..be5e9025591 100644 --- a/src/Libraries/Microsoft.Extensions.AsyncState/IAsyncLocalContext.cs +++ b/src/Libraries/Microsoft.Extensions.AsyncState/IAsyncLocalContext.cs @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.AsyncState; /// /// The type of the asynchronous state. /// This type is intended for internal use. Use instead. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] #pragma warning disable S4023 // Interfaces should not be empty public interface IAsyncLocalContext : IAsyncContext diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj index d88e014f05a..15442d1a835 100644 --- a/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj +++ b/src/Libraries/Microsoft.Extensions.Compliance.Redaction/Microsoft.Extensions.Compliance.Redaction.csproj @@ -6,7 +6,6 @@ - true true diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactorOptionsAutoValidator.cs b/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactorOptionsAutoValidator.cs index 848234268c9..91ea505e36c 100644 --- a/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactorOptionsAutoValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Compliance.Testing/FakeRedactorOptionsAutoValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Compliance.Testing; diff --git a/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj b/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj index a09c5578f9b..10f6491f9df 100644 --- a/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj +++ b/src/Libraries/Microsoft.Extensions.Compliance.Testing/Microsoft.Extensions.Compliance.Testing.csproj @@ -7,7 +7,6 @@ - true true true true @@ -23,7 +22,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/CommonHealthChecksExtensions.TelemetryPublisher.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/CommonHealthChecksExtensions.TelemetryPublisher.cs index ac7cbf8edee..9034b7b9884 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/CommonHealthChecksExtensions.TelemetryPublisher.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/CommonHealthChecksExtensions.TelemetryPublisher.cs @@ -30,7 +30,7 @@ public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceC /// Configuration for . /// The value of . /// or are . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceCollection services, IConfigurationSection section) => Throw.IfNull(services) .Configure(Throw.IfNull(section)) @@ -44,7 +44,7 @@ public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceC /// Configuration for . /// The value of . /// or are . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddTelemetryHealthCheckPublisher(this IServiceCollection services, Action configure) => Throw.IfNull(services) .Configure(Throw.IfNull(configure)) diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/TelemetryHealthCheckPublisherOptions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/TelemetryHealthCheckPublisherOptions.cs index bf5d07c5dce..d2b1155551a 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/TelemetryHealthCheckPublisherOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.Common/TelemetryHealthCheckPublisherOptions.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Diagnostics.HealthChecks; /// /// Options for the telemetry health check publisher. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class TelemetryHealthCheckPublisherOptions { /// diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj index cacc4326872..8497c054823 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj @@ -6,7 +6,6 @@ - true true true diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptions.cs index 29afe898c19..115c94da936 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptions.cs @@ -3,7 +3,7 @@ using System; using Microsoft.Extensions.Diagnostics.ResourceMonitoring; -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; using Microsoft.Shared.Data.Validation; namespace Microsoft.Extensions.Diagnostics.HealthChecks; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptionsValidator.cs index 5ed6da4d506..2ed4d499a14 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheckOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Diagnostics.HealthChecks; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Kubernetes/TcpEndpointHealthCheckOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Kubernetes/TcpEndpointHealthCheckOptionsValidator.cs index b606417706d..0a11191883e 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Kubernetes/TcpEndpointHealthCheckOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Kubernetes/TcpEndpointHealthCheckOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Diagnostics.Probes; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj index deaa8dc277a..ec64ad46cc5 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.Probes/Microsoft.Extensions.Diagnostics.Probes.csproj @@ -7,7 +7,6 @@ true - true true true @@ -21,7 +20,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Internal/ResourceUtilizationTrackerOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Internal/ResourceUtilizationTrackerOptionsValidator.cs index e7c38f1bbeb..6295ecdaecd 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Internal/ResourceUtilizationTrackerOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Internal/ResourceUtilizationTrackerOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Internal/LinuxResourceUtilizationProviderOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Internal/LinuxResourceUtilizationProviderOptionsValidator.cs index b8e0ebc445c..7631d2d4d10 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Internal/LinuxResourceUtilizationProviderOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/Internal/LinuxResourceUtilizationProviderOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationExtensions.cs index 7c4163199ca..5183b37810e 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Linux/LinuxUtilizationExtensions.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Diagnostics.ResourceMonitoring.Internal; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Telemetry.Metering; using Microsoft.Shared.Diagnostics; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj index 532e55ea400..c09459bdb77 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Microsoft.Extensions.Diagnostics.ResourceMonitoring.csproj @@ -7,7 +7,6 @@ true - true true true true @@ -27,7 +26,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs index d6b55d14820..97f2b805ff1 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/ResourceMonitoringOptions.cs @@ -50,7 +50,7 @@ public class ResourceMonitoringOptions /// The value needs to be less than or equal to the . /// Most importantly, this period is used to calculate instances pushed to publishers. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [TimeSpan(MinimumSamplingWindow, MaximumSamplingWindow)] public TimeSpan CalculationPeriod { get; set; } = DefaultCollectionWindow; } diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Internal/WindowsCountersOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Internal/WindowsCountersOptionsValidator.cs index 501d31049df..2058dd53ecb 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Internal/WindowsCountersOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/Internal/WindowsCountersOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring; diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsCountersOptions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsCountersOptions.cs index 5d90106ce54..1678918817c 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsCountersOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsCountersOptions.cs @@ -12,7 +12,7 @@ namespace Microsoft.Extensions.Diagnostics.ResourceMonitoring; /// /// Options for WindowsCounters. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class WindowsCountersOptions { internal const int MinimumCachingInterval = 100; @@ -33,7 +33,7 @@ public class WindowsCountersOptions /// /// The default value is 5 seconds. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [TimeSpan(MinimumCachingInterval, MaximumCachingInterval)] public TimeSpan CachingInterval { get; set; } = DefaultCachingInterval; } diff --git a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsUtilizationExtensions.cs b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsUtilizationExtensions.cs index 211f6976e5e..1718e85d9e9 100644 --- a/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsUtilizationExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Diagnostics.ResourceMonitoring/Windows/WindowsUtilizationExtensions.cs @@ -65,7 +65,7 @@ public static IResourceMonitorBuilder AddWindowsPerfCounterPublisher(this IResou /// The value of . /// is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder) { _ = Throw.IfNull(builder); @@ -93,7 +93,7 @@ public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBu /// The value of . /// is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder, IConfigurationSection section) { _ = Throw.IfNull(builder); @@ -123,7 +123,7 @@ public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBu /// The value of . /// is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IResourceMonitorBuilder AddWindowsCounters(this IResourceMonitorBuilder builder, Action configure) { _ = Throw.IfNull(builder); diff --git a/src/Libraries/Microsoft.Extensions.Hosting.Testing/HostingFakesExtensions.cs b/src/Libraries/Microsoft.Extensions.Hosting.Testing/HostingFakesExtensions.cs index 57234351d7c..9d61e191b86 100644 --- a/src/Libraries/Microsoft.Extensions.Hosting.Testing/HostingFakesExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Hosting.Testing/HostingFakesExtensions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.Hosting.Testing; /// /// Extension methods supporting host unit testing scenarios. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class HostingFakesExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientAttribute.cs index 0c3323cde5f..43f66cda85e 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientAttribute.cs @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Interface)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class AutoClientAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientException.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientException.cs index e244ea0691d..56bdd54dae6 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientException.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientException.cs @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// /// [SuppressMessage("Design", "CA1032:Implement standard exception constructors", Justification = "Not applicable to this exception")] -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class AutoClientException : Exception { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientHttpError.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientHttpError.cs index 05b9b713973..a194a4c2d1c 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientHttpError.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientHttpError.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// When a REST API client fails, it will throw a . /// This exception contains a instance that holds details like content, headers and status code. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class AutoClientHttpError { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientOptions.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientOptions.cs index 63a961dcde7..11df36f248c 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/AutoClientOptions.cs @@ -21,7 +21,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// }); /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class AutoClientOptions { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyAttribute.cs index d6b3d8bf8d4..697c8806ee8 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyAttribute.cs @@ -24,7 +24,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Parameter)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class BodyAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyContentType.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyContentType.cs index 93baae2b791..4a4617cdc0b 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyContentType.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/BodyContentType.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// /// Defines the types of encoding possible for request bodies. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public enum BodyContentType { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/HeaderAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/HeaderAttribute.cs index 48a3d45a679..e1af6b6240f 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/HeaderAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/HeaderAttribute.cs @@ -23,7 +23,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Parameter)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class HeaderAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/DeleteAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/DeleteAttribute.cs index 8b2a2fd473f..ab67d7e61f8 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/DeleteAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/DeleteAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class DeleteAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/GetAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/GetAttribute.cs index 577a82321e2..29859dac58a 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/GetAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/GetAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class GetAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/HeadAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/HeadAttribute.cs index e9121a281b4..7ede1879fc4 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/HeadAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/HeadAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class HeadAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/OptionsAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/OptionsAttribute.cs index de23fa8d0f9..11659f78b06 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/OptionsAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/OptionsAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class OptionsAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PatchAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PatchAttribute.cs index 04e5803ab8d..489259c9c28 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PatchAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PatchAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class PatchAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PostAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PostAttribute.cs index a42a3f6bb16..52385dc5873 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PostAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PostAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class PostAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PutAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PutAttribute.cs index c7de67fa335..9342d15fca2 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PutAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Methods/PutAttribute.cs @@ -29,7 +29,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] public sealed class PutAttribute : Attribute { diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Microsoft.Extensions.Http.AutoClient.csproj b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Microsoft.Extensions.Http.AutoClient.csproj index 5c5b7eca3bc..4d4185e35b1 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/Microsoft.Extensions.Http.AutoClient.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/Microsoft.Extensions.Http.AutoClient.csproj @@ -6,7 +6,6 @@ - true true @@ -25,10 +24,6 @@ - - - - diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/QueryAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/QueryAttribute.cs index 0b9b9da47d1..306ad18839d 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/QueryAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/QueryAttribute.cs @@ -23,7 +23,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Parameter)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class QueryAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/RequestNameAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/RequestNameAttribute.cs index e3fbc2a2e8b..48cefbdc1e9 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/RequestNameAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/RequestNameAttribute.cs @@ -26,7 +26,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Method)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class RequestNameAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.AutoClient/StaticHeaderAttribute.cs b/src/Libraries/Microsoft.Extensions.Http.AutoClient/StaticHeaderAttribute.cs index 774d9716267..5c44944c918 100644 --- a/src/Libraries/Microsoft.Extensions.Http.AutoClient/StaticHeaderAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Http.AutoClient/StaticHeaderAttribute.cs @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.Http.AutoClient; /// } /// /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [AttributeUsage(AttributeTargets.Interface | AttributeTargets.Method, AllowMultiple = true)] [Conditional("CODE_GENERATION_ATTRIBUTES")] public sealed class StaticHeaderAttribute : Attribute diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/ContextExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/ContextExtensions.cs index 7ff798724cc..72f6fc491b8 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/ContextExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/ContextExtensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Http.Resilience.FaultInjection; /// /// Provides extension methods for . /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class ContextExtensions { private const string CallingRequestMessage = "CallingRequestMessage"; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/HttpClientFaultInjectionExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/HttpClientFaultInjectionExtensions.cs index a4d5e91c5c8..289b9aed156 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/HttpClientFaultInjectionExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/FaultInjection/HttpClientFaultInjectionExtensions.cs @@ -147,7 +147,7 @@ public static IHttpClientBuilder AddFaultInjectionPolicyHandler(this IHttpClient /// /// The so that additional calls can be chained. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IHttpClientBuilder AddWeightedFaultInjectionPolicyHandlers(this IHttpClientBuilder httpClientBuilder, Action weightAssignmentsConfig) { @@ -176,7 +176,7 @@ public static IHttpClientBuilder AddWeightedFaultInjectionPolicyHandlers(this IH /// /// The so that additional calls can be chained. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [DynamicDependency( DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.PublicParameterlessConstructor, typeof(FaultPolicyWeightAssignmentsOptions))] diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HedgingEndpointOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HedgingEndpointOptions.cs index d3b73a59afa..2b5eae1bfa7 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HedgingEndpointOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HedgingEndpointOptions.cs @@ -1,10 +1,11 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Http.Resilience.Internal.Validators; using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Http.Resilience.Internal.Validators; +using Microsoft.Extensions.Options; using Polly.Timeout; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HttpStandardHedgingResilienceOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HttpStandardHedgingResilienceOptions.cs index 7f4f560b2d4..5e1116cf789 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HttpStandardHedgingResilienceOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/HttpStandardHedgingResilienceOptions.cs @@ -1,11 +1,12 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.ComponentModel.DataAnnotations; using Microsoft.Extensions.Compliance.Classification; -using Microsoft.Extensions.Http.Resilience.Internal.Validators; using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Http.Resilience.Internal.Validators; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/Internals/Validators/HttpStandardHedgingResilienceOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/Internals/Validators/HttpStandardHedgingResilienceOptionsValidator.cs index d9c81573d81..7cc7faa75fd 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/Internals/Validators/HttpStandardHedgingResilienceOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/Internals/Validators/HttpStandardHedgingResilienceOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Resilience.Internal.Validators; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs index acfe72386ae..a51f69f3a82 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Hedging/StandardHedgingHandlerBuilderExtensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -65,7 +65,7 @@ public static IStandardHedgingHandlerBuilder Configure(this IStandardHedgingHand /// The strategy builder. /// The configure method. /// The same builder instance. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IStandardHedgingHandlerBuilder Configure(this IStandardHedgingHandlerBuilder builder, Action configure) { _ = Throw.IfNull(builder); diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj index b63bf4ab1c4..733b5ae0bb8 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Microsoft.Extensions.Http.Resilience.csproj @@ -10,7 +10,6 @@ true true true - true true true false @@ -28,7 +27,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceBuilderBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceBuilderBuilderExtensions.cs index ce8acf3c861..b3cee1fc974 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceBuilderBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceBuilderBuilderExtensions.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -65,7 +65,7 @@ public static IHttpStandardResilienceStrategyBuilder Configure(this IHttpStandar /// The configure method. /// The same builder instance. #pragma warning disable S3872 // Parameter names should not duplicate the names of their methods - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IHttpStandardResilienceStrategyBuilder Configure(this IHttpStandardResilienceStrategyBuilder builder, Action configure) #pragma warning restore S3872 // Parameter names should not duplicate the names of their methods { diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceOptions.cs index b3c58506e13..3c0cc196ce6 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/HttpStandardResilienceOptions.cs @@ -1,10 +1,11 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Http.Resilience.Internal; using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Http.Resilience.Internal; +using Microsoft.Extensions.Options; using Polly.Timeout; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/Internal/Validators/HttpStandardResilienceOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/Internal/Validators/HttpStandardResilienceOptionsValidator.cs index d07c5564bf4..06018537821 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/Internal/Validators/HttpStandardResilienceOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Resilience/Internal/Validators/HttpStandardResilienceOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Resilience.Internal.Validators; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/EndpointGroup.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/EndpointGroup.cs index 12a43a3959d..2c95550db07 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/EndpointGroup.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/EndpointGroup.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Collections.Generic; -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/OrderedGroups/OrderedGroupsRoutingOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/OrderedGroups/OrderedGroupsRoutingOptionsValidator.cs index f69a0cd7226..3ba6ed3df24 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/OrderedGroups/OrderedGroupsRoutingOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/OrderedGroups/OrderedGroupsRoutingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Resilience.Internal.Routing; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/WeightedGroups/WeightedGroupsRoutingOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/WeightedGroups/WeightedGroupsRoutingOptionsValidator.cs index 34659cd2bcb..35686af2ba3 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/WeightedGroups/WeightedGroupsRoutingOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/Internal/WeightedGroups/WeightedGroupsRoutingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Resilience.Internal.Routing; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/OrderedGroupsRoutingOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/OrderedGroupsRoutingOptions.cs index 0b99daabf7b..6d856ab6345 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/OrderedGroupsRoutingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/OrderedGroupsRoutingOptions.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/RoutingStrategyBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/RoutingStrategyBuilderExtensions.cs index fbd3530f7c1..f1ef1667a4a 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/RoutingStrategyBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/RoutingStrategyBuilderExtensions.cs @@ -67,7 +67,7 @@ public static IRoutingStrategyBuilder ConfigureOrderedGroups(this IRoutingStrate /// /// The same routing builder instance. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IRoutingStrategyBuilder ConfigureOrderedGroups(this IRoutingStrategyBuilder builder, Action configure) { _ = Throw.IfNull(builder); @@ -121,7 +121,7 @@ public static IRoutingStrategyBuilder ConfigureWeightedGroups(this IRoutingStrat /// /// The same routing builder instance. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IRoutingStrategyBuilder ConfigureWeightedGroups(this IRoutingStrategyBuilder builder, Action configure) { _ = Throw.IfNull(builder); diff --git a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/WeightedGroupsRoutingOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/WeightedGroupsRoutingOptions.cs index 7ce868e494d..5d3bdfa8bdd 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/WeightedGroupsRoutingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Resilience/Routing/WeightedGroupsRoutingOptions.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Http.Resilience; diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/Internal/LoggingOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/Internal/LoggingOptionsValidator.cs index 582d87fd874..64103a74b4d 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/Internal/LoggingOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/Internal/LoggingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Telemetry.Logging.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/LoggingOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/LoggingOptions.cs index 0d44db5149a..aa05eb08e3f 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/LoggingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Logging/LoggingOptions.cs @@ -134,7 +134,7 @@ public class LoggingOptions /// /// The default value is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode; /// diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpClientMeteringExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpClientMeteringExtensions.cs index 7927428efaf..5a96349c2ba 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpClientMeteringExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpClientMeteringExtensions.cs @@ -34,7 +34,7 @@ public static class HttpClientMeteringExtensions /// /// instance for chaining. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddHttpClientMeteringForAllHttpClients(this IServiceCollection services) { _ = Throw.IfNull(services); diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpMeteringHandler.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpMeteringHandler.cs index ba946b7198b..309ed468fc2 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpMeteringHandler.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpMeteringHandler.cs @@ -49,7 +49,7 @@ public class HttpMeteringHandler : DelegatingHandler /// /// The meter. /// Enumerable of outgoing request metric enrichers. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public HttpMeteringHandler( Meter meter, IEnumerable enrichers) diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpRequestResultType.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpRequestResultType.cs index d6c33a18376..a24204404d5 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpRequestResultType.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Metering/HttpRequestResultType.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Http.Telemetry.Metering; /// /// Statuses for classifying http request result. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EnumStrings] public enum HttpRequestResultType { diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Microsoft.Extensions.Http.Telemetry.csproj b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Microsoft.Extensions.Http.Telemetry.csproj index 2e1f3b162ae..5da0cb9d370 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Microsoft.Extensions.Http.Telemetry.csproj +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Microsoft.Extensions.Http.Telemetry.csproj @@ -8,7 +8,6 @@ true true - true true true false @@ -32,7 +31,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingExtensions.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingExtensions.cs index 5901f2668f3..85fff0062b3 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingExtensions.cs @@ -82,7 +82,7 @@ public static TracerProviderBuilder AddHttpClientTracing(this TracerProviderBuil /// The to add this enricher to. /// for chaining. /// The argument is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddHttpClientTraceEnricher(this IServiceCollection services) where T : class, IHttpClientTraceEnricher { @@ -98,7 +98,7 @@ public static IServiceCollection AddHttpClientTraceEnricher(this IServiceColl /// Enricher to be added. /// for chaining. /// The argument or is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddHttpClientTraceEnricher(this IServiceCollection services, IHttpClientTraceEnricher enricher) { _ = Throw.IfNull(services); diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingOptions.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingOptions.cs index ac0e56ff31c..a1b678643a9 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/HttpClientTracingOptions.cs @@ -23,7 +23,7 @@ public class HttpClientTracingOptions /// /// The default value is . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public HttpRouteParameterRedactionMode RequestPathParameterRedactionMode { get; set; } = DefaultPathParameterRedactionMode; /// diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpClientTraceEnricher.netfx.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpClientTraceEnricher.netfx.cs index e557eb5ac59..307325ab00f 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpClientTraceEnricher.netfx.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpClientTraceEnricher.netfx.cs @@ -23,7 +23,7 @@ public interface IHttpClientTraceEnricher /// /// If your enricher fetches some information from or to enrich HTTP traces, then make sure to check it for . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] void Enrich(Activity activity, HttpWebRequest? webRequest, HttpWebResponse? webResponse); } diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpPathRedactor.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpPathRedactor.cs index f15a5465e66..1ec02d6758f 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpPathRedactor.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/IHttpPathRedactor.cs @@ -10,7 +10,7 @@ namespace Microsoft.Extensions.Http.Telemetry.Tracing; /// /// Interface for implementing a redaction mechanism for outgoing HTTP request paths. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public interface IHttpPathRedactor { /// diff --git a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/Internal/HttpClientTracingOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/Internal/HttpClientTracingOptionsValidator.cs index bdae1d856eb..efb9c70c443 100644 --- a/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/Internal/HttpClientTracingOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Http.Telemetry/Tracing/Internal/HttpClientTracingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Http.Telemetry.Tracing.Internal; diff --git a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/DependencyInjectionPoolOptions.cs b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/DependencyInjectionPoolOptions.cs index cbb398634ee..f5002f122ca 100644 --- a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/DependencyInjectionPoolOptions.cs +++ b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/DependencyInjectionPoolOptions.cs @@ -8,7 +8,7 @@ namespace Microsoft.Extensions.ObjectPool; /// /// Contains configuration for pools. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public sealed class DependencyInjectionPoolOptions { internal const int DefaultCapacity = 1024; diff --git a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs index 2622a9d9958..29ea71e2995 100644 --- a/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.ObjectPool.DependencyInjection/ObjectPoolServiceCollectionExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.ObjectPool; /// /// Extension methods for adding to DI container. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class ObjectPoolServiceCollectionExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.csproj b/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.csproj deleted file mode 100644 index be466cb0dc0..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.csproj +++ /dev/null @@ -1,38 +0,0 @@ - - - Microsoft.Extensions.Options.Validation - Support for extended option validation. - Fundamentals - - - - true - true - true - true - - - - normal - 100 - 95 - 92 - - - - - - - - - - - - - - - - - - - diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.json b/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.json deleted file mode 100644 index 89c2e051c7d..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/Microsoft.Extensions.Options.Validation.json +++ /dev/null @@ -1,55 +0,0 @@ -{ - "Name": "Microsoft.Extensions.Options.Validation, Version=8.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", - "Types": [ - { - "Type": "sealed class Microsoft.Extensions.Options.Validation.OptionsValidatorAttribute : System.Attribute", - "Stage": "Stable", - "Methods": [ - { - "Member": "Microsoft.Extensions.Options.Validation.OptionsValidatorAttribute.OptionsValidatorAttribute();", - "Stage": "Stable" - } - ] - }, - { - "Type": "sealed class Microsoft.Extensions.Options.Validation.ValidateEnumeratedItemsAttribute : System.Attribute", - "Stage": "Experimental", - "Methods": [ - { - "Member": "Microsoft.Extensions.Options.Validation.ValidateEnumeratedItemsAttribute.ValidateEnumeratedItemsAttribute();", - "Stage": "Experimental" - }, - { - "Member": "Microsoft.Extensions.Options.Validation.ValidateEnumeratedItemsAttribute.ValidateEnumeratedItemsAttribute(System.Type validator);", - "Stage": "Experimental" - } - ], - "Properties": [ - { - "Member": "System.Type? Microsoft.Extensions.Options.Validation.ValidateEnumeratedItemsAttribute.Validator { get; }", - "Stage": "Experimental" - } - ] - }, - { - "Type": "sealed class Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute : System.Attribute", - "Stage": "Stable", - "Methods": [ - { - "Member": "Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute.ValidateObjectMembersAttribute();", - "Stage": "Stable" - }, - { - "Member": "Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute.ValidateObjectMembersAttribute(System.Type validator);", - "Stage": "Stable" - } - ], - "Properties": [ - { - "Member": "System.Type? Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute.Validator { get; }", - "Stage": "Stable" - } - ] - } - ] -} \ No newline at end of file diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/OptionsValidatorAttribute.cs b/src/Libraries/Microsoft.Extensions.Options.Validation/OptionsValidatorAttribute.cs deleted file mode 100644 index c5a8fa15ba4..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/OptionsValidatorAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics; - -namespace Microsoft.Extensions.Options.Validation; - -/// -/// Triggers the automatic generation of the implementation of at compile time. -/// -[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)] -[Conditional("CODE_GENERATION_ATTRIBUTES")] -public sealed class OptionsValidatorAttribute : Attribute -{ -} diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateEnumeratedItemsAttribute.cs b/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateEnumeratedItemsAttribute.cs deleted file mode 100644 index 11ccd1c22fd..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateEnumeratedItemsAttribute.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Options; - -namespace Microsoft.Extensions.Options.Validation; - -/// -/// Marks a field or property to be enumerated, and each enumerated object to be validated. -/// -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] -[Experimental] -public sealed class ValidateEnumeratedItemsAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// - /// Using this constructor for a field/property tells the code generator to - /// generate validation for the individual members of the enumerable's type. - /// - public ValidateEnumeratedItemsAttribute() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// A type that implements for the enumerable's type. - /// - /// Using this constructor for a field/property tells the code generator to use the given type to validate - /// the object held by the enumerable. - /// - public ValidateEnumeratedItemsAttribute(Type validator) - { - Validator = validator; - } - - /// - /// Gets the type to use to validate the enumerable's objects. - /// - public Type? Validator { get; } -} diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateObjectMembersAttribute.cs b/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateObjectMembersAttribute.cs deleted file mode 100644 index 6bdd46261f7..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/ValidateObjectMembersAttribute.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using Microsoft.Extensions.Options; - -namespace Microsoft.Extensions.Options.Validation; - -/// -/// Marks a field or property to be validated transitively. -/// -[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)] -public sealed class ValidateObjectMembersAttribute : Attribute -{ - /// - /// Initializes a new instance of the class. - /// - /// - /// Using this constructor for a field/property tells the code generator to - /// generate validation for the individual members of the field/property's type. - /// - public ValidateObjectMembersAttribute() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// A type that implements for the field/property's type. - /// - /// Using this constructor for a field/property tells the code generator to use the given type to validate - /// the object held by the field/property. - /// - public ValidateObjectMembersAttribute(Type validator) - { - Validator = validator; - } - - /// - /// Gets the type to use to validate a field or property. - /// - public Type? Validator { get; } -} diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.props b/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.props deleted file mode 100644 index 7bc91e44385..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.props +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.targets b/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.targets deleted file mode 100644 index ceadfacb28c..00000000000 --- a/src/Libraries/Microsoft.Extensions.Options.Validation/buildTransitive/Microsoft.Extensions.Options.Validation.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionExtensions.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionExtensions.cs index 315decc55e3..f57611abe36 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionExtensions.cs @@ -125,7 +125,7 @@ public static Context WithFaultInjection(this Context context, string groupName) /// /// Any of the parameters are . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static Context WithFaultInjection(this Context context, FaultPolicyWeightAssignmentsOptions weightAssignments) { _ = Throw.IfNull(context); diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionOptionsBuilder.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionOptionsBuilder.cs index eb126f6615f..93d68bd3c86 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionOptionsBuilder.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/FaultInjectionOptionsBuilder.cs @@ -126,7 +126,7 @@ public FaultInjectionOptionsBuilder AddException(string key, Exception exception /// /// is an empty string or . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public FaultInjectionOptionsBuilder AddCustomResult(string key, object customResult) { _ = Throw.IfNull(customResult); diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/IChaosPolicyFactory.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/IChaosPolicyFactory.cs index f89120b5073..32906ec0217 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/IChaosPolicyFactory.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/IChaosPolicyFactory.cs @@ -40,6 +40,6 @@ public interface IChaosPolicyFactory /// /// The type of value policies created by this method will inject. /// A custom result policy, an instance of . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public AsyncInjectOutcomePolicy CreateCustomResultPolicy(); } diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/ChaosPolicyOptionsGroup.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/ChaosPolicyOptionsGroup.cs index 13473760cc1..ee261e4c747 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/ChaosPolicyOptionsGroup.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/ChaosPolicyOptionsGroup.cs @@ -2,7 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Resilience.FaultInjection; @@ -42,6 +42,6 @@ public class ChaosPolicyOptionsGroup /// Gets or sets the custom result policy options of the chaos policy options group. /// [ValidateObjectMembers] - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public CustomResultPolicyOptions? CustomResultPolicyOptions { get; set; } } diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/CustomResultPolicyOptions.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/CustomResultPolicyOptions.cs index 92cea07fe31..8fd856fbe58 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/CustomResultPolicyOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/CustomResultPolicyOptions.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Resilience.FaultInjection; /// /// Custom Result chaos policy options definition. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class CustomResultPolicyOptions : ChaosPolicyOptionsBase { /// @@ -20,7 +20,7 @@ public class CustomResultPolicyOptions : ChaosPolicyOptionsBase /// from . /// Default is set to . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [Required] public string CustomResultKey { get; set; } = string.Empty; } diff --git a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/FaultPolicyWeightAssignmentsOptions.cs b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/FaultPolicyWeightAssignmentsOptions.cs index 05254afa450..53daba3e416 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/FaultPolicyWeightAssignmentsOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/FaultInjection/Options/FaultPolicyWeightAssignmentsOptions.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Resilience.FaultInjection; /// /// Class to contain fault-injection policy weight assignments. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class FaultPolicyWeightAssignmentsOptions { /// diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Microsoft.Extensions.Resilience.csproj b/src/Libraries/Microsoft.Extensions.Resilience/Microsoft.Extensions.Resilience.csproj index 24fddc1e8f9..4205a709204 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Microsoft.Extensions.Resilience.csproj +++ b/src/Libraries/Microsoft.Extensions.Resilience/Microsoft.Extensions.Resilience.csproj @@ -8,7 +8,6 @@ true true - true true true true @@ -27,7 +26,6 @@ - diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/PipelineId.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/PipelineId.cs index 94afb13edd6..4c995c9bcc6 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/PipelineId.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/PipelineId.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Resilience.Internal; /// /// Composite key for the pipeline. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] internal sealed record PipelineId(string PipelineName, string PipelineKey, string? ResultType, string PolicyPipelineKey) { /// @@ -19,7 +19,7 @@ internal sealed record PipelineId(string PipelineName, string PipelineKey, strin /// The pipeline name. /// The pipeline key. /// The pipeline id instance. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static PipelineId Create(string pipelineName, string pipelineKey) { var policyPipelineKey = string.IsNullOrEmpty(pipelineKey) ? $"{typeof(T).Name}-{pipelineName}" : $"{typeof(T).Name}-{pipelineName}-{pipelineKey}"; @@ -33,7 +33,7 @@ public static PipelineId Create(string pipelineName, string pipelineKey) /// The pipeline name. /// The pipeline key. /// The pipeline id instance. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static PipelineId Create(string pipelineName, string pipelineKey) { var policyPipelineKey = string.IsNullOrEmpty(pipelineKey) ? pipelineName : $"{pipelineName}-{pipelineKey}"; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/BulkheadPolicyOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/BulkheadPolicyOptionsValidator.cs index 933add3b643..936851360e0 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/BulkheadPolicyOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/BulkheadPolicyOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidator.cs index b9e44fb2c27..697662e702d 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidatorT.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidatorT.cs index 1721378ee28..f206d6f5b60 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidatorT.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/CircuitBreakerPolicyOptionsValidatorT.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidator.cs index 96912a27e8c..c337243b3e8 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidatorT.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidatorT.cs index 7a01df2ddfb..d96ec809a5d 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidatorT.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/HedgingPolicyOptionsValidatorT.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidator.cs index 79de3d93c12..0e5267a1be0 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidatorT.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidatorT.cs index 4f17bf0bbb0..80c1abb7fc0 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidatorT.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/RetryPolicyOptionsValidatorT.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/TimeoutPolicyOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/TimeoutPolicyOptionsValidator.cs index a12aee93c2c..adfd092cebf 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/TimeoutPolicyOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/Internals/Validators/Generated/TimeoutPolicyOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; using Microsoft.Extensions.Resilience.Options; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Polly/ResilienceDimensions.cs b/src/Libraries/Microsoft.Extensions.Resilience/Polly/ResilienceDimensions.cs index 52705a74e0a..a4343075435 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Polly/ResilienceDimensions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Polly/ResilienceDimensions.cs @@ -15,77 +15,77 @@ namespace Microsoft.Extensions.Resilience; /// Constants are standardized in MS Common Schema. /// // Avoid changing const values in this class by all means. Such a breaking change would break customer's monitoring. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public static class ResilienceDimensions { /// /// Pipeline name. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string PipelineName = "pipeline_name"; /// /// Pipeline key. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string PipelineKey = "pipeline_key"; /// /// Result type. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string ResultType = "result_type"; /// /// Policy name. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string PolicyName = "policy_name"; /// /// Event name. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string EventName = "event_name"; /// /// Failure source. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string FailureSource = "failure_source"; /// /// Failure reason. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string FailureReason = "failure_reason"; /// /// Failure summary. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string FailureSummary = "failure_summary"; /// /// Dependency name. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string DependencyName = "dep_name"; /// /// Request name. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public const string RequestName = "req_name"; @@ -93,7 +93,7 @@ public static class ResilienceDimensions /// Gets a list of all dimension names. /// /// A read-only of all dimension names. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [EditorBrowsable(EditorBrowsableState.Never)] public static IReadOnlyList DimensionNames { get; } = Array.AsReadOnly(new[] diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/OptionsBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/OptionsBuilderExtensions.cs index 0bff0195411..2a7fd66022a 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/OptionsBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/OptionsBuilderExtensions.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.Resilience.Internal; /// /// Extensions for . /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] internal static class OptionsBuilderExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineBuilderExtensions.cs b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineBuilderExtensions.cs index bc3e5c58506..9a6106c6e0b 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineBuilderExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineBuilderExtensions.cs @@ -15,7 +15,7 @@ namespace Microsoft.Extensions.Resilience.Internal; /// Pub-internal extension methods for the . /// /// Do not use this class directly, it's reserved for internal use and can change at any time. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] internal static class ResiliencePipelineBuilderExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineFactoryOptionsValidatorT.cs b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineFactoryOptionsValidatorT.cs index 12b23fc8587..11d677c1883 100644 --- a/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineFactoryOptionsValidatorT.cs +++ b/src/Libraries/Microsoft.Extensions.Resilience/Resilience/Internal/ResiliencePipelineFactoryOptionsValidatorT.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Resilience.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Http/TelemetryConstants.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Http/TelemetryConstants.cs index 7ccb595318c..e942a25099d 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Http/TelemetryConstants.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Http/TelemetryConstants.cs @@ -28,12 +28,12 @@ public static class TelemetryConstants /// /// Header for client application name, sent on an outgoing http call. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public const string ClientApplicationNameHeader = "X-ClientApplication"; /// /// Header for server application name, sent on a http request. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public const string ServerApplicationNameHeader = "X-ServerApplication"; } diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodAttribute.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodAttribute.cs index 5942a141091..8e7659d3cc2 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodAttribute.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Logging/LogMethodAttribute.cs @@ -266,7 +266,7 @@ public LogMethodAttribute(int eventId) /// } /// /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public LogMethodAttribute() { EventId = 0; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeterT.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeterT.cs index 6726b6cd6d2..3f2f6a034ab 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeterT.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeterT.cs @@ -12,13 +12,13 @@ namespace Microsoft.Extensions.Telemetry.Metering; /// A meter class where the meter name is derived from the specified type name. /// /// The type whose name is used as the meter name. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class Meter : Meter { /// /// Initializes a new instance of the class. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public Meter() : base(typeof(TMeterName).FullName!) { diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeteringExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeteringExtensions.cs index e69dbb13093..a4f6354dabc 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeteringExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Abstractions/Metering/MeteringExtensions.cs @@ -17,7 +17,7 @@ public static class MeteringExtensions /// /// The dependency injection container to register metering into. /// The value of . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection RegisterMetering(this IServiceCollection services) { services.TryAdd(ServiceDescriptor.Singleton(typeof(Meter<>), typeof(Meter<>))); diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/CollectedMeasurement.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/CollectedMeasurement.cs index c3624db32c0..687a62b44d7 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/CollectedMeasurement.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/CollectedMeasurement.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Telemetry.Testing.Metering; /// Represents a single measurement performed by an instrument. /// /// The type of metric measurement value. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [DebuggerDisplay("{DebuggerToString(),nq}")] public sealed class CollectedMeasurement where T : struct diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MeasurementExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MeasurementExtensions.cs index 9986306f002..ee8bed03241 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MeasurementExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MeasurementExtensions.cs @@ -11,7 +11,7 @@ namespace Microsoft.Extensions.Telemetry.Testing.Metering; /// /// Extensions to simplify working with lists of measurements. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class MeasurementExtensions { /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MetricCollector.cs b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MetricCollector.cs index 4d162b9b5ab..cdf8405b73f 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MetricCollector.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry.Testing/Metering/MetricCollector.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -17,7 +17,7 @@ namespace Microsoft.Extensions.Telemetry.Testing.Metering; /// Collects the measurements published from an or . /// /// The type of metric data being recorded. -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [DebuggerDisplay("{_measurements.Count} measurements")] public sealed class MetricCollector : IDisposable where T : struct diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggerProvider.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggerProvider.cs index b913abc9027..7a724330783 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggerProvider.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggerProvider.cs @@ -19,7 +19,7 @@ namespace Microsoft.Extensions.Telemetry.Logging; /// OpenTelemetry Logger provider class. /// [ProviderAlias("R9")] -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public sealed class LoggerProvider : BaseProvider, ILoggerProvider, ISupportExternalScope { private const int ProcessorShutdownGracePeriodInMs = 5000; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptions.cs index 1188d2f7e11..8cdc35b2251 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptions.cs @@ -59,7 +59,7 @@ public class LoggingOptions /// /// When set to a value less than 2 KB or greater than 32 KB, an exception will be thrown. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] [Range(MinDefinedStackTraceLength, MaxDefinedStackTraceLength, ErrorMessage = "Maximum stack trace length should be between 2kb and 32kb")] public int MaxStackTraceLength { get; set; } = DefaultStackTraceLength; } diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptionsValidator.cs index 9d9489c9a66..3f396c504e6 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Logging/LoggingOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Telemetry.Logging; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/EventCountersCollectorOptions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/EventCountersCollectorOptions.cs index 2bb199698a3..d9be1869744 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/EventCountersCollectorOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/EventCountersCollectorOptions.cs @@ -69,7 +69,7 @@ public class EventCountersCollectorOptions /// EventSource: "Microsoft-AspNetCore-Server-Kestrel", Counters: /// - "connection-queue-length", "request-queue-length". /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public bool IncludeRecommendedDefault { get; set; } #if NET5_0_OR_GREATER diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/Internal/EventCountersCollectorOptionsValidator.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/Internal/EventCountersCollectorOptionsValidator.cs index 8eb3e85bc89..0c70de10791 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/Internal/EventCountersCollectorOptionsValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Metering.Collectors.EventCounters/Internal/EventCountersCollectorOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Telemetry.Metering.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Metering/MeteringOptions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Metering/MeteringOptions.cs index 76b4234fd6f..141a982c8f4 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Metering/MeteringOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Metering/MeteringOptions.cs @@ -9,7 +9,7 @@ namespace Microsoft.Extensions.Telemetry.Metering; /// /// Options for configuring metering. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class MeteringOptions { /// diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Metering/OTelMeteringExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Metering/OTelMeteringExtensions.cs index 688762886bc..3fccb6ef825 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Metering/OTelMeteringExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Metering/OTelMeteringExtensions.cs @@ -14,7 +14,7 @@ namespace Microsoft.Extensions.Telemetry.Metering; /// /// Metering extensions for OpenTelemetry based metrics. /// -[Experimental] +[Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class OTelMeteringExtensions { /// @@ -22,7 +22,7 @@ public static class OTelMeteringExtensions /// /// instance. /// Returns for chaining. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static MeterProviderBuilder AddMetering( this MeterProviderBuilder builder) { @@ -35,7 +35,7 @@ public static MeterProviderBuilder AddMetering( /// instance. /// Configuration section that contains . /// Returns for chaining. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static MeterProviderBuilder AddMetering( this MeterProviderBuilder builder, IConfigurationSection configurationSection) @@ -52,7 +52,7 @@ public static MeterProviderBuilder AddMetering( /// instance. /// The configuration delegate. /// Returns for chaining. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static MeterProviderBuilder AddMetering( this MeterProviderBuilder builder, Action configure) diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj b/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj index 026721a8001..31890f7372b 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj @@ -16,7 +16,6 @@ true true true - true @@ -29,12 +28,12 @@ - + diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry.Internal/IHttpRouteFormatter.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry.Internal/IHttpRouteFormatter.cs index f109271773f..258e30afd33 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry.Internal/IHttpRouteFormatter.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry.Internal/IHttpRouteFormatter.cs @@ -21,7 +21,7 @@ internal interface IHttpRouteFormatter /// Strategy to decide how parameters are redacted. /// Dictionary of parameters with their data classification that needs to be redacted. /// Returns formatted path with sensitive parameter values redacted. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] string Format(string httpRoute, string httpPath, HttpRouteParameterRedactionMode redactionMode, IReadOnlyDictionary parametersToRedact); /// @@ -32,6 +32,6 @@ internal interface IHttpRouteFormatter /// Strategy to decide how parameters are redacted. /// Dictionary of parameters with their data classification that needs to be redacted. /// Returns formatted path with sensitive parameter values redacted. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] string Format(in ParsedRouteSegments routeSegments, string httpPath, HttpRouteParameterRedactionMode redactionMode, IReadOnlyDictionary parametersToRedact); } diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry/TelemetryExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry/TelemetryExtensions.cs index 1d106201a91..911759ca8d1 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry/TelemetryExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Telemetry/TelemetryExtensions.cs @@ -25,7 +25,7 @@ public static class TelemetryExtensions /// /// object. /// Metadata for the request. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static void SetRequestMetadata(this HttpWebRequest request, RequestMetadata metadata) { _ = Throw.IfNull(request); @@ -58,7 +58,7 @@ public static void SetRequestMetadata(this HttpRequestMessage request, RequestMe /// /// object. /// Request metadata. - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static RequestMetadata? GetRequestMetadata(this HttpWebRequest request) { _ = Throw.IfNull(request); diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/Internal/SamplingOptionsAutoValidator.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/Internal/SamplingOptionsAutoValidator.cs index 083fd1c358f..6ad25eb2e93 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/Internal/SamplingOptionsAutoValidator.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/Internal/SamplingOptionsAutoValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Telemetry.Tracing.Internal; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/ParentBasedSamplerOptions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/ParentBasedSamplerOptions.cs index aee2e9731ea..b77dffb8eba 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/ParentBasedSamplerOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/ParentBasedSamplerOptions.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Telemetry.Tracing; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/SamplingOptions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/SamplingOptions.cs index 5c109e773bc..a91b19dcce8 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/SamplingOptions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing.Sampling/SamplingOptions.cs @@ -1,7 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Microsoft.Extensions.Options.Validation; +using Microsoft.Extensions.Options; namespace Microsoft.Extensions.Telemetry.Tracing; diff --git a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing/TracingEnricherExtensions.cs b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing/TracingEnricherExtensions.cs index 36cc62c5b47..76854f58e0d 100644 --- a/src/Libraries/Microsoft.Extensions.Telemetry/Tracing/TracingEnricherExtensions.cs +++ b/src/Libraries/Microsoft.Extensions.Telemetry/Tracing/TracingEnricherExtensions.cs @@ -53,7 +53,7 @@ public static TracerProviderBuilder AddTraceEnricher(this TracerProviderBuilder /// The to add this enricher to. /// The so that additional calls can be chained. /// The argument is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddTraceEnricher(this IServiceCollection services) where T : class, ITraceEnricher { @@ -71,7 +71,7 @@ public static IServiceCollection AddTraceEnricher(this IServiceCollection ser /// Enricher to be added. /// The so that additional calls can be chained. /// The argument or is . - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static IServiceCollection AddTraceEnricher(this IServiceCollection services, ITraceEnricher enricher) { _ = Throw.IfNull(services); diff --git a/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs b/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs index 55c8310299b..695f0a13d0e 100644 --- a/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs +++ b/src/Libraries/Microsoft.Extensions.TimeProvider.Testing/FakeTimeProvider.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; @@ -30,7 +30,7 @@ public class FakeTimeProvider : TimeProvider /// This creates a provider whose time is initially set to midnight January 1st 2000. /// The provider is set to not automatically advance time each time it is read. /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public FakeTimeProvider() { Start = _now; @@ -64,7 +64,7 @@ public FakeTimeProvider(DateTimeOffset startDateTime) /// /// This defaults to . /// - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public TimeSpan AutoAdvanceAmount { get => _autoAdvanceAmount; diff --git a/src/ToBeMoved/Hosting.StartupInitialization/Hosting.StartupInitialization.csproj b/src/ToBeMoved/Hosting.StartupInitialization/Hosting.StartupInitialization.csproj index 58974307386..6efbe56cc68 100644 --- a/src/ToBeMoved/Hosting.StartupInitialization/Hosting.StartupInitialization.csproj +++ b/src/ToBeMoved/Hosting.StartupInitialization/Hosting.StartupInitialization.csproj @@ -6,7 +6,6 @@ Provides infrastructure to execute asynchronous functions on server startups Fundamentals Application Bootstrap - true true true true @@ -28,7 +27,6 @@ - diff --git a/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationBuilder.cs b/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationBuilder.cs index 6c70493a12c..c82281e9cae 100644 --- a/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationBuilder.cs +++ b/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationBuilder.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Options.Validation; using Microsoft.Shared.Diagnostics; diff --git a/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationOptionsValidator.cs b/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationOptionsValidator.cs index a15058129ea..20b926881e5 100644 --- a/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationOptionsValidator.cs +++ b/src/ToBeMoved/Hosting.StartupInitialization/Internal/StartupInitializationOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.Hosting.Testing.Internal; diff --git a/src/ToBeMoved/Hosting.StartupInitialization/StartupInitializationExtensions.cs b/src/ToBeMoved/Hosting.StartupInitialization/StartupInitializationExtensions.cs index 31276de6c92..00371c48685 100644 --- a/src/ToBeMoved/Hosting.StartupInitialization/StartupInitializationExtensions.cs +++ b/src/ToBeMoved/Hosting.StartupInitialization/StartupInitializationExtensions.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting.Testing.Internal; +using Microsoft.Extensions.Options; using Microsoft.Extensions.Options.Validation; using Microsoft.Shared.Diagnostics; diff --git a/src/ToBeMoved/HttpClient.SocketHandling/HttpClient.SocketHandling.csproj b/src/ToBeMoved/HttpClient.SocketHandling/HttpClient.SocketHandling.csproj index 288becef1e3..03b7a3f67da 100644 --- a/src/ToBeMoved/HttpClient.SocketHandling/HttpClient.SocketHandling.csproj +++ b/src/ToBeMoved/HttpClient.SocketHandling/HttpClient.SocketHandling.csproj @@ -7,7 +7,6 @@ Fundamentals HTTP Processing $(NetCoreTargetFrameworks) - true true @@ -23,7 +22,6 @@ - diff --git a/src/ToBeMoved/HttpClient.SocketHandling/SocketsHttpHandlerOptionsValidator.cs b/src/ToBeMoved/HttpClient.SocketHandling/SocketsHttpHandlerOptionsValidator.cs index c5c343d8ef2..4a05de361d1 100644 --- a/src/ToBeMoved/HttpClient.SocketHandling/SocketsHttpHandlerOptionsValidator.cs +++ b/src/ToBeMoved/HttpClient.SocketHandling/SocketsHttpHandlerOptionsValidator.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; namespace Microsoft.Extensions.HttpClient.SocketHandling; diff --git a/test/Analyzers/Microsoft.Extensions.ExtraAnalyzers/Common/UsingExperimentalApiAnalyzerTest.cs b/test/Analyzers/Microsoft.Extensions.ExtraAnalyzers/Common/UsingExperimentalApiAnalyzerTest.cs index 972b29df052..3e2771f0a7e 100644 --- a/test/Analyzers/Microsoft.Extensions.ExtraAnalyzers/Common/UsingExperimentalApiAnalyzerTest.cs +++ b/test/Analyzers/Microsoft.Extensions.ExtraAnalyzers/Common/UsingExperimentalApiAnalyzerTest.cs @@ -13,19 +13,12 @@ public static class UsingExperimentalApiAnalyzerTest [MemberData(nameof(TestData))] public static async Task Common(string source) { - const string AttributeSource = @" - namespace System.Diagnostics.CodeAnalysis - { - public sealed class ExperimentalAttribute : System.Attribute { } - }"; - var d = await RoslynTestUtils.RunAnalyzer( new UsingExperimentalApiAnalyzer(), null, new[] { source, - AttributeSource, }).ConfigureAwait(false); var expectedCount = source.CountSpans(); @@ -67,7 +60,7 @@ public void Test() } } - [Experimental] + [Experimental(diagnosticId: ""TBD"", UrlFormat = ""TBD"")] public class ExpClass { } @@ -81,7 +74,7 @@ public class ExpClass using System.Diagnostics.CodeAnalysis; #pragma warning disable R9A029 - [assembly: Experimental] + [assembly: Experimental(diagnosticId: ""TBD"", UrlFormat = ""TBD"")] #pragma warning restore R9A029 public class TestClass : /*0+*/ExpClass/*-0*/ diff --git a/test/Analyzers/Microsoft.Extensions.LocalAnalyzers/ApiLifecycle/ApiLifecycleAnalyzerTest.cs b/test/Analyzers/Microsoft.Extensions.LocalAnalyzers/ApiLifecycle/ApiLifecycleAnalyzerTest.cs index 4f81b21e6fd..379a0fe65df 100644 --- a/test/Analyzers/Microsoft.Extensions.LocalAnalyzers/ApiLifecycle/ApiLifecycleAnalyzerTest.cs +++ b/test/Analyzers/Microsoft.Extensions.LocalAnalyzers/ApiLifecycle/ApiLifecycleAnalyzerTest.cs @@ -228,7 +228,7 @@ namespace Microsoft.Extensions.Security.Identity; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class AdditionalContext2 { protected IReadOnlyDictionary Features { get; } = new Dictionary(); @@ -347,7 +347,7 @@ public sealed class BufferWriter2 : IBufferWriter private T[] _buffer = Array.Empty(); - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public BufferWriter2() { } public ReadOnlyMemory WrittenMemory => _buffer.AsMemory(0, WrittenCount); @@ -474,7 +474,7 @@ public interface IClassifiedData public DataClass DataClass { get; } } - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public enum DataClass { @@ -562,10 +562,10 @@ namespace SomePackage; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static class Test { - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public static void Load() { // Intentionally left empty. @@ -707,7 +707,7 @@ namespace Microsoft.Extensions.Diagnostics; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class WindowsCountersOptions2 { [Required] @@ -728,7 +728,7 @@ namespace Test; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public sealed class BufferWriter { internal const int MaxArrayLength = 0X7FEF_FFFF; // Copy of the internal Array.MaxArrayLength const @@ -751,7 +751,7 @@ namespace Inheritance; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class BaseType { public virtual int P => 1; @@ -774,7 +774,7 @@ namespace Nested; using System.Diagnostics.CodeAnalysis; - [Experimental] + [Experimental(diagnosticId: "TBD", UrlFormat = "TBD")] public class OuterType { public int ReadValue(string s) => new InnerType().P; diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/CustomAttrTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/CustomAttrTests.cs deleted file mode 100644 index 9770924b5b1..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/CustomAttrTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using CustomAttr; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class CustomAttrTests -{ - [Fact] - public void Invalid() - { - var firstModel = new FirstModel - { - P1 = 'a', - P2 = 'x', - }; - - var validator = new FirstValidator(); - var vr = validator.Validate("CustomAttr", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 2, "P1", "P2"); - } - - [Fact] - public void Valid() - { - var firstModel = new FirstModel - { - P1 = 'A', - P2 = 'A', - }; - - var validator = new FirstValidator(); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("CustomAttr", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/EnumerationTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/EnumerationTests.cs deleted file mode 100644 index d2f9bddca28..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/EnumerationTests.cs +++ /dev/null @@ -1,93 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Enumeration; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class EnumerationTests -{ - [Fact] - public void Invalid() - { - var secondModelC = new SecondModel - { - P6 = "1234", - }; - - var secondModelB = new SecondModel - { - P6 = "12345", - }; - - var secondModel = new SecondModel - { - P6 = "1234", - }; - - ThirdModel? thirdModel = new ThirdModel - { - Value = 11 - }; - - var firstModel = new FirstModel - { - P1 = new[] { secondModel }, - P2 = new[] { secondModel, secondModelB, secondModelC }, - P51 = new[] { thirdModel } - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("Enumeration", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 4, "P1[0].P6", "P2[0].P6", "P2[2].P6", "P51[0].Value"); - } - - [Fact] - public void NullElement() - { - var firstModel = new FirstModel - { - P1 = new[] { (SecondModel)null! }, - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("Enumeration", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 1, "P1[0]"); - } - - [Fact] - public void Valid() - { - var secondModel = new SecondModel - { - P6 = "12345", - }; - - var thirdModelA = new ThirdModel - { - Value = 2 - }; - - var thirdModelB = new ThirdModel - { - Value = 9 - }; - - var firstModel = new FirstModel - { - P1 = new[] { secondModel }, - P2 = new[] { secondModel }, - P3 = new[] { (SecondModel?)null }, - P4 = new[] { thirdModelA, thirdModelB }, - P5 = new ThirdModel?[] { thirdModelA, default }, - P51 = new ThirdModel?[] { thirdModelB, default } - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("Enumeration", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FieldTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FieldTests.cs deleted file mode 100644 index 3656d4f359e..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FieldTests.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Fields; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class FieldTests -{ - [Fact] - public void Invalid() - { - var thirdModel = new ThirdModel - { - P5 = "1234", - }; - - var secondModel = new SecondModel - { - P4 = "1234", - }; - - var firstModel = new FirstModel - { - P1 = "1234", - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("Fields", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 3, "P1", "P2.P4", "P3.P5"); - } - - [Fact] - public void Valid() - { - var thirdModel = new ThirdModel - { - P5 = "12345", - P6 = 1 - }; - - var secondModel = new SecondModel - { - P4 = "12345", - }; - - var firstModel = new FirstModel - { - P1 = "12345", - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("Fields", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FunnyStringsTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FunnyStringsTests.cs deleted file mode 100644 index 29b62a5c4b4..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/FunnyStringsTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using FunnyStrings; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class FunnyStringsTests -{ - [Fact] - public void Invalid() - { - var firstModel = new FirstModel - { - P1 = "XXX", - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("FunnyStrings", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 1, "P1"); - } - - [Fact] - public void Valid() - { - var firstModel = new FirstModel - { - P1 = "\"\r\n\\", - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("FunnyStrings", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/GenericsTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/GenericsTests.cs deleted file mode 100644 index 838fe529689..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/GenericsTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Generics; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class GenericsTests -{ - [Fact] - public void Invalid() - { - var secondModel = new SecondModel - { - P4 = "1234", - }; - - var firstModel = new FirstModel - { - P1 = "1234", - P3 = secondModel, - }; - - var validator = new FirstValidator(); - var vr = validator.Validate("Generics", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 2, "P1", "P3.P4"); - } - - [Fact] - public void Valid() - { - var secondModel = new SecondModel - { - P4 = "12345", - }; - - var firstModel = new FirstModel - { - P1 = "12345", - P3 = secondModel, - }; - - var validator = new FirstValidator(); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("Generics", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/MultiModelValidatorTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/MultiModelValidatorTests.cs deleted file mode 100644 index fff83ced918..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/MultiModelValidatorTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using MultiModelValidator; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class MultiModelValidatorTests -{ - [Fact] - public void Invalid() - { - var secondModel = new SecondModel - { - P3 = "1234", - }; - - var firstModel = new FirstModel - { - P1 = "1234", - P2 = secondModel, - }; - - var validator = default(MultiValidator); - var vr = validator.Validate("MultiModelValidator", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 2, "P1", "P2.P3"); - } - - [Fact] - public void Valid() - { - var secondModel = new SecondModel - { - P3 = "12345", - }; - - var firstModel = new FirstModel - { - P1 = "12345", - P2 = secondModel, - }; - - var validator = default(MultiValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("MultiModelValidator", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NestedTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NestedTests.cs deleted file mode 100644 index 8a4b04361a3..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NestedTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if ROSLYN_4_0_OR_GREATER - -using Microsoft.Extensions.Options; -using Nested; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class NestedTests -{ - [Fact] - public void Invalid() - { - var thirdModel = new Container1.ThirdModel - { - P6 = "1234", - }; - - var secondModel = new Container1.SecondModel - { - P5 = "1234", - }; - - var firstModel = new Container1.FirstModel - { - P1 = "1234", - P2 = secondModel, - P3 = thirdModel, - P4 = secondModel, - }; - - var validator = default(Container2.Container3.FirstValidator); - var vr = validator.Validate("Nested", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 4, "P1", "P2.P5", "P3.P6", "P4.P5"); - } - - [Fact] - public void Valid() - { - var thirdModel = new Container1.ThirdModel - { - P6 = "12345", - }; - - var secondModel = new Container1.SecondModel - { - P5 = "12345", - }; - - var firstModel = new Container1.FirstModel - { - P1 = "12345", - P2 = secondModel, - P3 = thirdModel, - P4 = secondModel, - }; - - var validator = default(Container2.Container3.FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("Nested", firstModel)); - } -} - -#endif diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NoNamespaceTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NoNamespaceTests.cs deleted file mode 100644 index 5530b639531..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/NoNamespaceTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class NoNamespaceTests -{ - [Fact] - public void Invalid() - { - var thirdModel = new ThirdModelNoNamespace - { - P5 = "1234", - }; - - var secondModel = new SecondModelNoNamespace - { - P4 = "1234", - }; - - var firstModel = new FirstModelNoNamespace - { - P1 = "1234", - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = new FirstValidatorNoNamespace(); - var vr = validator.Validate("NoNamespace", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 3, "P1", "P2.P4", "P3.P5"); - } - - [Fact] - public void Valid() - { - var thirdModel = new ThirdModelNoNamespace - { - P5 = "12345", - }; - - var secondModel = new SecondModelNoNamespace - { - P4 = "12345", - }; - - var firstModel = new FirstModelNoNamespace - { - P1 = "12345", - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = new FirstValidatorNoNamespace(); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("NoNamespace", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/OptionsValidationTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/OptionsValidationTests.cs deleted file mode 100644 index 49941010f1a..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/OptionsValidationTests.cs +++ /dev/null @@ -1,442 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using Microsoft.Extensions.Options; -using TestClasses.OptionsValidation; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class OptionsValidationTests -{ - [Fact] - public void RequiredAttributeValid() - { - var validModel = new RequiredAttributeModel - { - Val = "val" - }; - - var modelValidator = new RequiredAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RequiredAttributeInvalid() - { - var validModel = new RequiredAttributeModel - { - Val = null - }; - - var modelValidator = new RequiredAttributeModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void RegularExpressionAttributeValid() - { - var validModel = new RegularExpressionAttributeModel - { - Val = " " - }; - - var modelValidator = new RegularExpressionAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RegularExpressionAttributeInvalid() - { - var validModel = new RegularExpressionAttributeModel - { - Val = "Not Space" - }; - - var modelValidator = new RegularExpressionAttributeModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void EmailAttributeValid() - { - var validModel = new EmailAttributeModel - { - Val = "abc@xyz.com" - }; - - var modelValidator = new EmailAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void EmailAttributeInvalid() - { - var validModel = new EmailAttributeModel - { - Val = "Not Email Address" - }; - - var modelValidator = new EmailAttributeModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void CustomValidationAttributeValid() - { - var validModel = new CustomValidationAttributeModel - { - Val = "Pass" - }; - - var modelValidator = new CustomValidationAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void CustomValidationAttributeInvalid() - { - var validModel = new CustomValidationAttributeModel - { - Val = "NOT PASS" - }; - - var modelValidator = new CustomValidationAttributeModelValidator(); - Assert.Throws(() => modelValidator.Validate(nameof(validModel), validModel)); - } - - [Fact] - public void DataTypeAttributeValid() - { - var validModel = new DataTypeAttributeModel - { - Val = "ABC" - }; - - var modelValidator = new DataTypeAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RangeAttributeModelIntValid() - { - var validModel = new RangeAttributeModelInt - { - Val = 1 - }; - - var modelValidator = new RangeAttributeModelIntValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RangeAttributeModelIntInvalid() - { - var validModel = new RangeAttributeModelInt - { - Val = 0 - }; - - var modelValidator = new RangeAttributeModelIntValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void RangeAttributeModelDoubleValid() - { - var validModel = new RangeAttributeModelDouble - { - Val = 0.6 - }; - - var modelValidator = new RangeAttributeModelDoubleValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RangeAttributeModelDoubleInvalid() - { - var validModel = new RangeAttributeModelDouble - { - Val = 0.1 - }; - - var modelValidator = new RangeAttributeModelDoubleValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void RangeAttributeModelDateValid() - { -#if NETCOREAPP3_1_OR_GREATER - // Setting non-invariant culture to check that - // attribute's "ParseLimitsInInvariantCulture" property - // was set up correctly in the validator: - CultureInfo.CurrentCulture = new CultureInfo("cs"); -#else - // Setting invariant culture to avoid DateTime parsing discrepancies: - CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; -#endif - var validModel = new RangeAttributeModelDate - { - Val = new DateTime(day: 3, month: 1, year: 2004) - }; - - var modelValidator = new RangeAttributeModelDateValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void RangeAttributeModelDateInvalid() - { - var validModel = new RangeAttributeModelDate - { - Val = new DateTime(day: 1, month: 1, year: 2004) - }; - - var modelValidator = new RangeAttributeModelDateValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void MultipleAttributeModelValid() - { - var validModel = new MultipleAttributeModel - { - Val1 = "abc", - Val2 = 2, - Val3 = 4, - Val4 = 6 - }; - - var modelValidator = new MultipleAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Theory] - [InlineData("", 2, 4, 7)] - [InlineData(null, 2, 4, 7)] - [InlineData("abc", 0, 4, 9)] - [InlineData("abc", 2, 8, 8)] - [InlineData("abc", 2, 4, 10)] - public void MultipleAttributeModelInvalid(string val1, int val2, int val3, int val4) - { - var validModel = new MultipleAttributeModel - { - Val1 = val1, - Val2 = val2, - Val3 = val3, - Val4 = val4 - }; - - var modelValidator = new MultipleAttributeModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void CustomTypeCustomValidationAttributeModelValid() - { - var validModel = new CustomTypeCustomValidationAttributeModel - { - Val = new CustomType { Val1 = "Pass", Val2 = "Pass" } - }; - - var modelValidator = new CustomTypeCustomValidationAttributeModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void CustomTypeCustomValidationAttributeModelInvalid() - { - var validModel = new CustomTypeCustomValidationAttributeModel - { - Val = new CustomType { Val1 = "Pass", Val2 = "Not Pass" } - }; - - var modelValidator = new CustomTypeCustomValidationAttributeModelValidator(); - Assert.Throws(() => modelValidator.Validate(nameof(validModel), validModel)); - } - - [Fact] - public void DerivedModelIsValid() - { - var validModel = new DerivedModel - { - Val = 1, - DerivedVal = "Valid", - VirtualValWithAttr = 1, - VirtualValWithoutAttr = null - }; - - ((RequiredAttributeModel)validModel).Val = "Valid hidden member from base class"; - - var validator = new DerivedModelValidator(); - var result = validator.Validate(nameof(validModel), validModel); - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Theory] - [InlineData(0, "", 1, null, "Valid hidden member from base class")] - [InlineData(null, "Valid", 1, null, "Valid hidden member from base class")] - [InlineData(1, "Valid", null, null, "Valid hidden member from base class")] - public void DerivedModelIsInvalid(int? val, string? derivedVal, int? virtValAttr, int? virtVal, string? hiddenValBaseClass) - { - var invalidModel = new DerivedModel - { - Val = val, - DerivedVal = derivedVal, - VirtualValWithAttr = virtValAttr, - VirtualValWithoutAttr = virtVal - }; - - ((RequiredAttributeModel)invalidModel).Val = hiddenValBaseClass; - - var validator = new DerivedModelValidator(); - Utils.VerifyValidateOptionsResult(validator.Validate(nameof(invalidModel), invalidModel), 1); - } - - [Fact] - public void LeafModelIsValid() - { - var validModel = new LeafModel - { - Val = 1, - DerivedVal = "Valid", - VirtualValWithAttr = null, - VirtualValWithoutAttr = 1 - }; - - ((RequiredAttributeModel)validModel).Val = "Valid hidden member from base class"; - - var validator = new LeafModelValidator(); - var result = validator.Validate(nameof(validModel), validModel); - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void ComplexModelValid() - { - var validModel = new ComplexModel - { - ComplexVal = new RequiredAttributeModel { Val = "Valid" } - }; - - var modelValidator = new ComplexModelValidator(); - var result = modelValidator.Validate(nameof(validModel), validModel); - Assert.Equal(ValidateOptionsResult.Success, result); - - validModel = new ComplexModel - { - ValWithoutOptionsValidator = new TypeWithoutOptionsValidator - { - Val1 = "Valid", - Val2 = new DateTime(day: 3, month: 1, year: 2004) - } - }; - - // Setting invariant culture to avoid DateTime parsing discrepancies: - CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; - result = modelValidator.Validate(nameof(validModel), validModel); - Assert.Equal(ValidateOptionsResult.Success, result); - - validModel = new ComplexModel - { - ValWithoutOptionsValidator = new TypeWithoutOptionsValidator - { - Val1 = "A", - Val2 = new DateTime(day: 2, month: 2, year: 2004), - YetAnotherComplexVal = new RangeAttributeModelDouble { Val = 0.7 } - } - }; - - result = modelValidator.Validate(nameof(validModel), validModel); - Assert.Equal(ValidateOptionsResult.Success, result); - } - - [Fact] - public void ComplexModelInvalid() - { - var invalidModel = new ComplexModel - { - ComplexVal = new RequiredAttributeModel { Val = null } - }; - - var modelValidator = new ComplexModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(invalidModel), invalidModel), 1); - - invalidModel = new ComplexModel - { - ValWithoutOptionsValidator = new TypeWithoutOptionsValidator { Val1 = "Valid", Val2 = new DateTime(2003, 3, 3) } - }; - - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(invalidModel), invalidModel), 1); - - invalidModel = new ComplexModel - { - ValWithoutOptionsValidator = new TypeWithoutOptionsValidator { Val1 = string.Empty, Val2 = new DateTime(2004, 3, 3) } - }; - - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(invalidModel), invalidModel), 1); - - invalidModel = new ComplexModel - { - ValWithoutOptionsValidator = new TypeWithoutOptionsValidator - { - Val1 = "A", - Val2 = new DateTime(2004, 2, 2), - YetAnotherComplexVal = new RangeAttributeModelDouble { Val = 0.4999 } - } - }; - - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(invalidModel), invalidModel), 1); - } - - [Fact] - public void AttributePropertyModelTestOnErrorMessage() - { - var validModel = new AttributePropertyModel - { - Val1 = 5, - Val2 = 1 - }; - - var modelValidator = new AttributePropertyModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } - - [Fact] - public void AttributePropertyModelTestOnErrorMessageResource() - { - var validModel = new AttributePropertyModel - { - Val1 = 1, - Val2 = 5 - }; - - var modelValidator = new AttributePropertyModelValidator(); - Utils.VerifyValidateOptionsResult(modelValidator.Validate(nameof(validModel), validModel), 1); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RandomMembersTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RandomMembersTests.cs deleted file mode 100644 index 1c87892b279..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RandomMembersTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using RandomMembers; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class RandomMembersTests -{ - [Fact] - public void Invalid() - { - var firstModel = new FirstModel - { - P1 = "1234", - }; - - var validator = new FirstValidator(); - var vr = validator.Validate("RandomMembers", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 1, "P1"); - } - - [Fact] - public void Valid() - { - var firstModel = new FirstModel - { - P1 = "12345", - }; - - var validator = new FirstValidator(); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("RandomMembers", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RecordTypesTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RecordTypesTests.cs deleted file mode 100644 index bd0d872c8b6..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RecordTypesTests.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if ROSLYN_4_0_OR_GREATER - -using Microsoft.Extensions.Options; -using RecordTypes; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class RecordTypesTests -{ - [Fact] - public void Invalid() - { - var thirdModel = new ThirdModel - { - P6 = "1234", - }; - - var secondModel = new SecondModel - { - P5 = "1234", - }; - - var firstModel = new FirstModel - { - P1 = "1234", - P2 = secondModel, - P3 = secondModel, - P4 = thirdModel, - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("RecordTypes", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 4, "P1", "P2.P5", "P3.P5", "P4.P6"); - } - - [Fact] - public void Valid() - { - var thirdModel = new ThirdModel - { - P6 = "12345", - }; - - var secondModel = new SecondModel - { - P5 = "12345", - }; - - var firstModel = new FirstModel - { - P1 = "12345", - P2 = secondModel, - P3 = secondModel, - P4 = thirdModel, - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("RecordTypes", firstModel)); - } -} - -#endif diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RepeatedTypesTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RepeatedTypesTests.cs deleted file mode 100644 index b45fcbf9ced..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/RepeatedTypesTests.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using RepeatedTypes; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class RepeatedTypesTests -{ - [Fact] - public void Invalid() - { - var thirdModel = new ThirdModel - { - P5 = "1234", - }; - - var secondModel = new SecondModel - { - P4 = thirdModel, - }; - - var firstModel = new FirstModel - { - P1 = secondModel, - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = new FirstValidator(); - var vr = validator.Validate("RepeatedTypes", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 3, "P1.P4.P5", "P2.P4.P5", "P3.P5"); - } - - [Fact] - public void Valid() - { - var thirdModel = new ThirdModel - { - P5 = "12345", - }; - - var secondModel = new SecondModel - { - P4 = thirdModel, - }; - - var firstModel = new FirstModel - { - P1 = secondModel, - P2 = secondModel, - P3 = thirdModel, - }; - - var validator = new FirstValidator(); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("RepeatedTypes", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/SelfValidationTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/SelfValidationTests.cs deleted file mode 100644 index 0a511333f03..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/SelfValidationTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using SelfValidation; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class SelfValidationTests -{ - [Fact] - public void Invalid() - { - var firstModel = new FirstModel - { - P1 = "1234", - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("SelfValidation", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 1, "P1"); - } - - [Fact] - public void Valid() - { - var firstModel = new FirstModel - { - P1 = "12345", - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("SelfValidation", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.Designer.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.Designer.cs deleted file mode 100644 index 4fa3e97cbd2..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Microsoft.Gen.OptionsValidation.Test { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class TestResource { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal TestResource() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Microsoft.Gen.OptionsValidation.Test.TestResource", typeof(TestResource).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to ErrorMessageResourceName. - /// - internal static string ErrorMessageResourceName { - get { - return ResourceManager.GetString("ErrorMessageResourceName", resourceCulture); - } - } - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.resx b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.resx deleted file mode 100644 index 70f767945b3..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/TestResource.resx +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ErrorMessageResourceName - - \ No newline at end of file diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/Utils.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/Utils.cs deleted file mode 100644 index 7412374f18a..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/Utils.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if NETCOREAPP3_1_OR_GREATER -using System.Linq; -#endif -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -internal static class Utils -{ - public static void VerifyValidateOptionsResult(ValidateOptionsResult vr, int expectedErrorCount, params string[] expectedErrorSubstrings) - { - Assert.NotNull(vr); - -#if NETCOREAPP3_1_OR_GREATER - var failures = vr.Failures!.ToArray(); -#else - var failures = vr.FailureMessage!.Split(';'); -#endif - - Assert.Equal(expectedErrorCount, failures.Length); - - for (int i = 0; i < expectedErrorSubstrings.Length; i++) - { - Assert.Contains(expectedErrorSubstrings[i], failures[i]); - } - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/ValueTypesTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/ValueTypesTests.cs deleted file mode 100644 index 543e8eb882b..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Common/ValueTypesTests.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Microsoft.Extensions.Options; -using ValueTypes; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class ValueTypesTests -{ - [Fact] - public void Invalid() - { - var secondModel = new SecondModel - { - P4 = "1234", - }; - - var firstModel = new FirstModel - { - P1 = "1234", - P3 = secondModel, - P2 = secondModel, - P4 = default, - }; - - var validator = default(FirstValidator); - var vr = validator.Validate("ValueTypes", firstModel); - - Utils.VerifyValidateOptionsResult(vr, 3, "P1", "P2.P4", "P3.P4"); - } - - [Fact] - public void Valid() - { - var secondModel = new SecondModel - { - P4 = "12345", - }; - - var firstModel = new FirstModel - { - P1 = "12345", - P3 = secondModel, - P2 = secondModel, - P4 = default, - }; - - var validator = default(FirstValidator); - Assert.Equal(ValidateOptionsResult.Success, validator.Validate("ValueTypes", firstModel)); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Directory.Build.props b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Directory.Build.props deleted file mode 100644 index ee32cd31896..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Directory.Build.props +++ /dev/null @@ -1,33 +0,0 @@ - - - - - Microsoft.Gen.OptionsValidation.Test - Tests for code generated by Gen.OptionsValidation. - - - - $(TestNetCoreTargetFrameworks) - $(TestNetCoreTargetFrameworks)$(ConditionalNet462) - true - true - true - true - $(NoWarn);CA1824 - - - - - - - - - - - - - - - - - diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Generated.Tests.csproj b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Generated.Tests.csproj deleted file mode 100644 index 68a4e354e8c..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Generated.Tests.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - 3.8 - - - - - True - True - TestResource.resx - - - diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Generated.Tests.csproj b/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Generated.Tests.csproj deleted file mode 100644 index 1dbe0b6f25c..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Generated/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Generated.Tests.csproj +++ /dev/null @@ -1,14 +0,0 @@ - - - 4.0 - $(DefineConstants);ROSLYN_4_0_OR_GREATER - - - - - True - True - TestResource.resx - - - diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/CustomAttr.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/CustomAttr.cs deleted file mode 100644 index 4259af039bc..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/CustomAttr.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace CustomAttr -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 -#pragma warning disable CA1019 -#pragma warning disable IDE0052 - - [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] - public sealed class CustomAttribute : ValidationAttribute - { - private readonly char _ch; - private readonly bool _caseSensitive; - private readonly string? _extra; - - public CustomAttribute(char ch, bool caseSensitive, string? extra) - { - _ch = ch; - _caseSensitive = caseSensitive; - _extra = extra; - } - - protected override ValidationResult IsValid(object? value, ValidationContext? validationContext) - { - if (value == null) - { - return ValidationResult.Success!; - } - - if (_caseSensitive) - { - if ((char)value != _ch) - { - return new ValidationResult($"{validationContext?.MemberName} didn't match"); - } - } - else - { - if (char.ToUpperInvariant((char)value) != char.ToUpperInvariant(_ch)) - { - return new ValidationResult($"{validationContext?.MemberName} didn't match"); - } - } - - return ValidationResult.Success!; - } - } - - public class FirstModel - { - [Custom('A', true, null)] - public char P1 { get; set; } - - [Custom('A', false, "X")] - public char P2 { get; set; } - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Enumeration.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Enumeration.cs deleted file mode 100644 index bf5d1f7c634..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Enumeration.cs +++ /dev/null @@ -1,94 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace Enumeration -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 - - public class FirstModel - { - [ValidateEnumeratedItems] - public IList? P1; - - [ValidateEnumeratedItems(typeof(SecondValidator))] - public IList? P2; - - [ValidateEnumeratedItems] - public IList? P3; - - [ValidateEnumeratedItems] - public IList? P4; - - [ValidateEnumeratedItems] - public IList? P5; - - [ValidateEnumeratedItems] - [SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1125:Use shorthand for nullable types", Justification = "Testing System>Nullable")] - public IList>? P51; - - [ValidateEnumeratedItems] - public SynteticEnumerable? P6; - - [ValidateEnumeratedItems] - public SynteticEnumerable P7; - - [ValidateEnumeratedItems] - [SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1125:Use shorthand for nullable types", Justification = "Testing System>Nullable")] - public Nullable P8; - } - - public class SecondModel - { - [Required] - [MinLength(5)] - public string P6 = string.Empty; - } - - public struct ThirdModel - { - [Range(0, 10)] - public int Value; - } - - public struct SynteticEnumerable : IEnumerable - { - IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - - public IEnumerator GetEnumerator() => new InternalEnumerator(); - - private class InternalEnumerator : IEnumerator - { - public SecondModel Current => throw new NotSupportedException(); - - object IEnumerator.Current => Current; - - public void Dispose() - { - // Nothing to dispose... - } - - public bool MoveNext() => false; - - public void Reset() => throw new NotSupportedException(); - } - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial struct SecondValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Fields.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Fields.cs deleted file mode 100644 index ddf54f49f4e..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Fields.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace Fields -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 -#pragma warning disable S1186 -#pragma warning disable CA1822 - - public class FirstModel - { - [Required] - [MinLength(5)] - public string P1 = string.Empty; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(SecondValidator))] - public SecondModel? P2; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModel P3; - } - - public class SecondModel - { - [Required] - [MinLength(5)] - public string P4 = string.Empty; - } - - public struct ThirdModel - { - [Required] - [MinLength(5)] - public string P5 = string.Empty; - - public int P6 = default; - - public ThirdModel(object _) - { - } - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - public void Validate() - { - } - - public void Validate(int _) - { - } - - public void Validate(string? _) - { - } - - public void Validate(string? _0, object _1) - { - } - } - - [OptionsValidator] - public partial struct SecondValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FileScopedNamespace.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FileScopedNamespace.cs deleted file mode 100644 index 1341181d24d..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FileScopedNamespace.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace FileScopedNamespace; - -#pragma warning disable SA1649 // File name should match first type name - -public class FirstModel -{ - [Required] - [MinLength(5)] - public string P1 = string.Empty; -} - -[OptionsValidator] -public partial struct FirstValidator : IValidateOptions -{ -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FunnyStrings.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FunnyStrings.cs deleted file mode 100644 index 401109dd621..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/FunnyStrings.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace FunnyStrings -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 - - public class FirstModel - { - [RegularExpression("\"\r\n\\\\")] - public string P1 { get; set; } = string.Empty; - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Generics.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Generics.cs deleted file mode 100644 index bde80402a18..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Generics.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace Generics -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 - - public class FirstModel - { - [Required] - [MinLength(5)] - public string P1 { get; set; } = string.Empty; - - public T? P2 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public SecondModel? P3 { get; set; } - } - - public class SecondModel - { - [Required] - [MinLength(5)] - public string P4 { get; set; } = string.Empty; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions> - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Models.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Models.cs deleted file mode 100644 index 2234bd650da..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Models.cs +++ /dev/null @@ -1,252 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; -using Microsoft.Gen.OptionsValidation.Test; - -#pragma warning disable SA1649 -#pragma warning disable SA1402 - -namespace TestClasses.OptionsValidation -{ - // ValidationAttribute without parameter - public class RequiredAttributeModel - { - [Required] - public string? Val { get; set; } - } - - // ValidationAttribute with string parameter - public class RegularExpressionAttributeModel - { - [RegularExpression("\\s")] - public string Val { get; set; } = string.Empty; - } - - // DataTypeAttribute - public class EmailAttributeModel - { - [EmailAddress] - public string Val { get; set; } = string.Empty; - } - - // ValidationAttribute with System.Type parameter - public class CustomValidationAttributeModel - { - [CustomValidation(typeof(CustomValidationTest), "TestMethod")] - public string Val { get; set; } = string.Empty; - } - -#pragma warning disable SA1204 // Static elements should appear before instance elements - public static class CustomValidationTest -#pragma warning restore SA1204 // Static elements should appear before instance elements - { - public static ValidationResult? TestMethod(string val, ValidationContext _) - { - if (val.Equals("Pass", StringComparison.Ordinal)) - { - return ValidationResult.Success; - } - - throw new ValidationException(); - } - } - - // ValidationAttribute with DataType parameter - public class DataTypeAttributeModel - { - [DataType(DataType.Text)] - public string Val { get; set; } = string.Empty; - } - - // ValidationAttribute with type, double, int parameters - public class RangeAttributeModelInt - { - [Range(1, 3)] - public int Val { get; set; } - } - - public class RangeAttributeModelDouble - { - [Range(0.5, 0.9)] - public double Val { get; set; } - } - - public class RangeAttributeModelDate - { -#if NETCOREAPP3_1_OR_GREATER - [Range(typeof(DateTime), "1/2/2004", "3/4/2004", ParseLimitsInInvariantCulture = true)] -#else - [Range(typeof(DateTime), "1/2/2004", "3/4/2004")] -#endif - public DateTime Val { get; set; } - } - - public class MultipleAttributeModel - { - [Required] - [DataType(DataType.Password)] - public string Val1 { get; set; } = string.Empty; - - [Range(1, 3)] - public int Val2 { get; set; } - - [Range(3, 5)] - public int Val3 { get; set; } - - [Range(5, 9)] - public int Val4 { get; set; } - } - - public class CustomTypeCustomValidationAttributeModel - { - [CustomValidation(typeof(CustomTypeCustomValidationTest), "TestMethod")] - public CustomType? Val { get; set; } - } - - public class CustomType - { - public string Val1 { get; set; } = string.Empty; - public string Val2 { get; set; } = string.Empty; - } - -#pragma warning disable SA1204 // Static elements should appear before instance elements - public static class CustomTypeCustomValidationTest -#pragma warning restore SA1204 // Static elements should appear before instance elements - { - public static ValidationResult? TestMethod(CustomType val, ValidationContext _) - { - if (val.Val1.Equals("Pass", StringComparison.Ordinal) && val.Val2.Equals("Pass", StringComparison.Ordinal)) - { - return ValidationResult.Success; - } - - throw new ValidationException(); - } - } - - public class AttributePropertyModel - { - [Range(1, 3, ErrorMessage = "ErrorMessage")] - public int Val1 { get; set; } - - [Range(1, 3, ErrorMessageResourceType = typeof(TestResource), ErrorMessageResourceName = "ErrorMessageResourceName")] - public int Val2 { get; set; } - } - - public class TypeWithoutOptionsValidator - { - [Required] - public string? Val1 { get; set; } - - [Range(typeof(DateTime), "1/2/2004", "3/4/2004")] - public DateTime Val2 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public RangeAttributeModelDouble? YetAnotherComplexVal { get; set; } - } - - public class DerivedModel : RequiredAttributeModel - { - [Required] - public string? DerivedVal { get; set; } - - [Required] - internal virtual int? VirtualValWithAttr { get; set; } - - public virtual int? VirtualValWithoutAttr { get; set; } - - [Required] - public new int? Val { get; set; } - } - - public class LeafModel : DerivedModel - { - internal override int? VirtualValWithAttr { get; set; } - - [Required] - public override int? VirtualValWithoutAttr { get; set; } - } - - public class ComplexModel - { - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public RequiredAttributeModel? ComplexVal { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public TypeWithoutOptionsValidator? ValWithoutOptionsValidator { get; set; } - } - - [OptionsValidator] - public partial class RequiredAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class RegularExpressionAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class EmailAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class CustomValidationAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class DataTypeAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class RangeAttributeModelIntValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class RangeAttributeModelDoubleValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class RangeAttributeModelDateValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class MultipleAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class CustomTypeCustomValidationAttributeModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class AttributePropertyModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class DerivedModelValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class LeafModelValidator : IValidateOptions - { - } - - [OptionsValidator] - internal sealed partial class ComplexModelValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/MultiModelValidator.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/MultiModelValidator.cs deleted file mode 100644 index fd725d8403c..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/MultiModelValidator.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace MultiModelValidator -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 - - public class FirstModel - { - [Required] - [MinLength(5)] - public string P1 = string.Empty; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(MultiValidator))] - public SecondModel? P2; - } - - public class SecondModel - { - [Required] - [MinLength(5)] - public string P3 = string.Empty; - } - - [OptionsValidator] - public partial struct MultiValidator : IValidateOptions, IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Nested.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Nested.cs deleted file mode 100644 index 531e0eed0d1..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/Nested.cs +++ /dev/null @@ -1,106 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if ROSLYN_4_0_OR_GREATER - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace Nested -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 - - public static class Container1 - { - public class FirstModel - { - [Required] - [MinLength(5)] - public string P1 { get; set; } = string.Empty; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(Container2.Container3.SecondValidator))] - public SecondModel? P2 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModel P3 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(Container4.Container5.ThirdValidator))] - public SecondModel? P4 { get; set; } - } - - public class SecondModel - { - [Required] - [MinLength(5)] - public string P5 { get; set; } = string.Empty; - } - - public struct ThirdModel - { - public ThirdModel(int _) - { - } - - [Required] - [MinLength(5)] - public string P6 { get; set; } = string.Empty; - } - } - - public static partial class Container2 - { - public partial class Container3 - { - public Container3(int _) - { - // nothing to do - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial struct SecondValidator : IValidateOptions - { - } - } - } - - public partial record class Container4 - { - public partial record class Container5 - { - public Container5(int _) - { - // nothing to do - } - - [OptionsValidator] - public partial struct ThirdValidator : IValidateOptions - { - } - } - } - - public partial struct Container6 - { - [OptionsValidator] - public partial struct FourthValidator : IValidateOptions - { - } - } - - public partial record struct Container7 - { - [OptionsValidator] - public partial record struct FifthValidator : IValidateOptions - { - } - } -} - -#endif diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/NoNamespace.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/NoNamespace.cs deleted file mode 100644 index db6461ddf18..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/NoNamespace.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -#pragma warning disable SA1649 -#pragma warning disable SA1402 - -public class FirstModelNoNamespace -{ - [Required] - [MinLength(5)] - public string P1 { get; set; } = string.Empty; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(SecondValidatorNoNamespace))] - public SecondModelNoNamespace? P2 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModelNoNamespace? P3 { get; set; } -} - -public class SecondModelNoNamespace -{ - [Required] - [MinLength(5)] - public string P4 { get; set; } = string.Empty; -} - -public class ThirdModelNoNamespace -{ - [Required] - [MinLength(5)] - public string P5 { get; set; } = string.Empty; -} - -[OptionsValidator] -public partial class FirstValidatorNoNamespace : IValidateOptions -{ -} - -[OptionsValidator] -public partial class SecondValidatorNoNamespace : IValidateOptions -{ -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RandomMembers.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RandomMembers.cs deleted file mode 100644 index 08a3327a874..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RandomMembers.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace RandomMembers -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 -#pragma warning disable CA1822 - - public class FirstModel - { - [Required] - [MinLength(5)] - public string? P1 { get; set; } - - public void Foo() - { - throw new NotSupportedException(); - } - - public class Nested - { - } - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RecordTypes.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RecordTypes.cs deleted file mode 100644 index b0b393f737d..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RecordTypes.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -#if ROSLYN_4_0_OR_GREATER - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace RecordTypes -{ -#pragma warning disable SA1649 - - public record class FirstModel - { - [Required] - [MinLength(5)] - public string P1 { get; set; } = string.Empty; - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(SecondValidator))] - public SecondModel? P2 { get; set; } - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers(typeof(ThirdValidator))] - public SecondModel P3 { get; set; } = new SecondModel(); - - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModel P4 { get; set; } - } - - public record class SecondModel - { - [Required] - [MinLength(5)] - public string P5 { get; set; } = string.Empty; - } - - public record struct ThirdModel - { - [Required] - [MinLength(5)] - public string P6 { get; set; } = string.Empty; - - public ThirdModel(int _) - { - } - - public ThirdModel(object _) - { - } - } - - [OptionsValidator] - public partial record struct FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial record struct SecondValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial record class ThirdValidator : IValidateOptions - { - } -} - -#endif diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RepeatedTypes.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RepeatedTypes.cs deleted file mode 100644 index f5fa327bae5..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/RepeatedTypes.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace RepeatedTypes -{ -#pragma warning disable SA1649 -#pragma warning disable SA1402 -#pragma warning disable CA1019 - - public class FirstModel - { - [Required] - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public SecondModel? P1 { get; set; } - - [Required] - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public SecondModel? P2 { get; set; } - - [Required] - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModel? P3 { get; set; } - } - - public class SecondModel - { - [Required] - [Microsoft.Extensions.Options.Validation.ValidateObjectMembers] - public ThirdModel? P4 { get; set; } - } - - public class ThirdModel - { - [Required] - [MinLength(5)] - public string? P5; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/SelfValidation.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/SelfValidation.cs deleted file mode 100644 index 673af4a0896..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/SelfValidation.cs +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace SelfValidation -{ -#pragma warning disable SA1649 - - public class FirstModel : IValidatableObject - { - [Required] - public string P1 = string.Empty; - - public IEnumerable Validate(ValidationContext validationContext) - { - if (P1.Length < 5) - { - return new[] { new ValidationResult("P1 is not long enough") }; - } - - return Array.Empty(); - } - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/ValueTypes.cs b/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/ValueTypes.cs deleted file mode 100644 index aa6a8c3f972..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/TestClasses/ValueTypes.cs +++ /dev/null @@ -1,46 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics.CodeAnalysis; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; - -namespace ValueTypes -{ -#pragma warning disable SA1649 - - public class FirstModel - { - [Required] - [MinLength(5)] - public string P1 { get; set; } = string.Empty; - - [ValidateObjectMembers] - public SecondModel? P2 { get; set; } - - [ValidateObjectMembers] - public SecondModel P3 { get; set; } - - [ValidateObjectMembers] - [SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1125:Use shorthand for nullable types", Justification = "Testing System>Nullable")] - public Nullable P4 { get; set; } - } - - public struct SecondModel - { - [Required] - [MinLength(5)] - public string P4 { get; set; } = string.Empty; - - public SecondModel(object _) - { - } - } - - [OptionsValidator] - public partial struct FirstValidator : IValidateOptions - { - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/EmitterTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/EmitterTests.cs deleted file mode 100644 index 56c0abdbfcb..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/EmitterTests.cs +++ /dev/null @@ -1,58 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; -using Microsoft.Gen.Shared; -using Microsoft.Shared.Data.Validation; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class EmitterTests -{ - [Fact] - public async Task TestEmitter() - { - var sources = new List(); - foreach (var file in Directory.GetFiles("TestClasses")) - { -#if !ROSLYN_4_0_OR_GREATER - if (file.EndsWith("Nested.cs") || file.EndsWith("RecordTypes.cs")) - { - continue; - } -#endif - -#if NETCOREAPP3_1_OR_GREATER - sources.Add("#define NETCOREAPP3_1_OR_GREATER\n" + File.ReadAllText(file)); -#else - sources.Add(File.ReadAllText(file)); -#endif - } - - var (d, r) = await RoslynTestUtils.RunGenerator( - new Generator(), - new[] - { - Assembly.GetAssembly(typeof(RequiredAttribute))!, - Assembly.GetAssembly(typeof(TimeSpanAttribute))!, - Assembly.GetAssembly(typeof(OptionsValidatorAttribute))!, - Assembly.GetAssembly(typeof(IValidateOptions))!, - }, - sources) - .ConfigureAwait(false); - - Assert.Empty(d); - _ = Assert.Single(r); - - var golden = File.ReadAllText($"GoldenFiles/Microsoft.Gen.OptionsValidation/Microsoft.Gen.OptionsValidation.Generator/Validators.g.cs"); - var result = r[0].SourceText.ToString(); - Assert.Equal(golden, result); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.Enumeration.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.Enumeration.cs deleted file mode 100644 index 4e99becec9a..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.Enumeration.cs +++ /dev/null @@ -1,212 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Threading.Tasks; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public partial class ParserTests -{ - [Fact] - public async Task CircularTypeReferencesInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateEnumeratedItems] - public FirstModel[]? P1 { get; set; } - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.CircularTypeReferences.Id, d[0].Id); - } - - [Fact] - public async Task NotValidatorInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [ValidateEnumeratedItems(typeof(SecondValidator)] - public SecondModel[]? P1; - } - - public class SecondModel - { - [Required] - public string? P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - public partial class SecondValidator - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.DoesntImplementIValidateOptions.Id, d[0].Id); - } - - [Fact] - public async Task NullValidatorInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [ValidateEnumeratedItems(null!)] - public SecondModel[]? P1; - } - - public class SecondModel - { - [Required] - public string? P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.NullValidatorType.Id, d[0].Id); - } - - [Fact] - public async Task NoSimpleValidatorConstructorInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string? P1; - - [ValidateEnumeratedItems(typeof(SecondValidator)] - public SecondModel[]? P2; - } - - public class SecondModel - { - [Required] - public string? P3; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - public SecondValidator(int _) - { - } - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.ValidatorsNeedSimpleConstructor.Id, d[0].Id); - } - - [Fact] - public async Task CantValidateOpenGenericMembersInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateEnumeratedItems] - public T[]? P1; - - [ValidateEnumeratedItems] - [Required] - public T[]? P2; - - [ValidateEnumeratedItems] - [Required] - public System.Collections.Generic.IList P3 = null!; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions> - { - } - "); - - Assert.Equal(3, d.Count); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[0].Id); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[1].Id); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[2].Id); - } - - [Fact] - public async Task ClosedGenericsInEnumeration() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [ValidateEnumeratedItems] - [Required] - public T[]? P1; - - [ValidateEnumeratedItems] - [Required] - public int[]? P2; - - [ValidateEnumeratedItems] - [Required] - public System.Collections.Generic.IList? P3; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions> - { - } - "); - - Assert.Equal(3, d.Count); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[0].Id); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[1].Id); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[2].Id); - } - - [Fact] - public async Task NotEnumerable() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateEnumeratedItems] - public int P1; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - "); - - Assert.Equal(1, d.Count); - Assert.Equal(DiagDescriptors.NotEnumerableType.Id, d[0].Id); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.cs deleted file mode 100644 index 8dbdfa237e3..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/ParserTests.cs +++ /dev/null @@ -1,930 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System.Collections.Generic; -using System.Collections.Immutable; -using System.ComponentModel.DataAnnotations; -using System.Globalization; -using System.Linq; -using System.Reflection; -using System.Threading.Tasks; -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.Options.Validation; -using Microsoft.Gen.Shared; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public partial class ParserTests -{ - [Fact] - public async Task PotentiallyMissingAttributes() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public SecondModel? P1 { get; set; } - - [Required] - public System.Collections.Generic.IList? P2 { get; set; } - } - - public class SecondModel - { - [Required] - public string? P3; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - "); - - Assert.Equal(2, d.Count); - Assert.Equal(DiagDescriptors.PotentiallyMissingTransitiveValidation.Id, d[0].Id); - Assert.Equal(DiagDescriptors.PotentiallyMissingEnumerableValidation.Id, d[1].Id); - } - - [Fact] - public async Task CircularTypeReferences() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateObjectMembers] - public FirstModel? P1 { get; set; } - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.CircularTypeReferences.Id, d[0].Id); - } - - [Fact] - public async Task InvalidValidatorInterface() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string? P1; - } - - public class SecondModel - { - [Required] - public string? P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.DoesntImplementIValidateOptions.Id, d[0].Id); - } - - [Fact] - public async Task NotValidator() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [ValidateObjectMembers(typeof(SecondValidator)] - public SecondModel? P1; - } - - public class SecondModel - { - [Required] - public string? P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - public partial class SecondValidator - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.DoesntImplementIValidateOptions.Id, d[0].Id); - } - - [Fact] - public async Task ValidatorAlreadyImplementValidateFunction() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string? P1; - - [ValidateObjectMembers(typeof(SecondValidator)] - public SecondModel? P2; - } - - public class SecondModel - { - [Required] - public string? P3; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - public ValidateOptionsResult Validate(string name, SecondModel options) - { - throw new System.NotSupportedException(); - } - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.AlreadyImplementsValidateMethod.Id, d[0].Id); - } - - [Fact] - public async Task NullValidator() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [ValidateObjectMembers(null!)] - public SecondModel? P1; - } - - public class SecondModel - { - [Required] - public string? P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.NullValidatorType.Id, d[0].Id); - } - - [Fact] - public async Task NoSimpleValidatorConstructor() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string? P1; - - [ValidateObjectMembers(typeof(SecondValidator)] - public SecondModel? P2; - } - - public class SecondModel - { - [Required] - public string? P3; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - public SecondValidator(int _) - { - } - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.ValidatorsNeedSimpleConstructor.Id, d[0].Id); - } - - [Fact] - public async Task NoStaticValidator() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string P1; - } - - [OptionsValidator] - public static partial class FirstValidator : IValidateOptions - { - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.CantBeStaticClass.Id, d[0].Id); - } - - [Fact] - public async Task BogusModelType() - { - var (d, _) = await RunGenerator(@" - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - "); - - // the generator doesn't produce any errors here, since the C# compiler will take care of it - Assert.Empty(d); - } - - [Fact] - public async Task CantValidateOpenGenericMembers() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateObjectMembers] - public T? P1; - - [ValidateObjectMembers] - [Required] - public T[]? P2; - - [ValidateObjectMembers] - [Required] - public System.Collections.Generics.IList P3 = null!; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions> - { - } - "); - - Assert.Equal(3, d.Count); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[0].Id); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[1].Id); - Assert.Equal(DiagDescriptors.CantUseWithGenericTypes.Id, d[2].Id); - } - - [Fact] - public async Task ClosedGenerics() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateObjectMembers] - public T? P1; - - [ValidateObjectMembers] - [Required] - public T[]? P2; - - [ValidateObjectMembers] - [Required] - public int[]? P3; - - [ValidateObjectMembers] - [Required] - public System.Collections.Generics.IList? P4; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions> - { - } - "); - - Assert.Equal(4, d.Count); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[0].Id); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[1].Id); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[2].Id); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[3].Id); - } - - [Fact] - public async Task NoEligibleMembers() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - [ValidateObjectMembers] - public SecondModel? P1; - } - - public class SecondModel - { - public string P2; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - } - - [OptionsValidator] - public partial class SecondValidator : IValidateOptions - { - } - "); - - Assert.Equal(2, d.Count); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[0].Id); - Assert.Equal(DiagDescriptors.NoEligibleMembersFromValidator.Id, d[1].Id); - } - - [Fact] - public async Task AlreadyImplemented() - { - var (d, _) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string One { get; set; } = string.Empty; - } - - [OptionsValidator] - public partial class FirstValidator : IValidateOptions - { - public void Validate(string name, FirstModel fm) - { - } - } - "); - - _ = Assert.Single(d); - Assert.Equal(DiagDescriptors.AlreadyImplementsValidateMethod.Id, d[0].Id); - } - - [Fact] - public async Task ShouldNotProduceInfoWhenTheClassHasABaseClass() - { - var (d, _) = await RunGenerator(@" - public class Parent - { - [Required] - public string parentString { get; set; } - } - - public class Child : Parent - { - [Required] - public string childString { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldNotProduceInfoWhenTransitiveClassHasABaseClass() - { - var (d, _) = await RunGenerator(@" - public class Parent - { - [Required] - public string parentString { get; set; } - } - - public class Child : Parent - { - [Required] - public string childString { get; set; } - } - - public class MyOptions - { - [ValidateObjectMembers] - public Child childVal { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Theory] - [InlineData("bool")] - [InlineData("int")] - [InlineData("double")] - [InlineData("string")] - [InlineData("System.String")] - [InlineData("System.DateTime")] - public async Task ShouldProduceWarn_WhenTransitiveAttrMisused(string memberClass) - { - var (d, _) = await RunGenerator(@$" - public class InnerModel - {{ - [Required] - public string childString {{ get; set; }} - }} - - public class MyOptions - {{ - [Required] - public string simpleVal {{ get; set; }} - - [ValidateObjectMembers] - public {memberClass} complexVal {{ get; set; }} - }} - - [OptionsValidator] - public partial class Validator : IValidateOptions - {{ - }} - "); - - Assert.Single(d); - Assert.Equal(DiagDescriptors.NoEligibleMember.Id, d[0].Id); - } - - [Fact] - public async Task ShouldProduceWarningWhenTheClassHasNoEligibleMembers() - { - var (d, _) = await RunGenerator(@" - public class Child - { - private string AccountName { get; set; } - public object Weight; - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Single(d); - Assert.Equal(DiagDescriptors.NoEligibleMembersFromValidator.Id, d[0].Id); - } - - [Theory] - [InlineData("private")] - [InlineData("protected")] - public async Task ShouldProduceWarningWhenTheClassMembersAreInaccessible(string accessModifier) - { - var (d, _) = await RunGenerator($@" - public class Model - {{ - [Required] - public string? PublicVal {{ get; set; }} - - [Required] - {accessModifier} string? Val {{ get; set; }} - }} - - [OptionsValidator] - public partial class Validator : IValidateOptions - {{ - }} - "); - - Assert.Single(d); - Assert.Equal("R9G106", d[0].Id); - } - - [Fact] - public async Task ShouldNotProduceErrorWhenMultipleValidationAnnotationsExist() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - [MinLength(5)] - [MaxLength(15)] - public string Val9 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldNotProduceErrorWhenDataTypeAttributesAreUsed() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - [CreditCard] - public string Val3 = """"; - - [EmailAddress] - public string Val6 { get; set; } - - [EnumDataType(typeof(string))] - public string Val7 { get; set; } - - [FileExtensions] - public string Val8 { get; set; } - - [Phone] - public string Val10 { get; set; } - - [Url] - public string Val11 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldNotProduceErrorWhenConstVariableIsUsedAsAttributeArgument() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - private const int q = 5; - [Range(q, 10)] - public string Val11 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - // Testing on all existing & eligible annotations extending ValidationAttribute that aren't used above - [Fact] - public async Task ShouldNotProduceAnyMessagesWhenExistingValidationsArePlaced() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - [Required] - public string Val { get; set; } - - [Compare(""val"")] - public string Val2 { get; set; } - - [DataType(DataType.Password)] - public string _val5 = """"; - - [Range(5.1, 10.11)] - public string Val12 { get; set; } - - [Range(typeof(MemberDeclarationSyntax), ""1/2/2004"", ""3/4/2004"")] - public string Val14 { get; set; } - - [RegularExpression("""")] - public string Val15 { get; set; } - - [StringLength(5)] - public string Val16 { get; set; } - - [CustomValidation(typeof(MemberDeclarationSyntax), ""CustomMethod"")] - public string Val17 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldNotProduceErrorWhenPropertiesAreUsedAsAttributeArgument() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - private const int q = 5; - [Range(q, 10, ErrorMessage = ""ErrorMessage"")] - public string Val11 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldSkipWhenOptionsValidatorAttributeDoesNotExist() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - private const int q = 5; - [Range(q, 10, ErrorMessage = ""ErrorMessage"")] - public string Val11 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - ", includeR9References: false); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldSkipAtrributeWhenAttributeSymbolCannotBeFound() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - [RandomTest] - public string Val11 { get; set; } - - [Range(1, 10, ErrorMessage = ""ErrorMessage"")] - public string Val12 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldSkipAtrributeWhenAttributeSymbolIsNotBasedOnValidationAttribute() - { - var (d, _) = await RunGenerator(@" - public class IValidateOptionsTestFile - { - [FilterUIHint(""MultiForeignKey"")] - public string Val11 { get; set; } - - [Range(1, 10, ErrorMessage = ""ErrorMessage"")] - public string Val12 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldAcceptAtrributeWhenAttributeIsInDifferentNamespace() - { - var (d, _) = await RunGenerator(@" - namespace Test { - public class IValidateOptionsTestFile - { - [Test] - public string Val11 { get; set; } - } - - [AttributeUsage(AttributeTargets.Class)] - public sealed class TestAttribute : ValidationAttribute - { - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - } - ", inNamespace: false); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldHandleAtrributePropertiesOtherThanString() - { - var (d, _) = await RunGenerator(@" - namespace Test { - public class IValidateOptionsTestFile - { - [Test(num = 5)] - public string Val11 { get; set; } - - [Required] - public string Val12 { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - } - - namespace System.ComponentModel.DataAnnotations { - [AttributeUsage(AttributeTargets.Class)] - public sealed class TestAttribute : ValidationAttribute - { - public int num { get; set; } - public TestAttribute() { - } - } - } - ", inNamespace: false); - - Assert.Empty(d); - } - - [Fact] - public async Task ShouldStoreFloatValuesCorrectly() - { - var backupCulture = CultureInfo.CurrentCulture; - CultureInfo.CurrentCulture = new CultureInfo("ru-RU", false); - try - { - var (diagMessages, generatedResults) = await RunGenerator(@" - public class Model - { - [Range(-0.1, 1.3)] - public string Val { get; set; } - } - - [OptionsValidator] - public partial class Validator : IValidateOptions - { - } - "); - - Assert.Empty(diagMessages); - Assert.Single(generatedResults); - Assert.DoesNotContain("0,1", generatedResults[0].SourceText.ToString()); - Assert.DoesNotContain("1,3", generatedResults[0].SourceText.ToString()); - } - finally - { - CultureInfo.CurrentCulture = backupCulture; - } - } - - [Fact] - public async Task MultiModelValidatorGeneratesOnlyOnePartialTypeBlock() - { - var (d, sources) = await RunGenerator(@" - public class FirstModel - { - [Required] - public string P1 { get; set; } - } - - public class SecondModel - { - [Required] - public string P2 { get; set; } - } - - public class ThirdModel - { - [Required] - public string P3 { get; set; } - } - - [OptionsValidator] - public partial class MultiValidator : IValidateOptions, IValidateOptions, IValidateOptions - { - } - "); - - var typeDeclarations = sources[0].SyntaxTree - .GetRoot() - .DescendantNodes() - .OfType() - .ToArray(); - - var multiValidatorTypeDeclarations = typeDeclarations - .Where(x => x.Identifier.ValueText == "MultiValidator") - .ToArray(); - - Assert.Single(multiValidatorTypeDeclarations); - - var validateMethodDeclarations = multiValidatorTypeDeclarations[0] - .DescendantNodes() - .OfType() - .Where(x => x.Identifier.ValueText == "Validate") - .ToArray(); - - Assert.Equal(3, validateMethodDeclarations.Length); - } - - private static async Task<(IReadOnlyList diagnostics, ImmutableArray generatedSources)> RunGenerator( - string code, - bool wrap = true, - bool inNamespace = true, - bool includeR9References = true, - bool includeSystemReferences = true, - bool includeOptionsReferences = true, - bool includeTransitiveReferences = true) - { - var text = code; - if (wrap) - { - var nspaceStart = "namespace Test {"; - var nspaceEnd = "}"; - if (!inNamespace) - { - nspaceStart = ""; - nspaceEnd = ""; - } - - text = $@" - {nspaceStart} - using System.ComponentModel.DataAnnotations; - using Microsoft.Extensions.Options.Validation; - using Microsoft.Shared.Data.Validation; - using Microsoft.Extensions.Options; - using Microsoft.CodeAnalysis.CSharp.Syntax; - {code} - {nspaceEnd} - "; - } - - var assemblies = new List { Assembly.GetAssembly(typeof(MemberDeclarationSyntax))! }; - - if (includeR9References) - { - assemblies.Add(Assembly.GetAssembly(typeof(OptionsValidatorAttribute))!); - } - - if (includeSystemReferences) - { - assemblies.Add(Assembly.GetAssembly(typeof(RequiredAttribute))!); - } - - if (includeOptionsReferences) - { - assemblies.Add(Assembly.GetAssembly(typeof(IValidateOptions))!); - } - - if (includeTransitiveReferences) - { - assemblies.Add(Assembly.GetAssembly(typeof(Microsoft.Extensions.Options.Validation.ValidateObjectMembersAttribute))!); - } - - var result = await RoslynTestUtils.RunGenerator(new Generator(), assemblies.ToArray(), new[] { text }) - .ConfigureAwait(false); - - return result; - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/SymbolLoaderTests.cs b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/SymbolLoaderTests.cs deleted file mode 100644 index 287072ea951..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Common/SymbolLoaderTests.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using System; -using System.Collections.Generic; -using System.Collections.Immutable; -using Microsoft.CodeAnalysis; -using Moq; -using Moq.Protected; -using Xunit; - -namespace Microsoft.Gen.OptionsValidation.Test; - -public class SymbolLoaderTests -{ - [Theory] - [InlineData(SymbolLoader.OptionsValidatorAttribute)] - [InlineData(SymbolLoader.ValidationAttribute)] - [InlineData(SymbolLoader.DataTypeAttribute)] - [InlineData(SymbolLoader.IValidatableObjectType)] - [InlineData(SymbolLoader.IValidateOptionsType)] - [InlineData(SymbolLoader.TypeOfType)] - public void Loader_ReturnsFalse_WhenRequiredTypeIsUnavailable(string type) - { - var compilationMock = new Mock( - string.Empty, - Array.Empty().ToImmutableArray(), - new Dictionary(), - false, - null!, - null!); - - compilationMock - .Protected() - .Setup("CommonGetTypeByMetadataName", ItExpr.Is(t => t != type)) - .Returns(Mock.Of()); - - compilationMock - .Protected() - .Setup("CommonGetTypeByMetadataName", ItExpr.Is(t => t == type)) - .Returns((INamedTypeSymbol?)null); - - var callbackMock = new Mock>(); - var result = SymbolLoader.TryLoad(compilationMock.Object, out var holder); - Assert.False(result); - Assert.Null(holder); - callbackMock.VerifyNoOtherCalls(); - } - - [Theory] - [InlineData(SymbolLoader.LegacyValidateTransitivelyAttribute)] - [InlineData(SymbolLoader.ValidateObjectMembersAttribute)] - [InlineData(SymbolLoader.ValidateEnumeratedItemsAttribute)] - public void Loader_ReturnsTrue_WhenOptionalTypeIsUnavailable(string type) - { - var compilationMock = new Mock( - string.Empty, - Array.Empty().ToImmutableArray(), - new Dictionary(), - false, - null!, - null!); - - compilationMock - .Protected() - .Setup("CommonGetTypeByMetadataName", ItExpr.Is(t => t != type)) - .Returns(Mock.Of()); - - compilationMock - .Protected() - .Setup("CommonGetTypeByMetadataName", ItExpr.Is(t => t == type)) - .Returns((INamedTypeSymbol?)null); - - var callbackMock = new Mock>(); - var result = SymbolLoader.TryLoad(compilationMock.Object, out var holder); - Assert.True(result); - Assert.NotNull(holder); - callbackMock.VerifyNoOtherCalls(); - } -} diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Directory.Build.props b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Directory.Build.props deleted file mode 100644 index feb0e78d598..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Directory.Build.props +++ /dev/null @@ -1,31 +0,0 @@ - - - - - Microsoft.Gen.OptionsValidation.Test - Unit tests for Gen.OptionsValidation. - - - - true - true - true - - - - - - - - - - - - - - - - - - - diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Unit.Tests.csproj b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Unit.Tests.csproj deleted file mode 100644 index eac2eac2172..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn3.8/Microsoft.Gen.OptionsValidation.Roslyn3.8.Unit.Tests.csproj +++ /dev/null @@ -1,5 +0,0 @@ - - - 3.8 - - diff --git a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Unit.Tests.csproj b/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Unit.Tests.csproj deleted file mode 100644 index 18ce9dd9ba0..00000000000 --- a/test/Generators/Microsoft.Gen.OptionsValidation/Unit/Roslyn4.0/Microsoft.Gen.OptionsValidation.Roslyn4.0.Unit.Tests.csproj +++ /dev/null @@ -1,6 +0,0 @@ - - - 4.0 - $(DefineConstants);ROSLYN_4_0_OR_GREATER - - diff --git a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/Microsoft.Extensions.Options.Validation.Tests.csproj b/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/Microsoft.Extensions.Options.Validation.Tests.csproj deleted file mode 100644 index 7adea74ea1d..00000000000 --- a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/Microsoft.Extensions.Options.Validation.Tests.csproj +++ /dev/null @@ -1,22 +0,0 @@ - - - Microsoft.Extensions.Options.Validation - Tests for Microsoft.Extensions.Options.Validation - - - - true - - - - - - - - - - - - - - diff --git a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateEnumeratedItemsAttributeTests.cs b/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateEnumeratedItemsAttributeTests.cs deleted file mode 100644 index 26f5cf70e30..00000000000 --- a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateEnumeratedItemsAttributeTests.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Microsoft.Extensions.Options.Validation.Test; - -public class ValidateEnumeratedItemsAttributeTests -{ - [Fact] - public void Basic() - { - var a = new ValidateEnumeratedItemsAttribute(); - Assert.NotNull(a); - Assert.Null(a.Validator); - - a = new ValidateEnumeratedItemsAttribute(typeof(int)); - Assert.Equal(typeof(int), a.Validator); - } -} diff --git a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateObjectMembersAttributeTest.cs b/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateObjectMembersAttributeTest.cs deleted file mode 100644 index 69208ed9b56..00000000000 --- a/test/Libraries/Microsoft.Extensions.Options.Validation.Tests/ValidateObjectMembersAttributeTest.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -using Xunit; - -namespace Microsoft.Extensions.Options.Validation.Test; - -public class ValidateObjectMembersAttributeTest -{ - [Fact] - public void Basic() - { - var a = new ValidateObjectMembersAttribute(); - Assert.NotNull(a); - Assert.Null(a.Validator); - - a = new ValidateObjectMembersAttribute(typeof(int)); - Assert.Equal(typeof(int), a.Validator); - } -} diff --git a/test/ToBeRemoved/Options.ValidateOnStart.Tests/Helpers/OptionsValidationModels.cs b/test/ToBeRemoved/Options.ValidateOnStart.Tests/Helpers/OptionsValidationModels.cs index 3d2e0ebbfd9..cd513ad9ec2 100644 --- a/test/ToBeRemoved/Options.ValidateOnStart.Tests/Helpers/OptionsValidationModels.cs +++ b/test/ToBeRemoved/Options.ValidateOnStart.Tests/Helpers/OptionsValidationModels.cs @@ -61,9 +61,9 @@ public class ComplexModel [ValidateObjectMembers] public ModelWithoutOptionsValidator? ValWithoutOptionsValidator { get; set; } -#pragma warning disable R9G113 +#pragma warning disable SYSLIB1212 // Member potentially missing transitive validation. public Model? ValWithoutRecursiveValidation { get; set; } -#pragma warning restore R9G113 +#pragma warning restore SYSLIB1212 // Member potentially missing transitive validation. } public class InceptionComplexModel diff --git a/test/ToBeRemoved/Options.ValidateOnStart.Tests/Options.ValidateOnStart.Tests.csproj b/test/ToBeRemoved/Options.ValidateOnStart.Tests/Options.ValidateOnStart.Tests.csproj index aadeb05c93f..3de3dc9c92d 100644 --- a/test/ToBeRemoved/Options.ValidateOnStart.Tests/Options.ValidateOnStart.Tests.csproj +++ b/test/ToBeRemoved/Options.ValidateOnStart.Tests/Options.ValidateOnStart.Tests.csproj @@ -3,7 +3,6 @@ Microsoft.Extensions.Options.ValidateOnStart.Tests Microsoft.Extensions.Options.ValidateOnStart.Test Tests for Microsoft.Extensions.Options.ValidateOnStart - true @@ -14,7 +13,6 @@ -