From 39b4f6fe53d1524fb64056fbdc3e2b5bbf72a4ee Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 24 Mar 2016 15:41:16 -0700 Subject: [PATCH] An `ObjectPoolProvider` is always registered - react to aspnet/Hosting/pull#673 --- .../DependencyInjection/RoutingServiceCollectionExtensions.cs | 1 - .../RequestDelegateRouteBuilderExtensionsTest.cs | 3 ++- test/Microsoft.AspNetCore.Routing.Tests/RouteCollectionTest.cs | 3 +++ test/Microsoft.AspNetCore.Routing.Tests/RouteTest.cs | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs b/src/Microsoft.AspNetCore.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs index 8ae1392aee..34d84c42b8 100644 --- a/src/Microsoft.AspNetCore.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs +++ b/src/Microsoft.AspNetCore.Routing/DependencyInjection/RoutingServiceCollectionExtensions.cs @@ -28,7 +28,6 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddTransient(); services.TryAddSingleton(UrlEncoder.Default); - services.TryAddSingleton(new DefaultObjectPoolProvider()); services.TryAddSingleton>(s => { var provider = s.GetRequiredService(); diff --git a/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs index dec6e9bcdc..c59031f371 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/RequestDelegateRouteBuilderExtensionsTest.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; +using Microsoft.Extensions.ObjectPool; using Moq; using Xunit; @@ -128,6 +128,7 @@ namespace Microsoft.AspNetCore.Routing private static IServiceProvider CreateServices() { var services = new ServiceCollection(); + services.AddSingleton(); services.AddOptions(); services.AddRouting(); services.AddLogging(); diff --git a/test/Microsoft.AspNetCore.Routing.Tests/RouteCollectionTest.cs b/test/Microsoft.AspNetCore.Routing.Tests/RouteCollectionTest.cs index bf57183e5d..68b31beaba 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/RouteCollectionTest.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/RouteCollectionTest.cs @@ -10,6 +10,7 @@ using Microsoft.AspNetCore.Http.Internal; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; +using Microsoft.Extensions.ObjectPool; using Microsoft.Extensions.Options; using Moq; using Xunit; @@ -528,6 +529,7 @@ namespace Microsoft.AspNetCore.Routing var request = new Mock(MockBehavior.Strict); var services = new ServiceCollection(); + services.AddSingleton(); services.AddOptions(); services.AddRouting(); if (options != null) @@ -549,6 +551,7 @@ namespace Microsoft.AspNetCore.Routing { var services = new ServiceCollection(); services.AddSingleton(NullLoggerFactory.Instance); + services.AddSingleton(); services.AddOptions(); services.AddRouting(); if (options != null) diff --git a/test/Microsoft.AspNetCore.Routing.Tests/RouteTest.cs b/test/Microsoft.AspNetCore.Routing.Tests/RouteTest.cs index 8fff1423d8..abb3b53dc7 100644 --- a/test/Microsoft.AspNetCore.Routing.Tests/RouteTest.cs +++ b/test/Microsoft.AspNetCore.Routing.Tests/RouteTest.cs @@ -14,6 +14,7 @@ using Microsoft.AspNetCore.Testing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging.Testing; +using Microsoft.Extensions.ObjectPool; using Moq; using Xunit; @@ -1383,6 +1384,7 @@ namespace Microsoft.AspNetCore.Routing { var services = new ServiceCollection(); services.AddSingleton(NullLoggerFactory.Instance); + services.AddSingleton(); services.AddRouting(); var context = new DefaultHttpContext