Closed
Description
With the new hosting model, it's possible to register routes top level instead of using UseEndpoints. To help customer learn about this, we can have an fixer that can hoist the route registrations to hang off WebApplicatin:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", () => "Hello World!");
});
We would suggest this:
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseRouting();
app.MapGet("/", () => "Hello World!");
app.Run();
Stretch goal is to also remove UseRouting but we would need to only remove it if it wasn't intentionally put top level (like set to re-run middleware).