Should Container implement IDisposable in a future version

Coordinator
Aug 2, 2014 at 3:32 PM
Edited Apr 17, 2015 at 2:54 PM
I'm wondering whether it would be good to let the container implement IDisposable to allow the container to dispose created singletons.

Some arguments against this:
  • a container instance would typically live for the duration of the application. When the application quits, finalizers will run automatically to clean up unmanaged resources.
  • It would be uncommon to have singletons that are disposable; they are much likely to be registered with a ScopedLifestyle.
Coordinator
Aug 2, 2014 at 7:21 PM
This question dovetails to where this issue/discussion has stalled:
He who owns the type is responsible for disposing it.
My stance is the same for both items - the Container should implement IDisposable and on Dispose() should clean up any disposable instances that it owns on the common understanding/assumption that the Container owns and governs these instances.

If the developer doesn't care they can skip calling Dispose() on the Container ....
Marked as answer by dot_NET_Junkie on 8/11/2014 at 12:10 PM
Coordinator
Aug 2, 2014 at 10:07 PM
Good point. I will add this as work item for v3.
Coordinator
Aug 2, 2014 at 10:09 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.