diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Emitter.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Emitter.cs index 9182555af10fa3..d8c5a8925b46b2 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Emitter.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Emitter.cs @@ -38,8 +38,12 @@ public void Emit(SourceProductionContext context) _writer.WriteLine(""" // - #nullable enable - #pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + + #nullable enable annotations + #nullable disable warnings + + // Suppress warnings about [Obsolete] member usage in generated code. + #pragma warning disable CS0612, CS0618 """); EmitInterceptsLocationAttrDecl(); diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs index eda240b098cc6d..ead8e80a167373 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/ConfigurationBindingGenerator.Parser.cs @@ -509,7 +509,6 @@ private TypeSpec CreateEnumerableSpec(TypeParseInfo typeParseInfo) private ObjectSpec CreateObjectSpec(TypeParseInfo typeParseInfo) { INamedTypeSymbol typeSymbol = (INamedTypeSymbol)typeParseInfo.TypeSymbol; - string typeName = typeSymbol.GetTypeName().Name; ObjectInstantiationStrategy initializationStrategy = ObjectInstantiationStrategy.None; DiagnosticDescriptor? initDiagDescriptor = null; @@ -548,11 +547,11 @@ private ObjectSpec CreateObjectSpec(TypeParseInfo typeParseInfo) if (!hasPublicParameterlessCtor && hasMultipleParameterizedCtors) { initDiagDescriptor = DiagnosticDescriptors.MultipleParameterizedConstructors; - initExceptionMessage = string.Format(Emitter.ExceptionMessages.MultipleParameterizedConstructors, typeName); + initExceptionMessage = string.Format(Emitter.ExceptionMessages.MultipleParameterizedConstructors, typeSymbol.GetFullName()); } ctor = typeSymbol.IsValueType - // Roslyn ctor fetching APIs include paramerterless ctors for structs, unlike System.Reflection. + // Roslyn ctor fetching APIs include parameterless ctors for structs, unlike System.Reflection. ? parameterizedCtor ?? parameterlessCtor : parameterlessCtor ?? parameterizedCtor; } @@ -560,7 +559,7 @@ private ObjectSpec CreateObjectSpec(TypeParseInfo typeParseInfo) if (ctor is null) { initDiagDescriptor = DiagnosticDescriptors.MissingPublicInstanceConstructor; - initExceptionMessage = string.Format(Emitter.ExceptionMessages.MissingPublicInstanceConstructor, typeName); + initExceptionMessage = string.Format(Emitter.ExceptionMessages.MissingPublicInstanceConstructor, typeSymbol.GetFullName()); } else { @@ -634,7 +633,7 @@ private ObjectSpec CreateObjectSpec(TypeParseInfo typeParseInfo) if (invalidParameters?.Count > 0) { - initExceptionMessage = string.Format(Emitter.ExceptionMessages.CannotBindToConstructorParameter, typeName, FormatParams(invalidParameters)); + initExceptionMessage = string.Format(Emitter.ExceptionMessages.CannotBindToConstructorParameter, typeSymbol.GetFullName(), FormatParams(invalidParameters)); } else if (missingParameters?.Count > 0) { @@ -644,7 +643,7 @@ private ObjectSpec CreateObjectSpec(TypeParseInfo typeParseInfo) } else { - initExceptionMessage = string.Format(Emitter.ExceptionMessages.ConstructorParametersDoNotMatchProperties, typeName, FormatParams(missingParameters)); + initExceptionMessage = string.Format(Emitter.ExceptionMessages.ConstructorParametersDoNotMatchProperties, typeSymbol.GetFullName(), FormatParams(missingParameters)); } } @@ -819,7 +818,7 @@ private void RecordTypeDiagnosticIfRequired(TypeParseInfo typeParseInfo, TypeSpe private void RecordTypeDiagnostic(TypeParseInfo typeParseInfo, DiagnosticDescriptor descriptor) { - RecordDiagnostic(descriptor, typeParseInfo.BinderInvocation.Location, new object?[] { typeParseInfo.TypeName }); + RecordDiagnostic(descriptor, typeParseInfo.BinderInvocation.Location, [typeParseInfo.FullName]); ReportContainingTypeDiagnosticIfRequired(typeParseInfo); } @@ -829,7 +828,7 @@ private void ReportContainingTypeDiagnosticIfRequired(TypeParseInfo typeParseInf while (containingTypeDiagInfo is not null) { - string containingTypeName = containingTypeDiagInfo.TypeName; + string containingTypeName = containingTypeDiagInfo.FullName; object[] messageArgs = containingTypeDiagInfo.MemberName is string memberName ? new[] { memberName, containingTypeName } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/ConfigurationBinder.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/ConfigurationBinder.cs index 4dbe36accbc6e1..c6f23779ec93d4 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/ConfigurationBinder.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/ConfigurationBinder.cs @@ -147,7 +147,7 @@ void EmitMethods(ImmutableEquatableArray? interc EmitCheckForNullArgument_WithBlankLine(Identifier.configuration, _emitThrowIfNullMethod); EmitCheckForNullArgument_WithBlankLine(Identifier.instance, _emitThrowIfNullMethod, voidReturn: true); _writer.WriteLine($$""" - var {{Identifier.typedObj}} = ({{type.DisplayString}}){{Identifier.instance}}; + var {{Identifier.typedObj}} = ({{type.TypeRef.FullyQualifiedName}}){{Identifier.instance}}; {{nameof(MethodsToGen_CoreBindingHelper.BindCore)}}({{configExpression}}, ref {{Identifier.typedObj}}, defaultValueIfNotFound: false, {{binderOptionsArg}}); """); } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs index 03366f8b49810b..2cba4ca61b50e6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Emitter/CoreBindingHelpers.cs @@ -107,7 +107,7 @@ private void EmitGetCoreMethod() TypeSpec effectiveType = _typeIndex.GetEffectiveTypeSpec(type); string conditionKindExpr = GetConditionKindExpr(ref isFirstType); - EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.DisplayString}))"); + EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.TypeRef.FullyQualifiedName}))"); switch (effectiveType) { @@ -144,7 +144,7 @@ private void EmitGetCoreMethod() #if DEBUG else { - Debug.Fail($"Complex should not be included for GetCore gen: {complexType.DisplayString}"); + Debug.Fail($"Complex should not be included for GetCore gen: {complexType.TypeRef.FullyQualifiedName}"); } #endif } @@ -195,7 +195,7 @@ private void EmitGetValueCoreMethod() foreach (TypeSpec type in targetTypes) { string conditionKindExpr = GetConditionKindExpr(ref isFirstType); - EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.DisplayString}))"); + EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.TypeRef.FullyQualifiedName}))"); EmitBindingLogic( (ParsableFromStringSpec)_typeIndex.GetEffectiveTypeSpec(type), @@ -236,8 +236,8 @@ private void EmitBindCoreMainMethod() Debug.Assert(_typeIndex.HasBindableMembers(effectiveType)); string conditionKindExpr = GetConditionKindExpr(ref isFirstType); - EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.DisplayString}))"); - _writer.WriteLine($"var {Identifier.temp} = ({effectiveType.DisplayString}){Identifier.instance};"); + EmitStartBlock($"{conditionKindExpr} ({Identifier.type} == typeof({type.TypeRef.FullyQualifiedName}))"); + _writer.WriteLine($"var {Identifier.temp} = ({effectiveType.TypeRef.FullyQualifiedName}){Identifier.instance};"); EmitBindingLogic(type, Identifier.temp, Identifier.configuration, InitializationKind.None, ValueDefaulting.None); _writer.WriteLine($"return;"); EmitEndBlock(); @@ -265,7 +265,7 @@ private void EmitBindCoreMethods() private void EmitBindCoreMethod(ComplexTypeSpec type) { - string objParameterExpression = $"ref {type.DisplayString} {Identifier.instance}"; + string objParameterExpression = $"ref {type.TypeRef.FullyQualifiedName} {Identifier.instance}"; EmitStartBlock(@$"public static void {nameof(MethodsToGen_CoreBindingHelper.BindCore)}({Identifier.IConfiguration} {Identifier.configuration}, {objParameterExpression}, bool defaultValueIfNotFound, {Identifier.BinderOptions}? {Identifier.binderOptions})"); ComplexTypeSpec effectiveType = (ComplexTypeSpec)_typeIndex.GetEffectiveTypeSpec(type); @@ -326,9 +326,8 @@ private void EmitInitializeMethod(ObjectSpec type) IEnumerable initOnlyProps = type.Properties.Where(prop => prop is { SetOnInit: true }); List ctorArgList = new(); - string displayString = type.DisplayString; - EmitStartBlock($"public static {type.DisplayString} {GetInitalizeMethodDisplayString(type)}({Identifier.IConfiguration} {Identifier.configuration}, {Identifier.BinderOptions}? {Identifier.binderOptions})"); + EmitStartBlock($"public static {type.TypeRef.FullyQualifiedName} {GetInitalizeMethodDisplayString(type)}({Identifier.IConfiguration} {Identifier.configuration}, {Identifier.BinderOptions}? {Identifier.binderOptions})"); _emitBlankLineBeforeNextStatement = false; foreach (ParameterSpec parameter in type.ConstructorParameters) @@ -355,7 +354,7 @@ private void EmitInitializeMethod(ObjectSpec type) } } - string returnExpression = $"return new {displayString}({string.Join(", ", ctorArgList)})"; + string returnExpression = $"return new {type.TypeRef.FullyQualifiedName}({string.Join(", ", ctorArgList)})"; if (!initOnlyProps.Any()) { _writer.WriteLine($"{returnExpression};"); @@ -378,7 +377,7 @@ private void EmitInitializeMethod(ObjectSpec type) void EmitBindImplForMember(MemberSpec member) { TypeSpec memberType = _typeIndex.GetTypeSpec(member.TypeRef); - string parsedMemberDeclarationLhs = $"{memberType.DisplayString} {member.Name}"; + string parsedMemberDeclarationLhs = $"{memberType.TypeRef.FullyQualifiedName} {member.Name}"; string configKeyName = member.ConfigurationKeyName; string parsedMemberAssignmentLhsExpr; @@ -437,7 +436,7 @@ void EmitThrowBlock(string condition) => _writer.WriteLine($$""" {{condition}} { - throw new {{Identifier.InvalidOperationException}}("{{string.Format(ExceptionMessages.ParameterHasNoMatchingConfig, type.Name, member.Name)}}"); + throw new {{Identifier.InvalidOperationException}}("{{string.Format(ExceptionMessages.ParameterHasNoMatchingConfig, type.FullName, member.Name)}}"); } """); } @@ -600,7 +599,7 @@ public static T ParseEnum(string value, Func getPath) where T : stru private void EmitPrimitiveParseMethod(ParsableFromStringSpec type) { StringParsableTypeKind typeKind = type.StringParsableTypeKind; - string typeDisplayString = type.DisplayString; + string typeFQN = type.TypeRef.FullyQualifiedName; string invariantCultureExpression = $"{Identifier.CultureInfo}.InvariantCulture"; string parsedValueExpr; @@ -614,22 +613,22 @@ private void EmitPrimitiveParseMethod(ParsableFromStringSpec type) break; case StringParsableTypeKind.Integer: { - parsedValueExpr = $"{typeDisplayString}.{Identifier.Parse}({Identifier.value}, {Identifier.NumberStyles}.Integer, {invariantCultureExpression})"; + parsedValueExpr = $"{typeFQN}.{Identifier.Parse}({Identifier.value}, {Identifier.NumberStyles}.Integer, {invariantCultureExpression})"; } break; case StringParsableTypeKind.Float: { - parsedValueExpr = $"{typeDisplayString}.{Identifier.Parse}({Identifier.value}, {Identifier.NumberStyles}.Float, {invariantCultureExpression})"; + parsedValueExpr = $"{typeFQN}.{Identifier.Parse}({Identifier.value}, {Identifier.NumberStyles}.Float, {invariantCultureExpression})"; } break; case StringParsableTypeKind.Parse: { - parsedValueExpr = $"{typeDisplayString}.{Identifier.Parse}({Identifier.value})"; + parsedValueExpr = $"{typeFQN}.{Identifier.Parse}({Identifier.value})"; } break; case StringParsableTypeKind.ParseInvariant: { - parsedValueExpr = $"{typeDisplayString}.{Identifier.Parse}({Identifier.value}, {invariantCultureExpression})"; ; + parsedValueExpr = $"{typeFQN}.{Identifier.Parse}({Identifier.value}, {invariantCultureExpression})"; ; } break; case StringParsableTypeKind.CultureInfo: @@ -649,9 +648,9 @@ private void EmitPrimitiveParseMethod(ParsableFromStringSpec type) } } - string exceptionArg1 = string.Format(ExceptionMessages.FailedBinding, $"{{{Identifier.getPath}()}}", $"{{typeof({typeDisplayString})}}"); + string exceptionArg1 = string.Format(ExceptionMessages.FailedBinding, $"{{{Identifier.getPath}()}}", $"{{typeof({typeFQN})}}"); - EmitStartBlock($"public static {typeDisplayString} {TypeIndex.GetParseMethodName(type)}(string {Identifier.value}, Func {Identifier.getPath})"); + EmitStartBlock($"public static {typeFQN} {TypeIndex.GetParseMethodName(type)}(string {Identifier.value}, Func {Identifier.getPath})"); EmitEndBlock($$""" try { @@ -667,11 +666,11 @@ private void EmitPrimitiveParseMethod(ParsableFromStringSpec type) private void EmitBindCoreImplForArray(ArraySpec type) { TypeRef elementTypeRef = type.ElementTypeRef; - string elementTypeDisplayString = _typeIndex.GetTypeSpec(elementTypeRef).DisplayString; + string elementTypeFQN = type.ElementTypeRef.FullyQualifiedName; string tempIdentifier = GetIncrementalIdentifier(Identifier.temp); // Create temp list. - _writer.WriteLine($"var {tempIdentifier} = new List<{elementTypeDisplayString}>();"); + _writer.WriteLine($"var {tempIdentifier} = new List<{elementTypeFQN}>();"); _writer.WriteLine(); // Bind elements to temp list. @@ -773,13 +772,13 @@ void Emit_BindAndAddLogic_ForElement(string parsedKeyExpr) if (keyType.StringParsableTypeKind is not StringParsableTypeKind.AssignFromSectionValue) { // Save value to local to avoid parsing twice - during look-up and during add. - _writer.WriteLine($"{keyType.DisplayString} {Identifier.key} = {parsedKeyExpr};"); + _writer.WriteLine($"{keyType.TypeRef.FullyQualifiedName} {Identifier.key} = {parsedKeyExpr};"); parsedKeyExpr = Identifier.key; } bool isValueType = complexElementType.IsValueType; string expressionForElementIsNotNull = $"{Identifier.element} is not null"; - string elementTypeDisplayString = complexElementType.DisplayString + (complexElementType.IsValueType ? string.Empty : "?"); + string elementTypeDisplayString = complexElementType.TypeRef.FullyQualifiedName + (complexElementType.IsValueType ? string.Empty : "?"); string expressionForElementExists = $"{instanceIdentifier}.{Identifier.TryGetValue}({parsedKeyExpr}, out {elementTypeDisplayString} {Identifier.element})"; string conditionToUseExistingElement = expressionForElementExists; @@ -829,14 +828,14 @@ private void EmitBindCoreImplForObject(ObjectSpec type) Debug.Assert(_typeIndex.HasBindableMembers(type)); string keyCacheFieldName = TypeIndex.GetConfigKeyCacheFieldName(type); - string validateMethodCallExpr = $"{Identifier.ValidateConfigurationKeys}(typeof({type.DisplayString}), {keyCacheFieldName}, {Identifier.configuration}, {Identifier.binderOptions});"; + string validateMethodCallExpr = $"{Identifier.ValidateConfigurationKeys}(typeof({type.TypeRef.FullyQualifiedName}), {keyCacheFieldName}, {Identifier.configuration}, {Identifier.binderOptions});"; _writer.WriteLine(validateMethodCallExpr); foreach (PropertySpec property in type.Properties!) { if (_typeIndex.ShouldBindTo(property)) { - string containingTypeRef = property.IsStatic ? type.DisplayString : Identifier.instance; + string containingTypeRef = property.IsStatic ? type.TypeRef.FullyQualifiedName : Identifier.instance; EmitBindImplForMember( property, memberAccessExpr: $"{containingTypeRef}.{property.Name}", @@ -930,21 +929,21 @@ private void EmitBindingLogicForComplexMember( } Debug.Assert(canSet); - string effectiveMemberTypeDisplayString = effectiveMemberType.DisplayString; + string effectiveMemberTypeFQN = effectiveMemberType.TypeRef.FullyQualifiedName; initKind = InitializationKind.None; if (memberType is NullableSpec) { string nullableTempIdentifier = GetIncrementalIdentifier(Identifier.temp); - _writer.WriteLine($"{memberType.DisplayString} {nullableTempIdentifier} = {memberAccessExpr};"); + _writer.WriteLine($"{memberType.TypeRef.FullyQualifiedName} {nullableTempIdentifier} = {memberAccessExpr};"); _writer.WriteLine( - $"{effectiveMemberTypeDisplayString} {tempIdentifier} = {nullableTempIdentifier}.{Identifier.HasValue} ? {nullableTempIdentifier}.{Identifier.Value} : new {effectiveMemberTypeDisplayString}();"); + $"{effectiveMemberTypeFQN} {tempIdentifier} = {nullableTempIdentifier}.{Identifier.HasValue} ? {nullableTempIdentifier}.{Identifier.Value} : new {effectiveMemberTypeFQN}();"); } else { - _writer.WriteLine($"{effectiveMemberTypeDisplayString} {tempIdentifier} = {memberAccessExpr};"); + _writer.WriteLine($"{effectiveMemberTypeFQN} {tempIdentifier} = {memberAccessExpr};"); } targetObjAccessExpr = tempIdentifier; @@ -1009,7 +1008,7 @@ private void EmitBindingLogic( if (initKind is InitializationKind.AssignmentWithNullCheck) { Debug.Assert(!type.IsValueType); - _writer.WriteLine($"{type.DisplayString}? {tempIdentifier} = {memberAccessExpr};"); + _writer.WriteLine($"{type.TypeRef.FullyQualifiedName}? {tempIdentifier} = {memberAccessExpr};"); EmitBindingLogic(tempIdentifier, InitializationKind.AssignmentWithNullCheck); } else if (initKind is InitializationKind.None && type.IsValueType) @@ -1076,7 +1075,7 @@ private void EmitBindingLogic( string parsedValueExpr = typeKind switch { StringParsableTypeKind.AssignFromSectionValue => stringValueToParse_Expr, - StringParsableTypeKind.Enum => $"ParseEnum<{type.DisplayString}>({stringValueToParse_Expr}, () => {sectionPathExpr})", + StringParsableTypeKind.Enum => $"ParseEnum<{type.TypeRef.FullyQualifiedName}>({stringValueToParse_Expr}, () => {sectionPathExpr})", _ => $"{TypeIndex.GetParseMethodName(type)}({stringValueToParse_Expr}, () => {sectionPathExpr})", }; @@ -1110,12 +1109,12 @@ private bool EmitObjectInit(ComplexTypeSpec type, string memberAccessExpr, Initi string? castExpr = null; string initExpr; - string effectiveDisplayString = type.DisplayString; + string typeFQN = type.TypeRef.FullyQualifiedName; if (collectionType is not null) { if (collectionType is ArraySpec) { - initExpr = $"new {s_arrayBracketsRegex.Replace(effectiveDisplayString, "[0]", 1)}"; + initExpr = $"new {s_arrayBracketsRegex.Replace(typeFQN, "[0]", 1)}"; } else { @@ -1123,11 +1122,11 @@ private bool EmitObjectInit(ComplexTypeSpec type, string memberAccessExpr, Initi if (collectionWithCtorInitType.InstantiationConcreteType is not CollectionInstantiationConcreteType.Self) { - castExpr = $"({collectionWithCtorInitType.DisplayString})"; + castExpr = $"({collectionWithCtorInitType.TypeRef.FullyQualifiedName})"; } - effectiveDisplayString = _typeIndex.GetInstantiationTypeDisplayString(collectionWithCtorInitType); - initExpr = $"{castExpr}new {effectiveDisplayString}()"; + typeFQN = TypeIndex.GetInstantiationTypeDisplayString(collectionWithCtorInitType); + initExpr = $"{castExpr}new {typeFQN}()"; } } else @@ -1137,7 +1136,7 @@ private bool EmitObjectInit(ComplexTypeSpec type, string memberAccessExpr, Initi if (strategy is ObjectInstantiationStrategy.ParameterlessConstructor) { - initExpr = $"new {effectiveDisplayString}()"; + initExpr = $"new {typeFQN}()"; } else { @@ -1164,7 +1163,7 @@ private bool EmitObjectInit(ComplexTypeSpec type, string memberAccessExpr, Initi } collectionWithCtorInitType) { string assignmentValueIfMemberNull = collectionWithCtorInitType.InstantiationStrategy is CollectionInstantiationStrategy.CopyConstructor - ? $"new {effectiveDisplayString}({memberAccessExpr})" + ? $"new {typeFQN}({memberAccessExpr})" : $"{memberAccessExpr}.ToDictionary(pair => pair.Key, pair => pair.Value)"; Debug.Assert(castExpr is not null || collectionWithCtorInitType.InstantiationConcreteType is CollectionInstantiationConcreteType.Self); @@ -1213,7 +1212,7 @@ private void EmitCollectionCastIfRequired(CollectionWithCtorInitSpec type, out s return; } - string castTypeDisplayString = _typeIndex.GetPopulationCastTypeDisplayString(type); + string castTypeDisplayString = TypeIndex.GetPopulationCastTypeDisplayString(type); instanceIdentifier = Identifier.temp; _writer.WriteLine($$""" diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Parser/Extensions.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Parser/Extensions.cs index f685842639966a..aeb78253825e56 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Parser/Extensions.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Parser/Extensions.cs @@ -15,7 +15,11 @@ internal sealed partial class Parser private readonly struct TypeParseInfo { public ITypeSymbol TypeSymbol { get; private init; } - public string TypeName { get; private init; } + + /// + /// like rendering of the symbol name. + /// + public string FullName { get; private init; } public MethodsToGen BindingOverload { get; private init; } public BinderInvocation BinderInvocation { get; private init; } public ContainingTypeDiagnosticInfo? ContainingTypeDiagnosticInfo { get; private init; } @@ -24,7 +28,7 @@ public static TypeParseInfo Create(ITypeSymbol typeSymbol, MethodsToGen overload new TypeParseInfo { TypeSymbol = typeSymbol, - TypeName = typeSymbol.GetName(), + FullName = typeSymbol.GetFullName(), BindingOverload = overload, BinderInvocation = invocation, ContainingTypeDiagnosticInfo = containingTypeDiagInfo, @@ -36,7 +40,7 @@ public TypeParseInfo ToTransitiveTypeParseInfo(ITypeSymbol memberType, Diagnosti ? null : new() { - TypeName = TypeName, + FullName = FullName, Descriptor = diagDescriptor, MemberName = memberName, ContainingTypeInfo = ContainingTypeDiagnosticInfo, @@ -48,7 +52,10 @@ public TypeParseInfo ToTransitiveTypeParseInfo(ITypeSymbol memberType, Diagnosti private sealed class ContainingTypeDiagnosticInfo { - public required string TypeName { get; init; } + /// + /// like rendering of the symbol name. + /// + public required string FullName { get; init; } public required string? MemberName { get; init; } public required DiagnosticDescriptor Descriptor { get; init; } public required ContainingTypeDiagnosticInfo? ContainingTypeInfo { get; init; } @@ -113,14 +120,14 @@ public static string ToIdentifierCompatibleSubstring(this ITypeSymbol type) return sb.ToString(); } - public static (string? Namespace, string DisplayString, string Name) GetTypeName(this ITypeSymbol type) + public static (string DisplayString, string FullName) GetTypeNames(this ITypeSymbol type) { string? @namespace = type.ContainingNamespace is { IsGlobalNamespace: false } containingNamespace ? containingNamespace.ToDisplayString() : null; string displayString = type.ToDisplayString(s_minimalDisplayFormat); - string name = (@namespace is null ? string.Empty : @namespace + ".") + displayString.Replace(".", "+"); - return (@namespace, displayString, name); + string fullname = (@namespace is null ? string.Empty : @namespace + ".") + displayString.Replace(".", "+"); + return (displayString, fullname); } - public static string GetName(this ITypeSymbol type) => GetTypeName(type).Name; + public static string GetFullName(this ITypeSymbol type) => GetTypeNames(type).FullName; } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs index 096c8410717ae7..316b904de88979 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/BindingHelperInfo.cs @@ -214,11 +214,6 @@ private void RegisterTypeForMethodGen(MethodsToGen_CoreBindingHelper method, Typ if (types.Add(type)) { _methodsToGen |= method; - - if (type is { Namespace: string @namespace }) - { - _namespaces.Add(@namespace); - } } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/TypeIndex.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/TypeIndex.cs index 5b59577b392921..5328d1da922a3a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/TypeIndex.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/TypeIndex.cs @@ -68,33 +68,33 @@ public TypeSpec GetEffectiveTypeSpec(TypeSpec typeSpec) public TypeSpec GetTypeSpec(TypeRef typeRef) => _index[typeRef]; - public string GetInstantiationTypeDisplayString(CollectionWithCtorInitSpec type) + public static string GetInstantiationTypeDisplayString(CollectionWithCtorInitSpec type) { CollectionInstantiationConcreteType concreteType = type.InstantiationConcreteType; return concreteType is CollectionInstantiationConcreteType.Self - ? type.DisplayString + ? type.TypeRef.FullyQualifiedName : GetGenericTypeDisplayString(type, concreteType); } - public string GetPopulationCastTypeDisplayString(CollectionWithCtorInitSpec type) + public static string GetPopulationCastTypeDisplayString(CollectionWithCtorInitSpec type) { CollectionPopulationCastType castType = type.PopulationCastType; Debug.Assert(castType is not CollectionPopulationCastType.NotApplicable); return GetGenericTypeDisplayString(type, castType); } - public string GetGenericTypeDisplayString(CollectionWithCtorInitSpec type, Enum genericProxyTypeName) + public static string GetGenericTypeDisplayString(CollectionWithCtorInitSpec type, Enum genericProxyTypeName) { string proxyTypeNameStr = genericProxyTypeName.ToString(); - string elementTypeDisplayString = GetTypeSpec(type.ElementTypeRef).DisplayString; + string elementTypeFQN = type.ElementTypeRef.FullyQualifiedName; if (type is EnumerableSpec) { - return $"{proxyTypeNameStr}<{elementTypeDisplayString}>"; + return $"{proxyTypeNameStr}<{elementTypeFQN}>"; } - string keyTypeDisplayString = GetTypeSpec(((DictionarySpec)type).KeyTypeRef).DisplayString; - return $"{proxyTypeNameStr}<{keyTypeDisplayString}, {elementTypeDisplayString}>"; + string keyTypeDisplayString = ((DictionarySpec)type).KeyTypeRef.FullyQualifiedName; + return $"{proxyTypeNameStr}<{keyTypeDisplayString}, {elementTypeFQN}>"; } public bool KeyIsSupported(DictionarySpec typeSpec) => @@ -109,14 +109,31 @@ public static string GetParseMethodName(ParsableFromStringSpec type) { Debug.Assert(type.StringParsableTypeKind is not StringParsableTypeKind.AssignFromSectionValue); - string displayString = type.DisplayString; + if (type.StringParsableTypeKind is StringParsableTypeKind.ByteArray) + { + return "ParseByteArray"; + } + + string displayString = type.TypeRef.FullyQualifiedName; + + const string GlobalPrefix = "global::"; + if (displayString.StartsWith(GlobalPrefix)) + { + displayString = displayString.Substring(GlobalPrefix.Length); + } - string parseMethod = type.StringParsableTypeKind is StringParsableTypeKind.ByteArray - ? "ParseByteArray" - // MinimalDisplayString.Length is certainly > 2. - : $"Parse{(char.ToUpper(displayString[0]) + displayString.Substring(1)).Replace(".", "")}"; + Debug.Assert(displayString.Length > 0); + if (char.IsLower(displayString[0])) + { + displayString = char.ToUpperInvariant(displayString[0]) + displayString.Substring(1); + } + + if (displayString.Contains('.')) + { + displayString = displayString.Replace(".", ""); + } - return parseMethod; + return "Parse" + displayString; } } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/Types/TypeSpec.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/Types/TypeSpec.cs index 1c243ae1cdc7c1..69168edb58eff8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/Types/TypeSpec.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/gen/Specs/Types/TypeSpec.cs @@ -13,8 +13,8 @@ public abstract record TypeSpec public TypeSpec(ITypeSymbol type) { TypeRef = new TypeRef(type); - EffectiveTypeRef = TypeRef; // Overriden by NullableSpec. - (Namespace, DisplayString, Name) = type.GetTypeName(); + EffectiveTypeRef = TypeRef; // Overridden by NullableSpec. + (DisplayString, FullName) = type.GetTypeNames(); IdentifierCompatibleSubstring = type.ToIdentifierCompatibleSubstring(); IsValueType = type.IsValueType; } @@ -23,14 +23,18 @@ public TypeSpec(ITypeSymbol type) public TypeRef EffectiveTypeRef { get; protected init; } - public string Name { get; } + /// + /// like rendering of the type name. + /// + public string FullName { get; } + /// + /// Display name excluding the namespace. + /// public string DisplayString { get; } public string IdentifierCompatibleSubstring { get; } - public string? Namespace { get; } - public bool IsValueType { get; } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Collections.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Collections.generated.txt index ea4fba79cbc465..a03d4c855c399c 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Collections.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Collections.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -53,9 +57,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClassWithCustomCollections)) + if (type == typeof(global::Program.MyClassWithCustomCollections)) { - var instance = new Program.MyClassWithCustomCollections(); + var instance = new global::Program.MyClassWithCustomCollections(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -63,7 +67,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.CustomDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.CustomDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -74,7 +78,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.CustomList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.CustomList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -85,7 +89,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref IReadOnlyList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.IReadOnlyList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection temp) { @@ -101,7 +105,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref IReadOnlyDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.IReadOnlyDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not IDictionary temp) { @@ -117,38 +121,38 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClassWithCustomCollections instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClassWithCustomCollections instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClassWithCustomCollections), s_configKeys_ProgramMyClassWithCustomCollections, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClassWithCustomCollections), s_configKeys_ProgramMyClassWithCustomCollections, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("CustomDictionary")) is IConfigurationSection section1) { - Program.CustomDictionary? temp3 = instance.CustomDictionary; - temp3 ??= new Program.CustomDictionary(); + global::Program.CustomDictionary? temp3 = instance.CustomDictionary; + temp3 ??= new global::Program.CustomDictionary(); BindCore(section1, ref temp3, defaultValueIfNotFound: false, binderOptions); instance.CustomDictionary = temp3; } if (AsConfigWithChildren(configuration.GetSection("CustomList")) is IConfigurationSection section4) { - Program.CustomList? temp6 = instance.CustomList; - temp6 ??= new Program.CustomList(); + global::Program.CustomList? temp6 = instance.CustomList; + temp6 ??= new global::Program.CustomList(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.CustomList = temp6; } if (AsConfigWithChildren(configuration.GetSection("IReadOnlyList")) is IConfigurationSection section7) { - IReadOnlyList? temp9 = instance.IReadOnlyList; - temp9 = temp9 is null ? (IReadOnlyList)new List() : (IReadOnlyList)new List(temp9); + global::System.Collections.Generic.IReadOnlyList? temp9 = instance.IReadOnlyList; + temp9 = temp9 is null ? (global::System.Collections.Generic.IReadOnlyList)new List() : (global::System.Collections.Generic.IReadOnlyList)new List(temp9); BindCore(section7, ref temp9, defaultValueIfNotFound: false, binderOptions); instance.IReadOnlyList = temp9; } if (AsConfigWithChildren(configuration.GetSection("IReadOnlyDictionary")) is IConfigurationSection section10) { - IReadOnlyDictionary? temp12 = instance.IReadOnlyDictionary; - temp12 = temp12 is null ? (IReadOnlyDictionary)new Dictionary() : (IReadOnlyDictionary)temp12.ToDictionary(pair => pair.Key, pair => pair.Value); + global::System.Collections.Generic.IReadOnlyDictionary? temp12 = instance.IReadOnlyDictionary; + temp12 = temp12 is null ? (global::System.Collections.Generic.IReadOnlyDictionary)new Dictionary() : (global::System.Collections.Generic.IReadOnlyDictionary)temp12.ToDictionary(pair => pair.Key, pair => pair.Value); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.IReadOnlyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind.generated.txt index fc0dda4b5b3ae9..8cb6fa53a52eb5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -44,7 +48,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } @@ -62,7 +66,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, GetBinderOptions(configureOptions)); } @@ -80,7 +84,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration.GetSection(key), ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -88,7 +92,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -99,7 +103,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -110,21 +114,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -142,24 +146,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance.generated.txt index 9cbc0a22c5c84d..392f067b9c3645 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -44,7 +48,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -52,7 +56,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -63,7 +67,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -74,21 +78,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -106,24 +110,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt index f3efa07fc0c5c2..35f4495fe0c185 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -44,7 +48,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, GetBinderOptions(configureOptions)); } #endregion IConfiguration extensions. @@ -52,7 +56,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -63,7 +67,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -74,21 +78,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -106,24 +110,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Key_Instance.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Key_Instance.generated.txt index 89b82d31bc19ae..6373c432f52401 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Key_Instance.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_Key_Instance.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -44,7 +48,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration.GetSection(key), ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -52,7 +56,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -63,7 +67,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -74,21 +78,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -106,24 +110,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt index 14753a4a1f8e4b..2a1453546c7bf9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get.generated.txt index b6fb659d544d42..b51fefddba98ad 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -65,15 +69,15 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } - else if (type == typeof(Program.MyClass2)) + else if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -81,7 +85,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -109,7 +113,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp2.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -120,9 +124,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -140,8 +144,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } @@ -156,16 +160,16 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value14) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue.generated.txt index bf7e64bd31f90c..e6fb4b5166ed89 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -73,9 +77,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration { return ParseByteArray(value, () => section.Path); } - else if (type == typeof(CultureInfo)) + else if (type == typeof(global::System.Globalization.CultureInfo)) { - return ParseCultureInfo(value, () => section.Path); + return ParseSystemGlobalizationCultureInfo(value, () => section.Path); } return null; @@ -117,7 +121,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -125,7 +129,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } #endregion Core binding extensions. diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key.generated.txt index b86915b78303b2..273df87c8e8098 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt index 697f710dff3027..b3d91eb6b49e8a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt index b5a22e71ccefbf..b8c1c5b1381915 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt index 4a4564796e562f..f93fb114275fe8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -49,15 +53,15 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(CultureInfo)) + if (type == typeof(global::System.Globalization.CultureInfo)) { - return ParseCultureInfo(value, () => section.Path); + return ParseSystemGlobalizationCultureInfo(value, () => section.Path); } return null; } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -65,7 +69,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } #endregion Core binding extensions. diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_PrimitivesOnly.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_PrimitivesOnly.generated.txt index b703fb5f1c864b..446bf43866a38e 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_PrimitivesOnly.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_PrimitivesOnly.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T.generated.txt index c2e8f167bb4750..8eecd3ba72a1e1 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -52,9 +56,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -62,7 +66,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -90,7 +94,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp1.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -101,9 +105,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value2) { @@ -121,8 +125,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section4) { - List? temp6 = instance.MyList; - temp6 ??= new List(); + global::System.Collections.Generic.List? temp6 = instance.MyList; + temp6 ??= new global::System.Collections.Generic.List(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp6; } @@ -137,8 +141,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section10) { - Dictionary? temp12 = instance.MyDictionary; - temp12 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp12 = instance.MyDictionary; + temp12 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T_BinderOptions.generated.txt index cd3f237917d4e3..ec88c39f20a2de 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -52,9 +56,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -62,7 +66,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -90,7 +94,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp1.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -101,9 +105,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value2) { @@ -121,8 +125,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section4) { - List? temp6 = instance.MyList; - temp6 ??= new List(); + global::System.Collections.Generic.List? temp6 = instance.MyList; + temp6 ??= new global::System.Collections.Generic.List(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp6; } @@ -137,8 +141,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section10) { - Dictionary? temp12 = instance.MyDictionary; - temp12 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp12 = instance.MyDictionary; + temp12 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf.generated.txt index eca2001123ff01..46c24547478ab1 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -52,9 +56,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass2)) + if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -62,9 +66,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt index 7883f4a50da0f6..f37307065a78e3 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -52,9 +56,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass2)) + if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -62,9 +66,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/EmptyConfigType.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/EmptyConfigType.generated.txt index 404ce7561cc47c..d435dc06d606d8 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/EmptyConfigType.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/EmptyConfigType.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -50,7 +54,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (TypeWithNoMembers_Wrapper)instance; + var typedObj = (global::TypeWithNoMembers_Wrapper)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -58,13 +62,13 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_TypeWithNoMembers_Wrapper = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "Member" }); - public static void BindCore(IConfiguration configuration, ref TypeWithNoMembers_Wrapper instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::TypeWithNoMembers_Wrapper instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(TypeWithNoMembers_Wrapper), s_configKeys_TypeWithNoMembers_Wrapper, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::TypeWithNoMembers_Wrapper), s_configKeys_TypeWithNoMembers_Wrapper, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Member")) is IConfigurationSection section0) { - instance.Member ??= new TypeWithNoMembers(); + instance.Member ??= new global::TypeWithNoMembers(); } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/BindConfiguration.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/BindConfiguration.generated.txt index f26695c7093969..e5b2254220fcf6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/BindConfiguration.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/BindConfiguration.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -83,9 +87,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -93,7 +97,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -104,9 +108,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -124,8 +128,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T.generated.txt index 8d7c70a27b3f2e..1907c525993237 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -89,9 +93,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -99,7 +103,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -110,9 +114,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -130,8 +134,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T_BinderOptions.generated.txt index 385079af1709a4..b3eb6354b5dbf5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/OptionsBuilder/Bind_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -83,9 +87,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -93,7 +97,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -104,9 +108,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -124,8 +128,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Primitives.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Primitives.generated.txt index 6f189bf2e55ba2..90c6a72aa4e559 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Primitives.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/Primitives.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -44,7 +48,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -52,9 +56,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "Prop0", "Prop1", "Prop2", "Prop3", "Prop4", "Prop5", "Prop6", "Prop8", "Prop9", "Prop10", "Prop13", "Prop14", "Prop15", "Prop16", "Prop17", "Prop19", "Prop20", "Prop21", "Prop23", "Prop24", "Prop25", "Prop26", "Prop27", "Prop28", "Prop29", "Prop30" }); - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["Prop0"] is string value0) { @@ -176,12 +180,12 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop17"] is string value14) { - instance.Prop17 = ParseCultureInfo(value14, () => configuration.GetSection("Prop17").Path); + instance.Prop17 = ParseSystemGlobalizationCultureInfo(value14, () => configuration.GetSection("Prop17").Path); } if (configuration["Prop19"] is string value15) { - instance.Prop19 = ParseDateTime(value15, () => configuration.GetSection("Prop19").Path); + instance.Prop19 = ParseSystemDateTime(value15, () => configuration.GetSection("Prop19").Path); } else if (defaultValueIfNotFound) { @@ -190,7 +194,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop20"] is string value16) { - instance.Prop20 = ParseDateTimeOffset(value16, () => configuration.GetSection("Prop20").Path); + instance.Prop20 = ParseSystemDateTimeOffset(value16, () => configuration.GetSection("Prop20").Path); } else if (defaultValueIfNotFound) { @@ -208,7 +212,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop23"] is string value18) { - instance.Prop23 = ParseTimeSpan(value18, () => configuration.GetSection("Prop23").Path); + instance.Prop23 = ParseSystemTimeSpan(value18, () => configuration.GetSection("Prop23").Path); } else if (defaultValueIfNotFound) { @@ -217,7 +221,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop24"] is string value19) { - instance.Prop24 = ParseGuid(value19, () => configuration.GetSection("Prop24").Path); + instance.Prop24 = ParseSystemGuid(value19, () => configuration.GetSection("Prop24").Path); } else if (defaultValueIfNotFound) { @@ -226,17 +230,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop25"] is string value20) { - instance.Prop25 = ParseUri(value20, () => configuration.GetSection("Prop25").Path); + instance.Prop25 = ParseSystemUri(value20, () => configuration.GetSection("Prop25").Path); } if (configuration["Prop26"] is string value21) { - instance.Prop26 = ParseVersion(value21, () => configuration.GetSection("Prop26").Path); + instance.Prop26 = ParseSystemVersion(value21, () => configuration.GetSection("Prop26").Path); } if (configuration["Prop27"] is string value22) { - instance.Prop27 = ParseEnum(value22, () => configuration.GetSection("Prop27").Path); + instance.Prop27 = ParseEnum(value22, () => configuration.GetSection("Prop27").Path); } else if (defaultValueIfNotFound) { @@ -259,7 +263,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop30"] is string value25) { - instance.Prop30 = ParseDateTime(value25, () => configuration.GetSection("Prop30").Path); + instance.Prop30 = ParseSystemDateTime(value25, () => configuration.GetSection("Prop30").Path); } else if (defaultValueIfNotFound) { @@ -446,7 +450,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -454,31 +458,31 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } - public static DateTime ParseDateTime(string value, Func getPath) + public static global::System.DateTime ParseSystemDateTime(string value, Func getPath) { try { - return DateTime.Parse(value, CultureInfo.InvariantCulture); + return global::System.DateTime.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(DateTime)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.DateTime)}'.", exception); } } - public static DateTimeOffset ParseDateTimeOffset(string value, Func getPath) + public static global::System.DateTimeOffset ParseSystemDateTimeOffset(string value, Func getPath) { try { - return DateTimeOffset.Parse(value, CultureInfo.InvariantCulture); + return global::System.DateTimeOffset.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(DateTimeOffset)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.DateTimeOffset)}'.", exception); } } @@ -494,31 +498,31 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static TimeSpan ParseTimeSpan(string value, Func getPath) + public static global::System.TimeSpan ParseSystemTimeSpan(string value, Func getPath) { try { - return TimeSpan.Parse(value, CultureInfo.InvariantCulture); + return global::System.TimeSpan.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(TimeSpan)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.TimeSpan)}'.", exception); } } - public static Guid ParseGuid(string value, Func getPath) + public static global::System.Guid ParseSystemGuid(string value, Func getPath) { try { - return Guid.Parse(value); + return global::System.Guid.Parse(value); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Guid)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Guid)}'.", exception); } } - public static Uri ParseUri(string value, Func getPath) + public static global::System.Uri ParseSystemUri(string value, Func getPath) { try { @@ -526,19 +530,19 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Uri)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Uri)}'.", exception); } } - public static Version ParseVersion(string value, Func getPath) + public static global::System.Version ParseSystemVersion(string value, Func getPath) { try { - return Version.Parse(value); + return global::System.Version.Parse(value); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Version)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Version)}'.", exception); } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T.generated.txt index 3e38a484c82552..88cf455949d50d 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -76,9 +80,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -86,7 +90,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -97,9 +101,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -111,17 +115,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -132,9 +136,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -152,24 +156,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_BinderOptions.generated.txt index 186e93a49207b2..96b4208f6a07f5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -76,9 +80,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -86,7 +90,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -97,9 +101,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -111,17 +115,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -132,9 +136,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -152,24 +156,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name.generated.txt index 7958adb1125338..77d46f40769aae 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -76,9 +80,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -86,7 +90,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -97,9 +101,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -111,17 +115,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -132,9 +136,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -152,24 +156,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name_BinderOptions.generated.txt index b87d0c0a259cc8..c42a34af05204e 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/net462/ServiceCollection/Configure_T_name_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -70,9 +74,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -80,7 +84,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -91,9 +95,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -105,17 +109,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -126,9 +130,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -146,24 +150,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Collections.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Collections.generated.txt index b0210df5e044ef..b489907db90059 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Collections.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Collections.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -50,9 +54,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClassWithCustomCollections)) + if (type == typeof(global::Program.MyClassWithCustomCollections)) { - var instance = new Program.MyClassWithCustomCollections(); + var instance = new global::Program.MyClassWithCustomCollections(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -60,7 +64,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.CustomDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.CustomDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -71,7 +75,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.CustomList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.CustomList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -82,7 +86,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref IReadOnlyList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.IReadOnlyList instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection temp) { @@ -98,7 +102,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref IReadOnlyDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.IReadOnlyDictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not IDictionary temp) { @@ -114,38 +118,38 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClassWithCustomCollections instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClassWithCustomCollections instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClassWithCustomCollections), s_configKeys_ProgramMyClassWithCustomCollections, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClassWithCustomCollections), s_configKeys_ProgramMyClassWithCustomCollections, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("CustomDictionary")) is IConfigurationSection section1) { - Program.CustomDictionary? temp3 = instance.CustomDictionary; - temp3 ??= new Program.CustomDictionary(); + global::Program.CustomDictionary? temp3 = instance.CustomDictionary; + temp3 ??= new global::Program.CustomDictionary(); BindCore(section1, ref temp3, defaultValueIfNotFound: false, binderOptions); instance.CustomDictionary = temp3; } if (AsConfigWithChildren(configuration.GetSection("CustomList")) is IConfigurationSection section4) { - Program.CustomList? temp6 = instance.CustomList; - temp6 ??= new Program.CustomList(); + global::Program.CustomList? temp6 = instance.CustomList; + temp6 ??= new global::Program.CustomList(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.CustomList = temp6; } if (AsConfigWithChildren(configuration.GetSection("IReadOnlyList")) is IConfigurationSection section7) { - IReadOnlyList? temp9 = instance.IReadOnlyList; - temp9 = temp9 is null ? (IReadOnlyList)new List() : (IReadOnlyList)new List(temp9); + global::System.Collections.Generic.IReadOnlyList? temp9 = instance.IReadOnlyList; + temp9 = temp9 is null ? (global::System.Collections.Generic.IReadOnlyList)new List() : (global::System.Collections.Generic.IReadOnlyList)new List(temp9); BindCore(section7, ref temp9, defaultValueIfNotFound: false, binderOptions); instance.IReadOnlyList = temp9; } if (AsConfigWithChildren(configuration.GetSection("IReadOnlyDictionary")) is IConfigurationSection section10) { - IReadOnlyDictionary? temp12 = instance.IReadOnlyDictionary; - temp12 = temp12 is null ? (IReadOnlyDictionary)new Dictionary() : (IReadOnlyDictionary)temp12.ToDictionary(pair => pair.Key, pair => pair.Value); + global::System.Collections.Generic.IReadOnlyDictionary? temp12 = instance.IReadOnlyDictionary; + temp12 = temp12 is null ? (global::System.Collections.Generic.IReadOnlyDictionary)new Dictionary() : (global::System.Collections.Generic.IReadOnlyDictionary)temp12.ToDictionary(pair => pair.Key, pair => pair.Value); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.IReadOnlyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind.generated.txt index c1c98b7d1e1623..da0c7375e13f62 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -41,7 +45,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } @@ -56,7 +60,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, GetBinderOptions(configureOptions)); } @@ -71,7 +75,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration.GetSection(key), ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -79,7 +83,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -90,7 +94,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -101,21 +105,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -133,24 +137,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance.generated.txt index 8c961fff978132..336d1b5a9f4ca7 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -41,7 +45,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -49,7 +53,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -60,7 +64,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -71,21 +75,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -103,24 +107,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt index f7ea54e511a57d..80c908cedbee23 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Instance_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -41,7 +45,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, GetBinderOptions(configureOptions)); } #endregion IConfiguration extensions. @@ -49,7 +53,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -60,7 +64,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -71,21 +75,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -103,24 +107,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Key_Instance.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Key_Instance.generated.txt index 22e430f70e6b79..592e8f14ae4101 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Key_Instance.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_Key_Instance.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -41,7 +45,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration.GetSection(key), ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -49,7 +53,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "MyString", "MyInt", "MyList", "MyDictionary", "MyComplexDictionary" }); - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -60,7 +64,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -71,21 +75,21 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - if (!(instance.TryGetValue(section.Key, out Program.MyClass2? element) && element is not null)) + if (!(instance.TryGetValue(section.Key, out global::Program.MyClass2? element) && element is not null)) { - element = new Program.MyClass2(); + element = new global::Program.MyClass2(); } instance[section.Key] = element; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value0) { @@ -103,24 +107,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section2) { - List? temp4 = instance.MyList; - temp4 ??= new List(); + global::System.Collections.Generic.List? temp4 = instance.MyList; + temp4 ??= new global::System.Collections.Generic.List(); BindCore(section2, ref temp4, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp4; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section5) { - Dictionary? temp7 = instance.MyDictionary; - temp7 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp7 = instance.MyDictionary; + temp7 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyComplexDictionary")) is IConfigurationSection section8) { - Dictionary? temp10 = instance.MyComplexDictionary; - temp10 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp10 = instance.MyComplexDictionary; + temp10 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyComplexDictionary = temp10; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt index 14753a4a1f8e4b..2a1453546c7bf9 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Bind_ParseTypeFromMethodParam.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get.generated.txt index a050ddffd430f9..0c631bfc10e6ae 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -62,15 +66,15 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } - else if (type == typeof(Program.MyClass2)) + else if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -78,7 +82,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -106,7 +110,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp2.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -117,9 +121,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -137,8 +141,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } @@ -153,16 +157,16 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value14) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue.generated.txt index cd7bd92c05b8d1..67df05b508e896 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -70,9 +74,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration { return ParseByteArray(value, () => section.Path); } - else if (type == typeof(CultureInfo)) + else if (type == typeof(global::System.Globalization.CultureInfo)) { - return ParseCultureInfo(value, () => section.Path); + return ParseSystemGlobalizationCultureInfo(value, () => section.Path); } return null; @@ -114,7 +118,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -122,7 +126,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } #endregion Core binding extensions. diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key.generated.txt index 1ebddd4bdc3ac7..678fa163a57c82 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt index 897a937ea31f6c..b546b86ea1b9b6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_T_Key_DefaultValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt index 8fd4c52ad6c933..706dec382c8635 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt index e5000774326125..772160a53bdd55 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/GetValue_TypeOf_Key_DefaultValue.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -46,15 +50,15 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(CultureInfo)) + if (type == typeof(global::System.Globalization.CultureInfo)) { - return ParseCultureInfo(value, () => section.Path); + return ParseSystemGlobalizationCultureInfo(value, () => section.Path); } return null; } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -62,7 +66,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } #endregion Core binding extensions. diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_PrimitivesOnly.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_PrimitivesOnly.generated.txt index 021a4ca8bef4ed..4934212d5836a5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_PrimitivesOnly.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_PrimitivesOnly.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T.generated.txt index c054010f560a08..93766ec1d40508 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -49,9 +53,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -59,7 +63,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -87,7 +91,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp1.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -98,9 +102,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value2) { @@ -118,8 +122,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section4) { - List? temp6 = instance.MyList; - temp6 ??= new List(); + global::System.Collections.Generic.List? temp6 = instance.MyList; + temp6 ??= new global::System.Collections.Generic.List(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp6; } @@ -134,8 +138,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section10) { - Dictionary? temp12 = instance.MyDictionary; - temp12 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp12 = instance.MyDictionary; + temp12 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T_BinderOptions.generated.txt index 9266520e105a61..caae5dfc5a8367 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -49,9 +53,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var instance = new Program.MyClass(); + var instance = new global::Program.MyClass(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -59,7 +63,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -87,7 +91,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration temp1.CopyTo(instance, originalCount); } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -98,9 +102,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value2) { @@ -118,8 +122,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section4) { - List? temp6 = instance.MyList; - temp6 ??= new List(); + global::System.Collections.Generic.List? temp6 = instance.MyList; + temp6 ??= new global::System.Collections.Generic.List(); BindCore(section4, ref temp6, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp6; } @@ -134,8 +138,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section10) { - Dictionary? temp12 = instance.MyDictionary; - temp12 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp12 = instance.MyDictionary; + temp12 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp12; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf.generated.txt index 8818894f387c4b..9c28e846781de5 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -49,9 +53,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass2)) + if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -59,9 +63,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt index 6202545f7ae8d5..c2b86bd863e499 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ConfigurationBinder/Get_TypeOf_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -49,9 +53,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return null; } - if (type == typeof(Program.MyClass2)) + if (type == typeof(global::Program.MyClass2)) { - var instance = new Program.MyClass2(); + var instance = new global::Program.MyClass2(); BindCore(configuration, ref instance, defaultValueIfNotFound: true, binderOptions); return instance; } @@ -59,9 +63,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/EmptyConfigType.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/EmptyConfigType.generated.txt index 0bb9d336b81e9e..026724498ac82a 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/EmptyConfigType.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/EmptyConfigType.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -47,7 +51,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (TypeWithNoMembers_Wrapper)instance; + var typedObj = (global::TypeWithNoMembers_Wrapper)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -55,13 +59,13 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_TypeWithNoMembers_Wrapper = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "Member" }); - public static void BindCore(IConfiguration configuration, ref TypeWithNoMembers_Wrapper instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::TypeWithNoMembers_Wrapper instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(TypeWithNoMembers_Wrapper), s_configKeys_TypeWithNoMembers_Wrapper, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::TypeWithNoMembers_Wrapper), s_configKeys_TypeWithNoMembers_Wrapper, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Member")) is IConfigurationSection section0) { - instance.Member ??= new TypeWithNoMembers(); + instance.Member ??= new global::TypeWithNoMembers(); } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/BindConfiguration.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/BindConfiguration.generated.txt index 3199217c28a0ed..d09432aa258337 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/BindConfiguration.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/BindConfiguration.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -74,9 +78,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -84,7 +88,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -95,9 +99,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -115,8 +119,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T.generated.txt index 76023bb8f04e26..1d116049774fe6 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -80,9 +84,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -90,7 +94,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -101,9 +105,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -121,8 +125,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T_BinderOptions.generated.txt index c6336da8dfaece..2a1abf7f17d363 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/OptionsBuilder/Bind_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -74,9 +78,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -84,7 +88,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -95,9 +99,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value1) { @@ -115,8 +119,8 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section3) { - List? temp5 = instance.MyList; - temp5 ??= new List(); + global::System.Collections.Generic.List? temp5 = instance.MyList; + temp5 ??= new global::System.Collections.Generic.List(); BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp5; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Primitives.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Primitives.generated.txt index 2d42875b9f9961..fdbe79002b2d34 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Primitives.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/Primitives.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -41,7 +45,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration return; } - var typedObj = (Program.MyClass)instance; + var typedObj = (global::Program.MyClass)instance; BindCore(configuration, ref typedObj, defaultValueIfNotFound: false, binderOptions: null); } #endregion IConfiguration extensions. @@ -49,9 +53,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration #region Core binding extensions. private readonly static Lazy> s_configKeys_ProgramMyClass = new(() => new HashSet(StringComparer.OrdinalIgnoreCase) { "Prop0", "Prop1", "Prop2", "Prop3", "Prop4", "Prop5", "Prop6", "Prop8", "Prop9", "Prop10", "Prop13", "Prop14", "Prop15", "Prop16", "Prop17", "Prop19", "Prop20", "Prop21", "Prop23", "Prop24", "Prop25", "Prop26", "Prop27", "Prop7", "Prop11", "Prop12", "Prop18", "Prop22", "Prop28", "Prop29", "Prop30" }); - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["Prop0"] is string value0) { @@ -173,12 +177,12 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop17"] is string value14) { - instance.Prop17 = ParseCultureInfo(value14, () => configuration.GetSection("Prop17").Path); + instance.Prop17 = ParseSystemGlobalizationCultureInfo(value14, () => configuration.GetSection("Prop17").Path); } if (configuration["Prop19"] is string value15) { - instance.Prop19 = ParseDateTime(value15, () => configuration.GetSection("Prop19").Path); + instance.Prop19 = ParseSystemDateTime(value15, () => configuration.GetSection("Prop19").Path); } else if (defaultValueIfNotFound) { @@ -187,7 +191,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop20"] is string value16) { - instance.Prop20 = ParseDateTimeOffset(value16, () => configuration.GetSection("Prop20").Path); + instance.Prop20 = ParseSystemDateTimeOffset(value16, () => configuration.GetSection("Prop20").Path); } else if (defaultValueIfNotFound) { @@ -205,7 +209,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop23"] is string value18) { - instance.Prop23 = ParseTimeSpan(value18, () => configuration.GetSection("Prop23").Path); + instance.Prop23 = ParseSystemTimeSpan(value18, () => configuration.GetSection("Prop23").Path); } else if (defaultValueIfNotFound) { @@ -214,7 +218,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop24"] is string value19) { - instance.Prop24 = ParseGuid(value19, () => configuration.GetSection("Prop24").Path); + instance.Prop24 = ParseSystemGuid(value19, () => configuration.GetSection("Prop24").Path); } else if (defaultValueIfNotFound) { @@ -223,17 +227,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop25"] is string value20) { - instance.Prop25 = ParseUri(value20, () => configuration.GetSection("Prop25").Path); + instance.Prop25 = ParseSystemUri(value20, () => configuration.GetSection("Prop25").Path); } if (configuration["Prop26"] is string value21) { - instance.Prop26 = ParseVersion(value21, () => configuration.GetSection("Prop26").Path); + instance.Prop26 = ParseSystemVersion(value21, () => configuration.GetSection("Prop26").Path); } if (configuration["Prop27"] is string value22) { - instance.Prop27 = ParseEnum(value22, () => configuration.GetSection("Prop27").Path); + instance.Prop27 = ParseEnum(value22, () => configuration.GetSection("Prop27").Path); } else if (defaultValueIfNotFound) { @@ -242,7 +246,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop7"] is string value23) { - instance.Prop7 = ParseInt128(value23, () => configuration.GetSection("Prop7").Path); + instance.Prop7 = ParseSystemInt128(value23, () => configuration.GetSection("Prop7").Path); } else if (defaultValueIfNotFound) { @@ -251,7 +255,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop11"] is string value24) { - instance.Prop11 = ParseHalf(value24, () => configuration.GetSection("Prop11").Path); + instance.Prop11 = ParseSystemHalf(value24, () => configuration.GetSection("Prop11").Path); } else if (defaultValueIfNotFound) { @@ -260,7 +264,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop12"] is string value25) { - instance.Prop12 = ParseUInt128(value25, () => configuration.GetSection("Prop12").Path); + instance.Prop12 = ParseSystemUInt128(value25, () => configuration.GetSection("Prop12").Path); } else if (defaultValueIfNotFound) { @@ -269,7 +273,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop18"] is string value26) { - instance.Prop18 = ParseDateOnly(value26, () => configuration.GetSection("Prop18").Path); + instance.Prop18 = ParseSystemDateOnly(value26, () => configuration.GetSection("Prop18").Path); } else if (defaultValueIfNotFound) { @@ -278,7 +282,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop22"] is string value27) { - instance.Prop22 = ParseTimeOnly(value27, () => configuration.GetSection("Prop22").Path); + instance.Prop22 = ParseSystemTimeOnly(value27, () => configuration.GetSection("Prop22").Path); } else if (defaultValueIfNotFound) { @@ -301,7 +305,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (configuration["Prop30"] is string value30) { - instance.Prop30 = ParseDateTime(value30, () => configuration.GetSection("Prop30").Path); + instance.Prop30 = ParseSystemDateTime(value30, () => configuration.GetSection("Prop30").Path); } else if (defaultValueIfNotFound) { @@ -488,7 +492,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static CultureInfo ParseCultureInfo(string value, Func getPath) + public static global::System.Globalization.CultureInfo ParseSystemGlobalizationCultureInfo(string value, Func getPath) { try { @@ -496,31 +500,31 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(CultureInfo)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Globalization.CultureInfo)}'.", exception); } } - public static DateTime ParseDateTime(string value, Func getPath) + public static global::System.DateTime ParseSystemDateTime(string value, Func getPath) { try { - return DateTime.Parse(value, CultureInfo.InvariantCulture); + return global::System.DateTime.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(DateTime)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.DateTime)}'.", exception); } } - public static DateTimeOffset ParseDateTimeOffset(string value, Func getPath) + public static global::System.DateTimeOffset ParseSystemDateTimeOffset(string value, Func getPath) { try { - return DateTimeOffset.Parse(value, CultureInfo.InvariantCulture); + return global::System.DateTimeOffset.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(DateTimeOffset)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.DateTimeOffset)}'.", exception); } } @@ -536,31 +540,31 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static TimeSpan ParseTimeSpan(string value, Func getPath) + public static global::System.TimeSpan ParseSystemTimeSpan(string value, Func getPath) { try { - return TimeSpan.Parse(value, CultureInfo.InvariantCulture); + return global::System.TimeSpan.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(TimeSpan)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.TimeSpan)}'.", exception); } } - public static Guid ParseGuid(string value, Func getPath) + public static global::System.Guid ParseSystemGuid(string value, Func getPath) { try { - return Guid.Parse(value); + return global::System.Guid.Parse(value); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Guid)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Guid)}'.", exception); } } - public static Uri ParseUri(string value, Func getPath) + public static global::System.Uri ParseSystemUri(string value, Func getPath) { try { @@ -568,79 +572,79 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Uri)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Uri)}'.", exception); } } - public static Version ParseVersion(string value, Func getPath) + public static global::System.Version ParseSystemVersion(string value, Func getPath) { try { - return Version.Parse(value); + return global::System.Version.Parse(value); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Version)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Version)}'.", exception); } } - public static Int128 ParseInt128(string value, Func getPath) + public static global::System.Int128 ParseSystemInt128(string value, Func getPath) { try { - return Int128.Parse(value, CultureInfo.InvariantCulture); + return global::System.Int128.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Int128)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Int128)}'.", exception); } } - public static Half ParseHalf(string value, Func getPath) + public static global::System.Half ParseSystemHalf(string value, Func getPath) { try { - return Half.Parse(value, CultureInfo.InvariantCulture); + return global::System.Half.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Half)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.Half)}'.", exception); } } - public static UInt128 ParseUInt128(string value, Func getPath) + public static global::System.UInt128 ParseSystemUInt128(string value, Func getPath) { try { - return UInt128.Parse(value, CultureInfo.InvariantCulture); + return global::System.UInt128.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(UInt128)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.UInt128)}'.", exception); } } - public static DateOnly ParseDateOnly(string value, Func getPath) + public static global::System.DateOnly ParseSystemDateOnly(string value, Func getPath) { try { - return DateOnly.Parse(value, CultureInfo.InvariantCulture); + return global::System.DateOnly.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(DateOnly)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.DateOnly)}'.", exception); } } - public static TimeOnly ParseTimeOnly(string value, Func getPath) + public static global::System.TimeOnly ParseSystemTimeOnly(string value, Func getPath) { try { - return TimeOnly.Parse(value, CultureInfo.InvariantCulture); + return global::System.TimeOnly.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { - throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(TimeOnly)}'.", exception); + throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(global::System.TimeOnly)}'.", exception); } } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T.generated.txt index 5d5b84cc1765ae..1bfbbdf6594751 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -70,9 +74,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -80,7 +84,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -91,9 +95,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -105,17 +109,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -126,9 +130,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -146,24 +150,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_BinderOptions.generated.txt index 9c75578aef9f79..8004628b3c4198 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -70,9 +74,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -80,7 +84,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -91,9 +95,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -105,17 +109,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -126,9 +130,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -146,24 +150,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name.generated.txt index 6d396b26bdefd8..98e11998663ebf 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -70,9 +74,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -80,7 +84,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -91,9 +95,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -105,17 +109,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -126,9 +130,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -146,24 +150,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name_BinderOptions.generated.txt b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name_BinderOptions.generated.txt index 2834491e351352..18b8b3b21dcd7d 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name_BinderOptions.generated.txt +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/Baselines/netcoreapp/ServiceCollection/Configure_T_name_BinderOptions.generated.txt @@ -1,6 +1,10 @@ // -#nullable enable -#pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. + +#nullable enable annotations +#nullable disable warnings + +// Suppress warnings about [Obsolete] member usage in generated code. +#pragma warning disable CS0612, CS0618 namespace System.Runtime.CompilerServices { @@ -64,9 +68,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration BinderOptions? binderOptions = GetBinderOptions(configureOptions); - if (type == typeof(Program.MyClass)) + if (type == typeof(global::Program.MyClass)) { - var temp = (Program.MyClass)instance; + var temp = (global::Program.MyClass)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } @@ -74,7 +78,7 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -85,9 +89,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass2 instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass2), s_configKeys_ProgramMyClass2, configuration, binderOptions); if (configuration["MyInt"] is string value1) { @@ -99,17 +103,17 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.List instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { - var value = new Program.MyClass2(); + var value = new global::Program.MyClass2(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } - public static void BindCore(IConfiguration configuration, ref Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::System.Collections.Generic.Dictionary instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { @@ -120,9 +124,9 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration } } - public static void BindCore(IConfiguration configuration, ref Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) + public static void BindCore(IConfiguration configuration, ref global::Program.MyClass instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { - ValidateConfigurationKeys(typeof(Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); + ValidateConfigurationKeys(typeof(global::Program.MyClass), s_configKeys_ProgramMyClass, configuration, binderOptions); if (configuration["MyString"] is string value3) { @@ -140,24 +144,24 @@ namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration if (AsConfigWithChildren(configuration.GetSection("MyList")) is IConfigurationSection section5) { - List? temp7 = instance.MyList; - temp7 ??= new List(); + global::System.Collections.Generic.List? temp7 = instance.MyList; + temp7 ??= new global::System.Collections.Generic.List(); BindCore(section5, ref temp7, defaultValueIfNotFound: false, binderOptions); instance.MyList = temp7; } if (AsConfigWithChildren(configuration.GetSection("MyList2")) is IConfigurationSection section8) { - List? temp10 = instance.MyList2; - temp10 ??= new List(); + global::System.Collections.Generic.List? temp10 = instance.MyList2; + temp10 ??= new global::System.Collections.Generic.List(); BindCore(section8, ref temp10, defaultValueIfNotFound: false, binderOptions); instance.MyList2 = temp10; } if (AsConfigWithChildren(configuration.GetSection("MyDictionary")) is IConfigurationSection section11) { - Dictionary? temp13 = instance.MyDictionary; - temp13 ??= new Dictionary(); + global::System.Collections.Generic.Dictionary? temp13 = instance.MyDictionary; + temp13 ??= new global::System.Collections.Generic.Dictionary(); BindCore(section11, ref temp13, defaultValueIfNotFound: false, binderOptions); instance.MyDictionary = temp13; } diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs index b5c8cc534f693d..24285047fff900 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.Helpers.cs @@ -138,7 +138,11 @@ private static async Task VerifyAgainstBaselineUsingF string source = string.Join(Environment.NewLine, lines).TrimEnd(Environment.NewLine.ToCharArray()) + Environment.NewLine; path = Path.Combine($"{repoRootDir}\\src\\libraries\\Microsoft.Extensions.Configuration.Binder\\tests\\SourceGenerationTests\\", path); - await File.WriteAllTextAsync(path, source).ConfigureAwait(false); +#if NETCOREAPP + await File.WriteAllTextAsync(path, source); +#else + File.WriteAllText(path, source); +#endif resultEqualsBaseline = true; } #endif diff --git a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs index 741ed473179407..f2cc5155789ae0 100644 --- a/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs +++ b/src/libraries/Microsoft.Extensions.Configuration.Binder/tests/SourceGenerationTests/GeneratorTests.cs @@ -176,6 +176,33 @@ public class MyClass { } } } + [Fact] + public async Task SucceedWhenGivenConflictingTypeNames() + { + // Regression test for https://github.com/dotnet/runtime/issues/93498 + + string source = """ + using Microsoft.Extensions.Configuration; + + var c = new ConfigurationBuilder().Build(); + c.Get(); + + namespace Microsoft.Foo + { + internal class AType {} + } + + namespace Foo.Bar + { + internal class BType {} + } + """; + + ConfigBindingGenRunResult result = await RunGeneratorAndUpdateCompilation(source); + Assert.NotNull(result.GeneratedSource); + Assert.Empty(result.Diagnostics); + } + [Fact] public async Task SucceedWhenGivenMinimumRequiredReferences() {