Skip to content

Fixer/Analyzer: Remove UseEndpoints() and hoist route registrations top level to WebApplication #35759

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

Closed
Tracked by #36637
davidfowl opened this issue Aug 26, 2021 · 2 comments · Fixed by #42937
Closed
Tracked by #36637
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-hosting old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Priority:2 Work that is important, but not critical for the release

Comments

@davidfowl
Copy link
Member

davidfowl commented Aug 26, 2021

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).

@davidfowl davidfowl changed the title Analyzer/Fixer: Remove UseEndpoints() and hoist route registrations top level to WebApplication Fixer/Analyzer: Remove UseEndpoints() and hoist route registrations top level to WebApplication Aug 26, 2021
@javiercn javiercn added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels feature-minimal-hosting labels Aug 26, 2021
@BrennanConroy
Copy link
Member

UseEndpoints fixer should only apply if it's the last middleware called

@rafikiassumani-msft rafikiassumani-msft added this to the Backlog milestone Aug 31, 2021
@ghost
Copy link

ghost commented Aug 31, 2021

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@rafikiassumani-msft rafikiassumani-msft added Cost:M Priority:2 Work that is important, but not critical for the release labels Jan 12, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 8, 2022
@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-hosting old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Priority:2 Work that is important, but not critical for the release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants