Skip to content

Conversation

@adamsitnik
Copy link
Member

An alternative for #100641 to fix #95745. It requires new public APIs and is a breaking change. Please see my comments

@ghost
Copy link

ghost commented Apr 4, 2024

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.


if (Source.OwnsFileProvider)
{
(Source.FileProvider as IDisposable)?.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

Provider.Dispose does not need to dispose the source anymore, the caller can access ConfigurationSource and do it when needed


foreach (IConfigurationSource source in _sources)
{
(source as IDisposable)?.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

the manager has all the sources, so it can just iterate over them and dispose when possible

// dispose providers and the sources
foreach (IConfigurationProvider provider in _providers)
{
(provider.ConfigurationSource as IDisposable)?.Dispose();
Copy link
Member Author

Choose a reason for hiding this comment

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

the root has no reference sources, but it can now access provider.ConfigurationSource and dispose when possible

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong disposal of FileConfigurationSource.FileProvider by FileConfigurationProvider.Dispose() on a modification of ConfigurationManager.Sources

1 participant