// <auto-generated/> #nullable enable #pragma warning disable CS0612, CS0618 // Suppress warnings about [Obsolete] member usage in generated code. namespace System.Runtime.CompilerServices { using System; using System.CodeDom.Compiler; [GeneratedCode("Microsoft.Extensions.Configuration.Binder.SourceGeneration", "8.0.9.3103")] [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] file sealed class InterceptsLocationAttribute : Attribute { public InterceptsLocationAttribute(string filePath, int line, int column) { } } } namespace Microsoft.Extensions.Configuration.Binder.SourceGeneration { using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; using Microsoft.Extensions.Options; using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Globalization; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; [GeneratedCode("Microsoft.Extensions.Configuration.Binder.SourceGeneration", "8.0.9.3103")] file static class BindingExtensions { #region IServiceCollection extensions. /// <summary>Registers a configuration instance which TOptions will bind against.</summary> [InterceptsLocation(@"/_/src/Libraries/Microsoft.Extensions.Diagnostics.Testing/Logging/FakeLoggerBuilderExtensions.cs", 31, 30)] public static IServiceCollection Configure<TOptions>(this IServiceCollection services, IConfiguration config) where TOptions : class { return Configure<TOptions>(services, string.Empty, config, configureOptions: null); } /// <summary>Registers a configuration instance which TOptions will bind against.</summary> public static IServiceCollection Configure<TOptions>(this IServiceCollection services, string? name, IConfiguration config, Action<BinderOptions>? configureOptions) where TOptions : class { if (services is null) { throw new ArgumentNullException(nameof(services)); } if (config is null) { throw new ArgumentNullException(nameof(config)); } OptionsServiceCollectionExtensions.AddOptions(services); services.AddSingleton<IOptionsChangeTokenSource<TOptions>>(new ConfigurationChangeTokenSource<TOptions>(name, config)); return services.AddSingleton<IConfigureOptions<TOptions>>(new ConfigureNamedOptions<TOptions>(name, instance => BindCoreMain(config, instance, typeof(TOptions), configureOptions))); } #endregion IServiceCollection extensions. #region Core binding extensions. private readonly static Lazy<HashSet<string>> s_configKeys_IntPtr = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Size" }); private readonly static Lazy<HashSet<string>> s_configKeys_RuntimeMethodHandle = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Value" }); private readonly static Lazy<HashSet<string>> s_configKeys_ModuleHandle = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "MDStreamVersion" }); private readonly static Lazy<HashSet<string>> s_configKeys_Module = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Assembly", "CustomAttributes", "FullyQualifiedName", "MDStreamVersion", "MetadataToken", "ModuleHandle", "ModuleVersionId", "Name", "ScopeName" }); private readonly static Lazy<HashSet<string>> s_configKeys_ConstructorInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "MemberType", "Attributes", "CallingConvention", "ContainsGenericParameters", "IsAbstract", "IsAssembly", "IsConstructor", "IsFamily", "IsFamilyAndAssembly", "IsFamilyOrAssembly", "IsFinal", "IsGenericMethod", "IsGenericMethodDefinition", "IsHideBySig", "IsPrivate", "IsPublic", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSpecialName", "IsStatic", "IsVirtual", "MethodHandle", "MethodImplementationFlags", "CustomAttributes", "DeclaringType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_EventInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "AddMethod", "Attributes", "EventHandlerType", "IsMulticast", "IsSpecialName", "MemberType", "RaiseMethod", "RemoveMethod", "CustomAttributes", "DeclaringType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_RuntimeFieldHandle = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Value" }); private readonly static Lazy<HashSet<string>> s_configKeys_FieldInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Attributes", "FieldHandle", "FieldType", "IsAssembly", "IsFamily", "IsFamilyAndAssembly", "IsFamilyOrAssembly", "IsInitOnly", "IsLiteral", "IsNotSerialized", "IsPinvokeImpl", "IsPrivate", "IsPublic", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSpecialName", "IsStatic", "MemberType", "CustomAttributes", "DeclaringType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_MemberInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "CustomAttributes", "DeclaringType", "MemberType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_PropertyInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Attributes", "CanRead", "CanWrite", "GetMethod", "IsSpecialName", "MemberType", "PropertyType", "SetMethod", "CustomAttributes", "DeclaringType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_MethodBase = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Attributes", "CallingConvention", "ContainsGenericParameters", "IsAbstract", "IsAssembly", "IsConstructor", "IsFamily", "IsFamilyAndAssembly", "IsFamilyOrAssembly", "IsFinal", "IsGenericMethod", "IsGenericMethodDefinition", "IsHideBySig", "IsPrivate", "IsPublic", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSpecialName", "IsStatic", "IsVirtual", "MethodHandle", "MethodImplementationFlags", "CustomAttributes", "DeclaringType", "MemberType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_StructLayoutAttribute = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Value", "TypeId" }); private readonly static Lazy<HashSet<string>> s_configKeys_RuntimeTypeHandle = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Value" }); private readonly static Lazy<HashSet<string>> s_configKeys_TypeInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "DeclaredConstructors", "DeclaredEvents", "DeclaredFields", "DeclaredMembers", "DeclaredMethods", "DeclaredNestedTypes", "DeclaredProperties", "GenericTypeParameters", "ImplementedInterfaces", "Assembly", "AssemblyQualifiedName", "Attributes", "BaseType", "ContainsGenericParameters", "DeclaringMethod", "DeclaringType", "DefaultBinder", "FullName", "GenericParameterAttributes", "GenericParameterPosition", "GenericTypeArguments", "GUID", "HasElementType", "IsAbstract", "IsAnsiClass", "IsArray", "IsAutoClass", "IsAutoLayout", "IsByRef", "IsClass", "IsCOMObject", "IsConstructedGenericType", "IsContextful", "IsEnum", "IsExplicitLayout", "IsGenericParameter", "IsGenericType", "IsGenericTypeDefinition", "IsImport", "IsInterface", "IsLayoutSequential", "IsMarshalByRef", "IsNested", "IsNestedAssembly", "IsNestedFamANDAssem", "IsNestedFamily", "IsNestedFamORAssem", "IsNestedPrivate", "IsNestedPublic", "IsNotPublic", "IsPointer", "IsPrimitive", "IsPublic", "IsSealed", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSerializable", "IsSpecialName", "IsUnicodeClass", "IsValueType", "IsVisible", "MemberType", "Module", "Namespace", "ReflectedType", "StructLayoutAttribute", "TypeHandle", "TypeInitializer", "UnderlyingSystemType", "CustomAttributes", "MetadataToken", "Name" }); private readonly static Lazy<HashSet<string>> s_configKeys_Assembly = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "CodeBase", "CustomAttributes", "DefinedTypes", "EntryPoint", "EscapedCodeBase", "ExportedTypes", "FullName", "GlobalAssemblyCache", "HostContext", "ImageRuntimeVersion", "IsDynamic", "IsFullyTrusted", "Location", "ManifestModule", "Modules", "ReflectionOnly", "SecurityRuleSet" }); private readonly static Lazy<HashSet<string>> s_configKeys_Type = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Assembly", "AssemblyQualifiedName", "Attributes", "BaseType", "ContainsGenericParameters", "DeclaringMethod", "DeclaringType", "DefaultBinder", "FullName", "GenericParameterAttributes", "GenericParameterPosition", "GenericTypeArguments", "GUID", "HasElementType", "IsAbstract", "IsAnsiClass", "IsArray", "IsAutoClass", "IsAutoLayout", "IsByRef", "IsClass", "IsCOMObject", "IsConstructedGenericType", "IsContextful", "IsEnum", "IsExplicitLayout", "IsGenericParameter", "IsGenericType", "IsGenericTypeDefinition", "IsImport", "IsInterface", "IsLayoutSequential", "IsMarshalByRef", "IsNested", "IsNestedAssembly", "IsNestedFamANDAssem", "IsNestedFamily", "IsNestedFamORAssem", "IsNestedPrivate", "IsNestedPublic", "IsNotPublic", "IsPointer", "IsPrimitive", "IsPublic", "IsSealed", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSerializable", "IsSpecialName", "IsUnicodeClass", "IsValueType", "IsVisible", "MemberType", "Module", "Namespace", "ReflectedType", "StructLayoutAttribute", "TypeHandle", "TypeInitializer", "UnderlyingSystemType", "CustomAttributes", "MetadataToken", "Name" }); private readonly static Lazy<HashSet<string>> s_configKeys_CustomAttributeTypedArgument = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Value", "ArgumentType" }); private readonly static Lazy<HashSet<string>> s_configKeys_CustomAttributeNamedArgument = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "MemberInfo", "IsField", "MemberName", "TypedValue" }); private readonly static Lazy<HashSet<string>> s_configKeys_CustomAttributeData = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "AttributeType", "Constructor", "ConstructorArguments", "NamedArguments" }); private readonly static Lazy<HashSet<string>> s_configKeys_ParameterInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Attributes", "CustomAttributes", "DefaultValue", "HasDefaultValue", "IsIn", "IsLcid", "IsOptional", "IsOut", "IsRetval", "Member", "MetadataToken", "Name", "ParameterType", "Position", "RawDefaultValue" }); private readonly static Lazy<HashSet<string>> s_configKeys_MethodInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "MemberType", "ReturnParameter", "ReturnType", "ReturnTypeCustomAttributes", "Attributes", "CallingConvention", "ContainsGenericParameters", "IsAbstract", "IsAssembly", "IsConstructor", "IsFamily", "IsFamilyAndAssembly", "IsFamilyOrAssembly", "IsFinal", "IsGenericMethod", "IsGenericMethodDefinition", "IsHideBySig", "IsPrivate", "IsPublic", "IsSecurityCritical", "IsSecuritySafeCritical", "IsSecurityTransparent", "IsSpecialName", "IsStatic", "IsVirtual", "MethodHandle", "MethodImplementationFlags", "CustomAttributes", "DeclaringType", "MetadataToken", "Module", "Name", "ReflectedType" }); private readonly static Lazy<HashSet<string>> s_configKeys_FuncFakeLogRecordBoolean = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Method", "Target" }); private readonly static Lazy<HashSet<string>> s_configKeys_TimeZoneInfo = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "BaseUtcOffset", "DaylightName", "DisplayName", "Id", "Local", "StandardName", "SupportsDaylightSavingTime", "Utc" }); private readonly static Lazy<HashSet<string>> s_configKeys_TimeProvider = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "System", "LocalTimeZone", "TimestampFrequency" }); private readonly static Lazy<HashSet<string>> s_configKeys_ActionString = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Method", "Target" }); private readonly static Lazy<HashSet<string>> s_configKeys_FuncFakeLogRecordString = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Method", "Target" }); private readonly static Lazy<HashSet<string>> s_configKeys_FakeLogCollectorOptions = new(() => new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "FilteredCategories", "FilteredLevels", "CustomFilter", "CollectRecordsForDisabledLogLevels", "TimeProvider", "OutputSink", "OutputFormatter" }); public static void BindCoreMain(IConfiguration configuration, object instance, Type type, Action<BinderOptions>? configureOptions) { if (instance is null) { return; } if (!HasValueOrChildren(configuration)) { return; } BinderOptions? binderOptions = GetBinderOptions(configureOptions); if (type == typeof(FakeLogCollectorOptions)) { var temp = (FakeLogCollectorOptions)instance; BindCore(configuration, ref temp, defaultValueIfNotFound: false, binderOptions); return; } throw new NotSupportedException($"Unable to bind to type '{type}': generator did not detect the type as input."); } public static void BindCore(IConfiguration configuration, ref ISet<string> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { if (section.Value is string value) { instance.Add(value); } } } public static void BindCore(IConfiguration configuration, ref ISet<LogLevel> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { if (section.Value is string value) { instance.Add(ParseEnum<LogLevel>(value, () => section.Path)); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<CustomAttributeData> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<CustomAttributeData> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref IntPtr instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(IntPtr), s_configKeys_IntPtr, configuration, binderOptions); } public static void BindCore(IConfiguration configuration, ref RuntimeMethodHandle instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(RuntimeMethodHandle), s_configKeys_RuntimeMethodHandle, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Value")) is IConfigurationSection section1) { } } public static void BindCore(IConfiguration configuration, ref ModuleHandle instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(ModuleHandle), s_configKeys_ModuleHandle, configuration, binderOptions); } public static void BindCore(IConfiguration configuration, ref Module instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Module), s_configKeys_Module, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Assembly")) is IConfigurationSection section3) { Assembly? temp5 = instance.Assembly; if (temp5 is not null) { BindCore(section3, ref temp5, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Assembly' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ModuleHandle")) is IConfigurationSection section6) { } } public static void BindCore(IConfiguration configuration, ref ConstructorInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(ConstructorInfo), s_configKeys_ConstructorInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("MethodHandle")) is IConfigurationSection section8) { } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section10) { Type? temp12 = instance.DeclaringType; if (temp12 is not null) { BindCore(section10, ref temp12, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section13) { Module? temp15 = instance.Module; if (temp15 is not null) { BindCore(section13, ref temp15, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section16) { Type? temp18 = instance.ReflectedType; if (temp18 is not null) { BindCore(section16, ref temp18, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<ConstructorInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<ConstructorInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref EventInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(EventInfo), s_configKeys_EventInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("AddMethod")) is IConfigurationSection section19) { MethodInfo? temp21 = instance.AddMethod; if (temp21 is not null) { BindCore(section19, ref temp21, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("EventHandlerType")) is IConfigurationSection section22) { Type? temp24 = instance.EventHandlerType; if (temp24 is not null) { BindCore(section22, ref temp24, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("RaiseMethod")) is IConfigurationSection section25) { MethodInfo? temp27 = instance.RaiseMethod; if (temp27 is not null) { BindCore(section25, ref temp27, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("RemoveMethod")) is IConfigurationSection section28) { MethodInfo? temp30 = instance.RemoveMethod; if (temp30 is not null) { BindCore(section28, ref temp30, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section31) { Type? temp33 = instance.DeclaringType; if (temp33 is not null) { BindCore(section31, ref temp33, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section34) { Module? temp36 = instance.Module; if (temp36 is not null) { BindCore(section34, ref temp36, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section37) { Type? temp39 = instance.ReflectedType; if (temp39 is not null) { BindCore(section37, ref temp39, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<EventInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<EventInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref RuntimeFieldHandle instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(RuntimeFieldHandle), s_configKeys_RuntimeFieldHandle, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Value")) is IConfigurationSection section40) { } } public static void BindCore(IConfiguration configuration, ref FieldInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(FieldInfo), s_configKeys_FieldInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("FieldHandle")) is IConfigurationSection section42) { } if (AsConfigWithChildren(configuration.GetSection("FieldType")) is IConfigurationSection section44) { Type? temp46 = instance.FieldType; if (temp46 is not null) { BindCore(section44, ref temp46, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section47) { Type? temp49 = instance.DeclaringType; if (temp49 is not null) { BindCore(section47, ref temp49, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section50) { Module? temp52 = instance.Module; if (temp52 is not null) { BindCore(section50, ref temp52, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section53) { Type? temp55 = instance.ReflectedType; if (temp55 is not null) { BindCore(section53, ref temp55, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<FieldInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<FieldInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref MemberInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(MemberInfo), s_configKeys_MemberInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section56) { Type? temp58 = instance.DeclaringType; if (temp58 is not null) { BindCore(section56, ref temp58, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section59) { Module? temp61 = instance.Module; if (temp61 is not null) { BindCore(section59, ref temp61, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section62) { Type? temp64 = instance.ReflectedType; if (temp64 is not null) { BindCore(section62, ref temp64, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<MemberInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<MemberInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref IEnumerable<MethodInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<MethodInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref IEnumerable<TypeInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<TypeInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref PropertyInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(PropertyInfo), s_configKeys_PropertyInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("GetMethod")) is IConfigurationSection section65) { MethodInfo? temp67 = instance.GetMethod; if (temp67 is not null) { BindCore(section65, ref temp67, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("PropertyType")) is IConfigurationSection section68) { Type? temp70 = instance.PropertyType; if (temp70 is not null) { BindCore(section68, ref temp70, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("SetMethod")) is IConfigurationSection section71) { MethodInfo? temp73 = instance.SetMethod; if (temp73 is not null) { BindCore(section71, ref temp73, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section74) { Type? temp76 = instance.DeclaringType; if (temp76 is not null) { BindCore(section74, ref temp76, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section77) { Module? temp79 = instance.Module; if (temp79 is not null) { BindCore(section77, ref temp79, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section80) { Type? temp82 = instance.ReflectedType; if (temp82 is not null) { BindCore(section80, ref temp82, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<PropertyInfo> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<PropertyInfo> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref Type[] instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { var temp83 = new List<Type>(); foreach (IConfigurationSection section in configuration.GetChildren()) { } int originalCount = instance.Length; Array.Resize(ref instance, originalCount + temp83.Count); temp83.CopyTo(instance, originalCount); } public static void BindCore(IConfiguration configuration, ref IEnumerable<Type> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<Type> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref MethodBase instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(MethodBase), s_configKeys_MethodBase, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("MethodHandle")) is IConfigurationSection section84) { } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section86) { Type? temp88 = instance.DeclaringType; if (temp88 is not null) { BindCore(section86, ref temp88, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section89) { Module? temp91 = instance.Module; if (temp91 is not null) { BindCore(section89, ref temp91, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section92) { Type? temp94 = instance.ReflectedType; if (temp94 is not null) { BindCore(section92, ref temp94, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref StructLayoutAttribute instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(StructLayoutAttribute), s_configKeys_StructLayoutAttribute, configuration, binderOptions); } public static void BindCore(IConfiguration configuration, ref RuntimeTypeHandle instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(RuntimeTypeHandle), s_configKeys_RuntimeTypeHandle, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Value")) is IConfigurationSection section95) { } } public static void BindCore(IConfiguration configuration, ref TypeInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(TypeInfo), s_configKeys_TypeInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("GenericTypeParameters")) is IConfigurationSection section97) { Type[]? temp99 = instance.GenericTypeParameters; temp99 ??= new Type[0]; BindCore(section97, ref temp99, defaultValueIfNotFound: false, binderOptions); } if (AsConfigWithChildren(configuration.GetSection("Assembly")) is IConfigurationSection section100) { Assembly? temp102 = instance.Assembly; if (temp102 is not null) { BindCore(section100, ref temp102, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Assembly' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("BaseType")) is IConfigurationSection section103) { Type? temp105 = instance.BaseType; if (temp105 is not null) { BindCore(section103, ref temp105, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringMethod")) is IConfigurationSection section106) { MethodBase? temp108 = instance.DeclaringMethod; if (temp108 is not null) { BindCore(section106, ref temp108, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodBase' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section109) { Type? temp111 = instance.DeclaringType; if (temp111 is not null) { BindCore(section109, ref temp111, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DefaultBinder")) is IConfigurationSection section112) { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Binder' because it is missing a public instance constructor."); } if (AsConfigWithChildren(configuration.GetSection("GenericTypeArguments")) is IConfigurationSection section114) { Type[]? temp116 = instance.GenericTypeArguments; temp116 ??= new Type[0]; BindCore(section114, ref temp116, defaultValueIfNotFound: false, binderOptions); } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section117) { Module? temp119 = instance.Module; if (temp119 is not null) { BindCore(section117, ref temp119, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section120) { Type? temp122 = instance.ReflectedType; if (temp122 is not null) { BindCore(section120, ref temp122, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("StructLayoutAttribute")) is IConfigurationSection section123) { StructLayoutAttribute? temp125 = instance.StructLayoutAttribute; if (temp125 is not null) { BindCore(section123, ref temp125, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Runtime.InteropServices.StructLayoutAttribute' because one or more parameters cannot be bound to. Constructor parameters must have corresponding properties. Fields are not supported. Missing properties are: 'layoutKind'"); } } if (AsConfigWithChildren(configuration.GetSection("TypeHandle")) is IConfigurationSection section126) { } if (AsConfigWithChildren(configuration.GetSection("TypeInitializer")) is IConfigurationSection section128) { ConstructorInfo? temp130 = instance.TypeInitializer; if (temp130 is not null) { BindCore(section128, ref temp130, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.ConstructorInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("UnderlyingSystemType")) is IConfigurationSection section131) { Type? temp133 = instance.UnderlyingSystemType; if (temp133 is not null) { BindCore(section131, ref temp133, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IEnumerable<Module> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { if (instance is not ICollection<Module> temp) { return; } foreach (IConfigurationSection section in configuration.GetChildren()) { } } public static void BindCore(IConfiguration configuration, ref Assembly instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Assembly), s_configKeys_Assembly, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("EntryPoint")) is IConfigurationSection section134) { MethodInfo? temp136 = instance.EntryPoint; if (temp136 is not null) { BindCore(section134, ref temp136, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ManifestModule")) is IConfigurationSection section137) { Module? temp139 = instance.ManifestModule; if (temp139 is not null) { BindCore(section137, ref temp139, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref Type instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Type), s_configKeys_Type, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Assembly")) is IConfigurationSection section140) { Assembly? temp142 = instance.Assembly; if (temp142 is not null) { BindCore(section140, ref temp142, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Assembly' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("BaseType")) is IConfigurationSection section143) { Type? temp145 = instance.BaseType; if (temp145 is not null) { BindCore(section143, ref temp145, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringMethod")) is IConfigurationSection section146) { MethodBase? temp148 = instance.DeclaringMethod; if (temp148 is not null) { BindCore(section146, ref temp148, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodBase' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section149) { Type? temp151 = instance.DeclaringType; if (temp151 is not null) { BindCore(section149, ref temp151, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("DefaultBinder")) is IConfigurationSection section152) { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Binder' because it is missing a public instance constructor."); } if (AsConfigWithChildren(configuration.GetSection("GenericTypeArguments")) is IConfigurationSection section154) { Type[]? temp156 = instance.GenericTypeArguments; temp156 ??= new Type[0]; BindCore(section154, ref temp156, defaultValueIfNotFound: false, binderOptions); } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section157) { Module? temp159 = instance.Module; if (temp159 is not null) { BindCore(section157, ref temp159, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section160) { Type? temp162 = instance.ReflectedType; if (temp162 is not null) { BindCore(section160, ref temp162, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("StructLayoutAttribute")) is IConfigurationSection section163) { StructLayoutAttribute? temp165 = instance.StructLayoutAttribute; if (temp165 is not null) { BindCore(section163, ref temp165, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Runtime.InteropServices.StructLayoutAttribute' because one or more parameters cannot be bound to. Constructor parameters must have corresponding properties. Fields are not supported. Missing properties are: 'layoutKind'"); } } if (AsConfigWithChildren(configuration.GetSection("TypeHandle")) is IConfigurationSection section166) { } if (AsConfigWithChildren(configuration.GetSection("TypeInitializer")) is IConfigurationSection section168) { ConstructorInfo? temp170 = instance.TypeInitializer; if (temp170 is not null) { BindCore(section168, ref temp170, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.ConstructorInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("UnderlyingSystemType")) is IConfigurationSection section171) { Type? temp173 = instance.UnderlyingSystemType; if (temp173 is not null) { BindCore(section171, ref temp173, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref CustomAttributeTypedArgument instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(CustomAttributeTypedArgument), s_configKeys_CustomAttributeTypedArgument, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("ArgumentType")) is IConfigurationSection section174) { Type? temp176 = instance.ArgumentType; if (temp176 is not null) { BindCore(section174, ref temp176, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref IList<CustomAttributeTypedArgument> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { var value = InitializeCustomAttributeTypedArgument(section, binderOptions); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } public static void BindCore(IConfiguration configuration, ref CustomAttributeNamedArgument instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(CustomAttributeNamedArgument), s_configKeys_CustomAttributeNamedArgument, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("MemberInfo")) is IConfigurationSection section178) { MemberInfo? temp180 = instance.MemberInfo; if (temp180 is not null) { BindCore(section178, ref temp180, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MemberInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("TypedValue")) is IConfigurationSection section181) { } } public static void BindCore(IConfiguration configuration, ref IList<CustomAttributeNamedArgument> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { foreach (IConfigurationSection section in configuration.GetChildren()) { var value = new CustomAttributeNamedArgument(); BindCore(section, ref value, defaultValueIfNotFound: false, binderOptions); instance.Add(value); } } public static void BindCore(IConfiguration configuration, ref CustomAttributeData instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(CustomAttributeData), s_configKeys_CustomAttributeData, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("AttributeType")) is IConfigurationSection section184) { Type? temp186 = instance.AttributeType; if (temp186 is not null) { BindCore(section184, ref temp186, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Constructor")) is IConfigurationSection section187) { ConstructorInfo? temp189 = instance.Constructor; if (temp189 is not null) { BindCore(section187, ref temp189, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.ConstructorInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ConstructorArguments")) is IConfigurationSection section190) { IList<CustomAttributeTypedArgument>? temp192 = instance.ConstructorArguments; temp192 ??= (IList<CustomAttributeTypedArgument>)new List<CustomAttributeTypedArgument>(); BindCore(section190, ref temp192, defaultValueIfNotFound: false, binderOptions); } if (AsConfigWithChildren(configuration.GetSection("NamedArguments")) is IConfigurationSection section193) { IList<CustomAttributeNamedArgument>? temp195 = instance.NamedArguments; temp195 ??= (IList<CustomAttributeNamedArgument>)new List<CustomAttributeNamedArgument>(); BindCore(section193, ref temp195, defaultValueIfNotFound: false, binderOptions); } } public static void BindCore(IConfiguration configuration, ref ParameterInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(ParameterInfo), s_configKeys_ParameterInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Member")) is IConfigurationSection section196) { MemberInfo? temp198 = instance.Member; if (temp198 is not null) { BindCore(section196, ref temp198, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MemberInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ParameterType")) is IConfigurationSection section199) { Type? temp201 = instance.ParameterType; if (temp201 is not null) { BindCore(section199, ref temp201, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref MethodInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(MethodInfo), s_configKeys_MethodInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("ReturnParameter")) is IConfigurationSection section202) { ParameterInfo? temp204 = instance.ReturnParameter; if (temp204 is not null) { BindCore(section202, ref temp204, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.ParameterInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReturnType")) is IConfigurationSection section205) { Type? temp207 = instance.ReturnType; if (temp207 is not null) { BindCore(section205, ref temp207, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReturnTypeCustomAttributes")) is IConfigurationSection section208) { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.ICustomAttributeProvider' because it is missing a public instance constructor."); } if (AsConfigWithChildren(configuration.GetSection("MethodHandle")) is IConfigurationSection section210) { } if (AsConfigWithChildren(configuration.GetSection("DeclaringType")) is IConfigurationSection section212) { Type? temp214 = instance.DeclaringType; if (temp214 is not null) { BindCore(section212, ref temp214, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Module")) is IConfigurationSection section215) { Module? temp217 = instance.Module; if (temp217 is not null) { BindCore(section215, ref temp217, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.Module' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("ReflectedType")) is IConfigurationSection section218) { Type? temp220 = instance.ReflectedType; if (temp220 is not null) { BindCore(section218, ref temp220, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Type' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref Func<FakeLogRecord, bool> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Func<FakeLogRecord, bool>), s_configKeys_FuncFakeLogRecordBoolean, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Method")) is IConfigurationSection section221) { MethodInfo? temp223 = instance.Method; if (temp223 is not null) { BindCore(section221, ref temp223, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref TimeZoneInfo instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(TimeZoneInfo), s_configKeys_TimeZoneInfo, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Local")) is IConfigurationSection section224) { TimeZoneInfo? temp226 = TimeZoneInfo.Local; if (temp226 is not null) { BindCore(section224, ref temp226, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.TimeZoneInfo' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("Utc")) is IConfigurationSection section227) { TimeZoneInfo? temp229 = TimeZoneInfo.Utc; if (temp229 is not null) { BindCore(section227, ref temp229, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.TimeZoneInfo' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref TimeProvider instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(TimeProvider), s_configKeys_TimeProvider, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("System")) is IConfigurationSection section230) { TimeProvider? temp232 = TimeProvider.System; if (temp232 is not null) { BindCore(section230, ref temp232, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.TimeProvider' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("LocalTimeZone")) is IConfigurationSection section233) { TimeZoneInfo? temp235 = instance.LocalTimeZone; if (temp235 is not null) { BindCore(section233, ref temp235, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.TimeZoneInfo' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref Action<string> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Action<string>), s_configKeys_ActionString, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Method")) is IConfigurationSection section236) { MethodInfo? temp238 = instance.Method; if (temp238 is not null) { BindCore(section236, ref temp238, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref Func<FakeLogRecord, string> instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(Func<FakeLogRecord, string>), s_configKeys_FuncFakeLogRecordString, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("Method")) is IConfigurationSection section239) { MethodInfo? temp241 = instance.Method; if (temp241 is not null) { BindCore(section239, ref temp241, defaultValueIfNotFound: false, binderOptions); } else { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.MethodInfo' because it is missing a public instance constructor."); } } } public static void BindCore(IConfiguration configuration, ref FakeLogCollectorOptions instance, bool defaultValueIfNotFound, BinderOptions? binderOptions) { ValidateConfigurationKeys(typeof(FakeLogCollectorOptions), s_configKeys_FakeLogCollectorOptions, configuration, binderOptions); if (AsConfigWithChildren(configuration.GetSection("FilteredCategories")) is IConfigurationSection section242) { ISet<string>? temp244 = instance.FilteredCategories; temp244 ??= (ISet<string>)new HashSet<string>(); BindCore(section242, ref temp244, defaultValueIfNotFound: false, binderOptions); instance.FilteredCategories = temp244; } if (AsConfigWithChildren(configuration.GetSection("FilteredLevels")) is IConfigurationSection section245) { ISet<LogLevel>? temp247 = instance.FilteredLevels; temp247 ??= (ISet<LogLevel>)new HashSet<LogLevel>(); BindCore(section245, ref temp247, defaultValueIfNotFound: false, binderOptions); instance.FilteredLevels = temp247; } if (AsConfigWithChildren(configuration.GetSection("CustomFilter")) is IConfigurationSection section248) { Func<FakeLogRecord, bool>? temp250 = instance.CustomFilter; if (temp250 is not null) { BindCore(section248, ref temp250, defaultValueIfNotFound: false, binderOptions); instance.CustomFilter = temp250; } else { throw new InvalidOperationException("Cannot create instance of type 'System.Func<FakeLogRecord, bool>' because one or more parameters cannot be bound to. Constructor parameters must have corresponding properties. Fields are not supported. Missing properties are: 'object'"); } } if (configuration["CollectRecordsForDisabledLogLevels"] is string value251) { instance.CollectRecordsForDisabledLogLevels = ParseBool(value251, () => configuration.GetSection("CollectRecordsForDisabledLogLevels").Path); } else if (defaultValueIfNotFound) { instance.CollectRecordsForDisabledLogLevels = default; } if (AsConfigWithChildren(configuration.GetSection("TimeProvider")) is IConfigurationSection section252) { TimeProvider? temp254 = instance.TimeProvider; if (temp254 is not null) { BindCore(section252, ref temp254, defaultValueIfNotFound: false, binderOptions); instance.TimeProvider = temp254; } else { throw new InvalidOperationException("Cannot create instance of type 'System.TimeProvider' because it is missing a public instance constructor."); } } if (AsConfigWithChildren(configuration.GetSection("OutputSink")) is IConfigurationSection section255) { Action<string>? temp257 = instance.OutputSink; if (temp257 is not null) { BindCore(section255, ref temp257, defaultValueIfNotFound: false, binderOptions); instance.OutputSink = temp257; } else { throw new InvalidOperationException("Cannot create instance of type 'System.Action<string>' because one or more parameters cannot be bound to. Constructor parameters must have corresponding properties. Fields are not supported. Missing properties are: 'object'"); } } if (AsConfigWithChildren(configuration.GetSection("OutputFormatter")) is IConfigurationSection section258) { Func<FakeLogRecord, string>? temp260 = instance.OutputFormatter; if (temp260 is not null) { BindCore(section258, ref temp260, defaultValueIfNotFound: false, binderOptions); instance.OutputFormatter = temp260; } else { throw new InvalidOperationException("Cannot create instance of type 'System.Func<FakeLogRecord, string>' because one or more parameters cannot be bound to. Constructor parameters must have corresponding properties. Fields are not supported. Missing properties are: 'object'"); } } } public static CustomAttributeTypedArgument InitializeCustomAttributeTypedArgument(IConfiguration configuration, BinderOptions? binderOptions) { if (configuration["Value"] is not object value) { throw new InvalidOperationException("Cannot create instance of type 'System.Reflection.CustomAttributeTypedArgument' because parameter 'value' has no matching config. Each parameter in the constructor that does not have a default value must have a corresponding config entry."); } return new CustomAttributeTypedArgument(value); } /// <summary>If required by the binder options, validates that there are no unknown keys in the input configuration object.</summary> public static void ValidateConfigurationKeys(Type type, Lazy<HashSet<string>> keys, IConfiguration configuration, BinderOptions? binderOptions) { if (binderOptions?.ErrorOnUnknownConfiguration is true) { List<string>? temp = null; foreach (IConfigurationSection section in configuration.GetChildren()) { if (!keys.Value.Contains(section.Key)) { (temp ??= new List<string>()).Add($"'{section.Key}'"); } } if (temp is not null) { throw new InvalidOperationException($"'ErrorOnUnknownConfiguration' was set on the provided BinderOptions, but the following properties were not found on the instance of {type}: {string.Join(", ", temp)}"); } } } public static bool HasValueOrChildren(IConfiguration configuration) { if ((configuration as IConfigurationSection)?.Value is not null) { return true; } return AsConfigWithChildren(configuration) is not null; } public static IConfiguration? AsConfigWithChildren(IConfiguration configuration) { foreach (IConfigurationSection _ in configuration.GetChildren()) { return configuration; } return null; } public static BinderOptions? GetBinderOptions(Action<BinderOptions>? configureOptions) { if (configureOptions is null) { return null; } BinderOptions binderOptions = new(); configureOptions(binderOptions); if (binderOptions.BindNonPublicProperties) { throw new NotSupportedException($"The configuration binding source generator does not support 'BinderOptions.BindNonPublicProperties'."); } return binderOptions; } public static T ParseEnum<T>(string value, Func<string?> getPath) where T : struct { try { #if NETFRAMEWORK || NETSTANDARD2_0 return (T)Enum.Parse(typeof(T), value, ignoreCase: true); #else return Enum.Parse<T>(value, ignoreCase: true); #endif } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(T)}'.", exception); } } public static bool ParseBool(string value, Func<string?> getPath) { try { return bool.Parse(value); } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(bool)}'.", exception); } } public static int ParseInt(string value, Func<string?> getPath) { try { return int.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture); } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(int)}'.", exception); } } public static Guid ParseGuid(string value, Func<string?> getPath) { try { return Guid.Parse(value); } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(Guid)}'.", exception); } } public static long ParseLong(string value, Func<string?> getPath) { try { return long.Parse(value, NumberStyles.Integer, CultureInfo.InvariantCulture); } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(long)}'.", exception); } } public static TimeSpan ParseTimeSpan(string value, Func<string?> getPath) { try { return TimeSpan.Parse(value, CultureInfo.InvariantCulture); } catch (Exception exception) { throw new InvalidOperationException($"Failed to convert configuration value at '{getPath()}' to type '{typeof(TimeSpan)}'.", exception); } } #endregion Core binding extensions. } }