Skip to content

Annotate top-level methods that aren't native AOT friendly as such so that analyzers produce warnings at design time #47521

@DamianEdwards

Description

@DamianEdwards

While we have issues tracking specific work to annotate the rest of the ASP.NET Core API surface area for trim and native AOT friendliness, as it is right now, enabling trimming or native AOT publish in an ASP.NET Core project often doesn't result in many (if any) warnings appearing during design-time or compile-time.

To improve the experience right now (e.g. in preview.4), we should consider annotating the top-level entry methods to the various large sub-systems of ASP.NET Core to that if they're called in apps configured for trimming or native AOT publish, the user gets appropriately warned that those sub-systems aren't supported when aggressively trimmed.

E.g. calling the following methods should trigger a warning as the various sub-systems they relate to aren't currently supported with full trimming and/or native AOT publish:

builder.Services.AddAuthentication(); // Authentication
builder.Services.AddRazorPages(); // Razor Pages
builder.Services.AddControllers(); // MVC Controllers
builder.Services.AddControllersWithViews(); // MVC
builder.Services.AddServerSideBlazor(); // Blazor Server
builder.Services.AddRazorComponents(); // Blazor United
builder.Services.AddSignalR(); // SignalR
builder.Services.AddSession(); // Session
builder.Services.AddRequestLocalization(o => { }); // Request localization

Should we consider doing the same in EF Core?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions