AutofacServiceProvider implementing IDisposable revisited
See original GitHub issueI know in #3 it was clear that implementing IDisposable
for the AutofacServiceProvider
was not desired. Now that the generic hosting is available in .net core 2.1, I’d kindly ask that you rethink this. I’d like to be able to use Autofac to register all my dependencies in a console application, and host it with the generic hosting classes. Unfortunately, since the AutofacServiceProvider
doesn’t implement IDisposable
, the console host has a deadlock when I try to terminate my process with CTRL-C
.
I think Microsoft’s implementation is mostly to blame for this situation, but adding an option to dispose the container that is built by the AutofacServiceProviderFactory
would alleviate it for me. I’d obviously be more than happy to submit a pr with this change, but I didn’t want to do so if you think this is still a bad idea.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:15 (8 by maintainers)
I added a bunch of new “assumed behavior tests” to verify what the Microsoft container is currently doing and ensure our
AutofacServiceProvider
and all are doing the same thing. Most of these are around disposal and assumptions around when/how things get disposed.I think I have it nailed, so I’ll push this out as a 4.3.0 shortly.
OK, 4.3.0 is out. Give it a shot and let me know what you think. I’m going to be out until next week so if you find something that needs to be fixed… I can approve PRs from my phone, but actual fixes may have to wait. Help resolving totally broken things is always welcome. 😉