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

Fixer/Analyzer: Suggest switching builder.Host.ConfigureAppConfiguration and builder.Host.ConfigureHostConfiguration to use the builder.Configuration property directly #35815

Closed
Tracked by #36637
davidfowl opened this issue Aug 27, 2021 · 1 comment · Fixed by #42351
Assignees
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 Priority:2 Work that is important, but not critical for the release

Comments

@davidfowl
Copy link
Member

davidfowl commented Aug 27, 2021

The WebApplicationBuilder has top level properties to remove some of the callback noise and we should push developers towards using those properties in their code since they are the moral equivalent to the Configure* callbacks:

var builder = WebApplication.CreateBuilder(args);

builder.Host.ConfigureAppConfiguration(builder =>
{
    builder.AddJsonFile("foo.json", optional: true);
});

// OR

builder.Host.ConfigureHostConfiguration(builder =>
{
    builder.AddJsonFile("foo.json", optional: true);
});

// OR

builder.WebHost.ConfigureAppConfiguration(builder =>
{
    builder.AddJsonFile("foo.json", optional: true);
});

Should be rewritten to:

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddJsonFile("foo.json", optional: true);
@davidfowl davidfowl changed the title Fixer/Analyzer: Suggest switching builder.ConfigureAppConfiguration and builder.ConfigureHostConfiguration to use the Configuration property directly Fixer/Analyzer: Suggest switching builder.Host.ConfigureAppConfiguration and builder.Host.ConfigureHostConfiguration to use the Configuration property directly Aug 27, 2021
@davidfowl davidfowl changed the title Fixer/Analyzer: Suggest switching builder.Host.ConfigureAppConfiguration and builder.Host.ConfigureHostConfiguration to use the Configuration property directly Fixer/Analyzer: Suggest switching builder.Host.ConfigureAppConfiguration and builder.Host.ConfigureHostConfiguration to use the builder.Configuration property directly Aug 27, 2021
@davidfowl davidfowl added old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels and removed area-runtime labels Aug 27, 2021
@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 analyzer Indicates an issue which is related to analyzer experience Cost:M Priority:2 Work that is important, but not critical for the release labels Jan 6, 2022
anhthidao pushed a commit to anhthidao/aspnetcore that referenced this issue Jul 8, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Jul 29, 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 Priority:2 Work that is important, but not critical for the release
Projects
None yet
4 participants