-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Load IConfigurationProviders once in WebApplicationBuilder #37039
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
Conversation
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/aspnetcore/actions/runs/1280231592 |
I think this change might be too braking. Nothing looks at sources but lots of things look at providers. Having them wrapped is pretty breaking. For example GetDebugView is completely broken by this change |
GetDebugView() is fixed pretty trivially by forwarding ToString() which I just did in this commit. Do you have examples of any code looking at the actual type of the providers @davidfowl? |
I generally don't feel comfortable with wrapping providers because they are exposed on IConfigurationRoot. I'm super paranoid about doing anything funky that changes the behavior after the service provider is built. There's too much code running not to break stuff |
5a0b4c8
to
3440cd3
Compare
3440cd3
to
a5c042a
Compare
src/DefaultBuilder/test/Microsoft.AspNetCore.Tests/WebApplicationTests.cs
Outdated
Show resolved
Hide resolved
src/DefaultBuilder/test/Microsoft.AspNetCore.Tests/WebApplicationTests.cs
Outdated
Show resolved
Hide resolved
a5c042a
to
1aed659
Compare
399e5d4
to
7fd31c1
Compare
@dotnet/minimal-apis I think this is ready for another review. I've updated the approach to reverse the direction we're chaining configuration. Before, we chained the HostBuilder's IConfiguration to the WebApplicationBuilder's ConfigurationManager after the host was built. Now we chain the ConfigurationManager to the HostBuilders IConfigurationBuilder when we start building the host. This also makes the ConfigurationManager the IConfiguration that's resolved from DI rather than the HostBuilder's IConfiguration. This forces us to copy IConfigurationProviders in the opposite direction we did before, and we still have to wrap these providers to prevent double loads. However, we expect this will mostly be test providers, so not preserving the provider types should be less of an issue. |
8def990
to
cbac727
Compare
cbac727
to
e76ef50
Compare
This updates
WebApplicationBuilder
to only loadIConfigurationProvider
s once. Before this change, they would be loaded twice. Once byConfigurationmanager
and then again by the inner generic host'sConfigurationBuilder
.This causes problems with
StreamConfigurationSource
s like the one used bybuilder.Configuration.AddJsonStream(jsonStream)
throwing errors similar to the following:Fixes #37030
Fixes #37046