From 9bb9c2f13d8ee1afb5ea3bd06bf4200860afe6cb Mon Sep 17 00:00:00 2001 From: dotnetjunkie Date: Sun, 25 Oct 2020 11:52:56 +0100 Subject: [PATCH] Bug fix: Registration of Singletons implementing IAsyncDisposable caused exception on shutdown when options.DisposeContainerWithServiceProvider was set to true. Fixes #4 --- .../SimpleInjector.Integration.ServiceCollection.csproj | 2 +- .../SimpleInjectorServiceCollectionExtensions.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/SimpleInjector.Integration.ServiceCollection/SimpleInjector.Integration.ServiceCollection.csproj b/src/SimpleInjector.Integration.ServiceCollection/SimpleInjector.Integration.ServiceCollection.csproj index a3c790c..8e8e504 100644 --- a/src/SimpleInjector.Integration.ServiceCollection/SimpleInjector.Integration.ServiceCollection.csproj +++ b/src/SimpleInjector.Integration.ServiceCollection/SimpleInjector.Integration.ServiceCollection.csproj @@ -5,7 +5,7 @@ Simple Injector IServiceCollection Integration en-US - 5.0.1 + 5.0.2 https://github.com/simpleinjector/SimpleInjector.Integration.AspNetCore/releases/tag/5.0.0 5.0.0.0 Simple Injector Contributors diff --git a/src/SimpleInjector.Integration.ServiceCollection/SimpleInjectorServiceCollectionExtensions.cs b/src/SimpleInjector.Integration.ServiceCollection/SimpleInjectorServiceCollectionExtensions.cs index 924ac31..8859df4 100644 --- a/src/SimpleInjector.Integration.ServiceCollection/SimpleInjectorServiceCollectionExtensions.cs +++ b/src/SimpleInjector.Integration.ServiceCollection/SimpleInjectorServiceCollectionExtensions.cs @@ -648,13 +648,15 @@ private sealed class NullSimpleInjectorHostedService : IHostedService public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; } - private sealed class ContainerDisposeWrapper : IDisposable + private sealed class ContainerDisposeWrapper : IDisposable, IAsyncDisposable { private readonly Container container; public ContainerDisposeWrapper(Container container) => this.container = container; public void Dispose() => this.container.Dispose(); + + public ValueTask DisposeAsync() => this.container.DisposeAsync(); } } } \ No newline at end of file