[release/8.0-staging] Revert "FileConfigurationProvider.Dispose should dispose FileProvider when it owns it" #101610
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #101609 to release/8.0-staging
/cc @adamsitnik
Customer Impact
ConfigurationManager
and modifying itsSources
getObjectDisposedException
.Regression
Testing
To ensure that the bug is not introduced again, an automated test was added, and it's passing.
Risk
Medium: this PR reverts a PR (#86455) that introduced this particular bug. But that PR has solved a resource leak (#86146), so by reverting it we re-introduce the leak. FWIW the leak was reported only by one user from tests and had zero upvotes (at the moment of writing this description) and it is unlikely to affect many applications (most apps create one builder per app lifetime). The leak was not a regression from .NET 6 or any previous release (the current APIs don't really solve the problem of ownership and disposal, example: #86456).
It's possible to workaround (#95745 (comment)) the bug, but only in scenario, where the user owns the code that calls the configuration method. If they don't (example: call R9 that calls this method), it's impossible.
IMO the proper fix is going to require new public APIs (sample approach: #100642) or breaking changes.
Because of that I've provided an ugly fix: #100641, but it got rejected.