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

Implementing analyzer to prefer WebApplicationBuilder.Configuration over Configure methods #42351

Merged
merged 10 commits into from
Jun 29, 2022

Conversation

anhthidao
Copy link
Contributor

Analyzer: Suggest replacing builder.Host.ConfigureAppConfiguration/builder.Host.ConfigureHostConfiguration/builder.WebHost.ConfigureAppConfiguration with builder.Configuration directly

Description

Add analyzers that warns when using ConfigureAppConfiguration/ConfigureHostConfiguration on WebApplicationBuilder.Host/WebApplicationBuilder.WebHost. Suggest switching to builder.Configuration.

Fixes #35815

@dnfadmin
Copy link

dnfadmin commented Jun 22, 2022

CLA assistant check
All CLA requirements met.

@anhthidao anhthidao changed the title Web application builder analyzers Analyzer: Suggest replacing builder.Host.ConfigureAppConfiguration/builder.Host.ConfigureHostConfiguration/builder.WebHost.ConfigureAppConfiguration with builder.Configuration directly Jun 22, 2022
@anhthidao anhthidao changed the title Analyzer: Suggest replacing builder.Host.ConfigureAppConfiguration/builder.Host.ConfigureHostConfiguration/builder.WebHost.ConfigureAppConfiguration with builder.Configuration directly Implementing analyzer to prefer WebApplicationBuilder.Configuration over Configure methods Jun 22, 2022
"Do not use builder.Host.ConfigureAppConfiguration or builder.Host.ConfigureHostConfiguration",
"Replace with builder.Configuration",
"Usage",
DiagnosticSeverity.Error,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make this one a warning like #42354 and #42356 as this doesn't functionally break an application if it's used.

anhthidao and others added 4 commits June 23, 2022 10:16
Co-authored-by: Safia Abdalla <safia@microsoft.com>
… and message. Changing the WebApplicationBuilderAnalyzers class so that the method name can be passed into the diagnostic message
… and message. Changing the WebApplicationBuilderAnalyzers class so that the method name can be passed into the diagnostic message
@Pilchie Pilchie 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 Jun 25, 2022
@anhthidao anhthidao merged commit 621326b into main Jun 29, 2022
@anhthidao anhthidao deleted the WebApplicationBuilderAnalyzers branch June 29, 2022 16:06
@ghost ghost added this to the 7.0-preview7 milestone Jun 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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
5 participants