Add ability to cleanup Configuration related disposables
See original GitHub issueFrom @JanEggers on Friday, 28 September 2018 06:43:27
Im having issues in a Unittests that complains that not all threads are ended when the unittest is completed.
Turns out this is due to using this:
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile(settingsPath, optional: true, reloadOnChange: true)
.Build();
the reloadable json file generates Filewatchers that hang in a sleep if the test is ended.
the core problem is that there PhsicalFileProvider is disposable but currently I have to do something like this to clean it up:
foreach (var provider in config.Providers.OfType<JsonConfigurationProvider>())
{
if (provider.Source.FileProvider is PhysicalFileProvider pfp)
{
pfp.Dispose();
}
}
I see two options here to improve the situation:
-
make IConfigurationRoot and all related classes disposable so I can just call config.Dispose();
-
resolve providers from DI so DI takes care of disposing the resources that require to do so.
maybe related to #3110
Copied from original issue: aspnet/Home#3564
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Implement a Dispose method
This helps ensure that the referenced disposable types are given the opportunity to deterministically perform cleanup through the Dispose ...
Read more >Dependency injection guidelines - .NET
The container is responsible for cleanup of types it creates, and calls Dispose on IDisposable instances. Services resolved from the ...
Read more >HYGEN™ 18" Disposable Microfiber Pad
Ideal for dusting and damp cleaning of surfaces; High-quality microfiber penetrates deeper for a superior clean; Stripe design is made of polyester to...
Read more >ProMist® MAX Microfiber Spray Mop
The ProMist R MAX's microfiber mop head removes over 99% of bacteria with just water* or your favorite cleaning solution. Features. • Reusable,...
Read more >Configure a Golden Image Virtual Machine
For View Composer linked clones, if you plan to configure disposable data disks when you create linked-clone machines, remove default user ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes we need to support disposable configuration providers which is viral so the root will need to support it as well.
Closing based on the previous comment as part of backlog clean-up.