question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ability to cleanup Configuration related disposables

See original GitHub issue

From @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:

  1. make IConfigurationRoot and all related classes disposable so I can just call config.Dispose();

  2. 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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
davidfowlcommented, Dec 21, 2018

Yes we need to support disposable configuration providers which is viral so the root will need to support it as well.

0reactions
analogrelaycommented, Mar 12, 2020

Closing based on the previous comment as part of backlog clean-up.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found