Skip to content

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

Merged
anhthidao merged 10 commits into
mainfrom
WebApplicationBuilderAnalyzers
Jun 29, 2022
Merged

Implementing analyzer to prefer WebApplicationBuilder.Configuration over Configure methods#42351
anhthidao merged 10 commits into
mainfrom
WebApplicationBuilderAnalyzers

Conversation

@anhthidao
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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.

Comment thread src/Http/samples/MinimalSample/Program.cs Outdated
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