Skip to content
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

Analyzer: Warn that UseStartup/Configure and ConfigureWebHost isn't supported on WebApplicationBuilder #35814

Closed
Tracked by #36637
davidfowl opened this issue Aug 27, 2021 · 3 comments · Fixed by #35884
Labels
analyzer Indicates an issue which is related to analyzer experience 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

Comments

@davidfowl
Copy link
Member

Today we throw in the following situations:

var builder = WebApplication.CreateBuilder(args);
builder.Host.ConfigureWebHost(builder =>
{

});
var builder = WebApplication.CreateBuilder(args);

// These should all fail with errors as well
builder.WebHost.UseStartup<Startup>();
builder.WebHost.UseStartup(typeof(Startup));
builder.WebHost.UseStartup("Startup");
builder.WebHost.UseStartup(context => new Startup());
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.Configure(app =>
{

});

We should add an analyzer that detects these patterns that warns/fails and tells the user to configure the pipeline on WebApplication itself.

@davidfowl davidfowl added the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Aug 27, 2021
@martincostello
Copy link
Member

@davidfowl If you'd like to assign this one to me I'll see if I can get it working.

1 similar comment
@martincostello

This comment has been minimized.

@martincostello
Copy link
Member

First analyzers attempt in #35884 - be kind 😄

@rafikiassumani-msft rafikiassumani-msft added this to the 6.0-rc2 milestone Sep 1, 2021
@captainsafia captainsafia removed their assignment Sep 13, 2021
@pranavkm pranavkm removed their assignment Sep 24, 2021
martincostello added a commit to martincostello/aspnetcore that referenced this issue Nov 6, 2021
Add analyzers that warn on incorrect usage of UseStartup(), Configure()
and ConfigureWebHost() when using WebApplicationBuilder.
Resolves dotnet#35814.
@rafikiassumani-msft rafikiassumani-msft added the analyzer Indicates an issue which is related to analyzer experience label Jan 6, 2022
captainsafia pushed a commit that referenced this issue Jan 12, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Add analyzers that warn on incorrect usage of UseStartup(), Configure()
and ConfigureWebHost() when using WebApplicationBuilder.
Resolves #35814.
@ghost ghost locked as resolved and limited conversation to collaborators Feb 11, 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
analyzer Indicates an issue which is related to analyzer experience 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
Projects
None yet
7 participants