Fix closure allocation in scope DisposeAsync (dotnet/Extensions#3024)
authorJames Newton-King <james@newtonking.com>
Wed, 26 Feb 2020 03:58:45 +0000 (16:58 +1300)
committerGitHub <noreply@github.com>
Wed, 26 Feb 2020 03:58:45 +0000 (16:58 +1300)
Commit migrated from https://github.com/dotnet/Extensions/commit/b190507b207f6d13f6dc7b00b33f8ca44ea3404b

src/libraries/Microsoft.Extensions.DependencyInjection/src/ServiceLookup/ServiceProviderEngineScope.cs

index 07ee884..45d5ec6 100644 (file)
@@ -98,7 +98,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
                             var vt = asyncDisposable.DisposeAsync();
                             if (!vt.IsCompletedSuccessfully)
                             {
-                                return Await(i, vt);
+                                return Await(i, vt, toDispose);
                             }
 
                             // If its a IValueTaskSource backed ValueTask,
@@ -119,7 +119,7 @@ namespace Microsoft.Extensions.DependencyInjection.ServiceLookup
 
             return default;
 
-            async ValueTask Await(int i, ValueTask vt)
+            static async ValueTask Await(int i, ValueTask vt, List<object> toDispose)
             {
                 await vt;