Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Certain APIs related to Microsoft.Extensions.Configuration that were marked as RequiresUnreferencedCodeAttribute were also annotated to preserve at least some of the necessary members when trimming. This made the API partially work when trimming, while still generating trimming warnings. The annotations are now removed completely. Users are encouraged to migrate to the source generator that works reliably with trimming.
Version introduced
.NET 10 Preview 6
Previous behavior
Previously, the affected APIs worked with some limited use cases while generating trimming warnings at publish time. These APIs were annotated to preserve at least some of the necessary members when trimming, making the API partially functional in trimmed scenarios.
New behavior
Starting in .NET 10, the affected APIs now work with even more limited use cases while still generating trimming warnings at publish time.
Type of breaking change
This change can affect binary compatibility.
Reason for change
The annotations were removed as part of an effort to remove uses of DynamicallyAccessedMemberTypes.All from the product.
Recommended action
Use the binding configuration source generator, which works reliably with trimming and provides a trim-safe alternative to these APIs.
Affected APIs
- Microsoft.Extensions.Configuration.ConfigurationBinder.Get(IConfiguration, Type, Action<BinderOptions>)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue(IConfiguration, Type, String)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue(IConfiguration, Type, String, Object)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue<T>(IConfiguration, String)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.GetValue<T>(IConfiguration, String, T)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.Get<T>(IConfiguration)
 - Microsoft.Extensions.Configuration.ConfigurationBinder.Get<T>(IConfiguration, Action<BinderOptions>)
 - Microsoft.Extensions.Logging.Configuration.LoggerProviderOptions.RegisterProviderOptions<TOptions,TProvider>(IServiceCollection)
 - Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsoleFormatter<TFormatter,TOptions>(ILoggingBuilder)
 - Microsoft.Extensions.Logging.ConsoleLoggerExtensions.AddConsoleFormatter<TFormatter,TOptions>(ILoggingBuilder, Action<TOptions>)
 - Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.BindConfiguration<TOptions>(OptionsBuilder<TOptions>, String, Action<BinderOptions>)
 - Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.Bind<TOptions>(OptionsBuilder<TOptions>, IConfiguration)
 - Microsoft.Extensions.DependencyInjection.OptionsBuilderConfigurationExtensions.Bind<TOptions>(OptionsBuilder<TOptions>, IConfiguration, Action<BinderOptions>)
 - Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure
 - Microsoft.Extensions.Options.ConfigureFromConfigurationOptions<TOptions>
 - Microsoft.Extensions.Options.NamedConfigureFromConfigurationOptions<TOptions>