You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The .NET ServiceProvider can dispose services with managed resources according to the Disposal of Services docs, but this only works if the service provider instance is also disposed properly. However, the MicrosoftDependencyResolver class:
Meets the same problem.
When calling the Locater.Current.GetService to get the service, it does not call something like ServiceProviderEngineScope.CaptureDisposable to check if the service is IDisposable, so it is not disposed after the scope is disposed.
Describe the bug
The .NET ServiceProvider can dispose services with managed resources according to the Disposal of Services docs, but this only works if the service provider instance is also disposed properly. However, the MicrosoftDependencyResolver class:
splat/src/Splat.Microsoft.Extensions.DependencyInjection/MicrosoftDependencyResolver.cs
Lines 253 to 265 in a7aae8b
never disposes the container. This affects services that need to do work to clean up resources when they're disposed.
Steps To Reproduce
Provide the steps to reproduce the behavior:
ServiceCollection.UseMicrosoftDependencyResolver
on your service collectionExpected behavior
I expect that the service provider should be disposed when the container is disposed
Screenshots
If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
Additional context
When I use a custom class that disposes the ServiceProvider in use and also manually call:
The service is disposed correctly.
The text was updated successfully, but these errors were encountered: