You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After installing Visual Studio 2026 and .NET10 I noticed the following behavior:
I’m building an AOT project that uses DI. When I build and publish the project, the IL trimming/AOT warnings are not shown in Visual Studio — neither in the Build Output nor in the Error List (Build + IntelliSense).
Code snippet:
LogManager.Setup().SetupExtensions(e => e.RegisterTarget<EventLogTarget>());
var config = new ConfigurationBuilder()
.SetBasePath(AppContext.BaseDirectory)
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.Build() ??
throw new InvalidOperationException("Cannot get configuration.");
var services = new ServiceCollection();
services.AddSingleton<IConfiguration>(config);
services.Configure<LicensingOptions>(config.GetSection(nameof(LicensingOptions)));
services.Configure<SettingsServiceOptions>(config.GetSection(nameof(SettingsServiceOptions)));
However, when I run dotnet format, those warnings do appear:
...\Program.cs(29,9): warning IL2026: Using member 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. TOptions's dependent types may have their members trimmed. Ensure all required members are preserved.
...\Program.cs(29,9): warning IL3050: Using member 'Microsoft.Extensions.DependencyInjection.OptionsConfigurationServiceCollectionExtensions.Configure<TOptions>(IServiceCollection, IConfiguration)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Binding strongly typed objects to configuration values may require generating dynamic code at runtime.
Before upgrading from .NET 8 to .NET 10 and from VS 2022 to VS 2026, these warnings were displayed both during the build / publish and inside the Visual Studio Error List.
I think that in this specific case I can ignore the warnings, because I use my own classes in this project for Configure(). I’m mainly curious whether anyone else has seen this behavior and whether this might be a Visual Studio or SDK bug.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
After installing Visual Studio 2026 and .NET10 I noticed the following behavior:
I’m building an AOT project that uses DI. When I build and publish the project, the IL trimming/AOT warnings are not shown in Visual Studio — neither in the Build Output nor in the Error List (Build + IntelliSense).
Code snippet:
However, when I run dotnet format, those warnings do appear:
Before upgrading from .NET 8 to .NET 10 and from VS 2022 to VS 2026, these warnings were displayed both during the build / publish and inside the Visual Studio Error List.
I think that in this specific case I can ignore the warnings, because I use my own classes in this project for Configure(). I’m mainly curious whether anyone else has seen this behavior and whether this might be a Visual Studio or SDK bug.
Beta Was this translation helpful? Give feedback.
All reactions