FileConfigurationProvider.Dispose should dispose FileProvider when it owns it#86455
Merged
adamsitnik merged 1 commit intodotnet:mainfrom May 19, 2023
Merged
FileConfigurationProvider.Dispose should dispose FileProvider when it owns it#86455adamsitnik merged 1 commit intodotnet:mainfrom
adamsitnik merged 1 commit intodotnet:mainfrom
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsThe app that I've used for leak detection and confirmation of the fix: Details<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Xml" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="settings.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project><?xml version="1.0" encoding="utf-8" ?>
<configuration>
<MySettings>
<SomeSetting>Test</SomeSetting>
<Another>true</Another>
</MySettings>
</configuration>using Microsoft.Extensions.Configuration;
namespace ConfigLeak
{
internal class Program
{
static void Main()
{
const int iterations = 2;
Console.WriteLine("Press a key");
Console.ReadKey();
for (var i = 0; i < iterations; i++)
{
Test();
Console.WriteLine("Take a snapshot and press a key");
Console.ReadKey();
}
}
static void Test()
{
var config = new ConfigurationBuilder().AddXmlFile("settings.xml", false, true).Build();
(config as IDisposable)?.Dispose();
}
}
}Before: After: The only tricky thing is that the fixes #86146
|
tarekgh
approved these changes
May 18, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.


The app that I've used for leak detection and confirmation of the fix:
Details
Before:
After:
The only tricky thing is that the
FileProvidercan be also provided by the user, so we can not just always dispose it.fixes #86146