Skip to content

[AOT] Remove AOT warning suppressions #46015

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/DataProtection/Extensions/src/DataProtectionProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ internal static IDataProtectionProvider CreateProvider(
setupAction(builder);

// extract the provider instance from the service collection
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
return serviceCollection.BuildServiceProvider().GetRequiredService<IDataProtectionProvider>();
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}
}
3 changes: 0 additions & 3 deletions src/DefaultBuilder/src/WebApplicationBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ internal WebApplicationBuilder(WebApplicationOptions options, Action<IHostBuilde

configuration.AddEnvironmentVariables(prefix: "ASPNETCORE_");

// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
_hostApplicationBuilder = new HostApplicationBuilder(new HostApplicationBuilderSettings
{
Args = options.Args,
Expand All @@ -43,7 +41,6 @@ internal WebApplicationBuilder(WebApplicationOptions options, Action<IHostBuilde
ContentRootPath = options.ContentRootPath,
Configuration = configuration,
});
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.

// Set WebRootPath if necessary
if (options.WebRootPath is not null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,7 @@ public IWebHostBuilder UseDefaultServiceProvider(Action<WebHostBuilderContext, S
var webHostBuilderContext = GetWebHostBuilderContext(context);
var options = new ServiceProviderOptions();
configure(webHostBuilderContext, options);
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
return new DefaultServiceProviderFactory(options);
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
});

return this;
Expand Down
3 changes: 0 additions & 3 deletions src/Hosting/Hosting/src/Internal/StartupLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,7 @@ IServiceProvider ConfigureServicesWithContainerConfiguration(IServiceCollection
applicationServiceProvider = serviceProviderFactory.CreateServiceProvider(builder);
}

// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
return applicationServiceProvider ?? services.BuildServiceProvider();
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/Hosting/Hosting/src/Internal/WebHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ public void Initialize()
// EnsureApplicationServices may have failed due to a missing or throwing Startup class.
if (_applicationServices == null)
{
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
_applicationServices = _applicationServiceCollection.BuildServiceProvider();
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}

if (!_options.CaptureStartupErrors)
Expand Down
3 changes: 0 additions & 3 deletions src/Hosting/Hosting/src/Startup/StartupBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ public virtual void ConfigureServices(IServiceCollection services)
/// <returns>The <see cref="IServiceProvider"/>.</returns>
public virtual IServiceProvider CreateServiceProvider(IServiceCollection services)
{
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
return services.BuildServiceProvider();
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
}
}

Expand Down
3 changes: 0 additions & 3 deletions src/Hosting/Hosting/src/WebHostBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,7 @@ public IWebHost Build()

static IServiceProvider GetProviderFromFactory(IServiceCollection collection)
{
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
var provider = collection.BuildServiceProvider();
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
var factory = provider.GetService<IServiceProviderFactory<IServiceCollection>>();

if (factory != null && factory is not DefaultServiceProviderFactory)
Expand Down
3 changes: 0 additions & 3 deletions src/Hosting/Hosting/src/WebHostBuilderExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ public static IWebHostBuilder UseDefaultServiceProvider(this IWebHostBuilder hos
{
var options = new ServiceProviderOptions();
configure(context, options);
// TODO: Remove when DI no longer has RequiresDynamicCodeAttribute https://github.com/dotnet/runtime/pull/79425
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
services.Replace(ServiceDescriptor.Singleton<IServiceProviderFactory<IServiceCollection>>(new DefaultServiceProviderFactory(options)));
#pragma warning restore IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
});
}

Expand Down