Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Commit 43836ae

Browse files
committed
An ObjectPoolProvider is always registered
- react to aspnet/Hosting/pull#673
1 parent 476d2eb commit 43836ae

File tree

6 files changed

+20
-9
lines changed

6 files changed

+20
-9
lines changed

src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonMvcCoreBuilderExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
using System;
55
using Microsoft.AspNetCore.Mvc;
66
using Microsoft.AspNetCore.Mvc.Formatters.Json.Internal;
7-
using Microsoft.AspNetCore.Mvc.Infrastructure;
87
using Microsoft.Extensions.DependencyInjection.Extensions;
9-
using Microsoft.Extensions.ObjectPool;
108
using Microsoft.Extensions.Options;
119
using Newtonsoft.Json;
1210

@@ -55,7 +53,6 @@ internal static void AddJsonFormatterServices(IServiceCollection services)
5553
services.TryAddEnumerable(
5654
ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcJsonMvcOptionsSetup>());
5755
services.TryAddSingleton<JsonResultExecutor>();
58-
services.TryAddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
5956
}
6057
}
6158
}

test/Microsoft.AspNetCore.Mvc.Core.Test/Internal/AttributeRoutingTest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Extensions.Logging;
2020
using Microsoft.Extensions.Logging.Testing;
2121
using Microsoft.Extensions.Options;
22+
using Microsoft.Extensions.ObjectPool;
2223
using Microsoft.Extensions.WebEncoders.Testing;
2324
using Moq;
2425
using Xunit;
@@ -195,6 +196,7 @@ private static IServiceProvider CreateServices(params ActionDescriptor[] actions
195196

196197
var services = new ServiceCollection()
197198
.AddSingleton<IInlineConstraintResolver>(new DefaultInlineConstraintResolver(routeOptions.Object))
199+
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
198200
.AddSingleton<UrlEncoder>(new UrlTestEncoder());
199201

200202
services.AddRouting();

test/Microsoft.AspNetCore.Mvc.Core.Test/Routing/UrlHelperTest.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Microsoft.AspNetCore.Mvc.Abstractions;
1313
using Microsoft.AspNetCore.Routing;
1414
using Microsoft.Extensions.DependencyInjection;
15+
using Microsoft.Extensions.ObjectPool;
1516
using Moq;
1617
using Xunit;
1718

@@ -1030,7 +1031,10 @@ private static IServiceProvider CreateServices()
10301031
services.AddOptions();
10311032
services.AddLogging();
10321033
services.AddRouting();
1033-
services.AddSingleton<UrlEncoder>(UrlEncoder.Default);
1034+
services
1035+
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
1036+
.AddSingleton<UrlEncoder>(UrlEncoder.Default);
1037+
10341038
return services.BuildServiceProvider();
10351039
}
10361040

test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelBindingTestHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
65
using Microsoft.AspNetCore.Http;
76
using Microsoft.AspNetCore.Http.Internal;
87
using Microsoft.AspNetCore.Mvc.Controllers;
@@ -12,6 +11,7 @@
1211
using Microsoft.AspNetCore.Routing;
1312
using Microsoft.Extensions.DependencyInjection;
1413
using Microsoft.Extensions.Logging;
14+
using Microsoft.Extensions.ObjectPool;
1515
using Microsoft.Extensions.Options;
1616

1717
namespace Microsoft.AspNetCore.Mvc.IntegrationTests
@@ -83,7 +83,9 @@ private static HttpContext GetHttpContext(
8383

8484
var serviceCollection = new ServiceCollection();
8585
serviceCollection.AddMvc();
86-
serviceCollection.AddTransient<ILoggerFactory, LoggerFactory>();
86+
serviceCollection
87+
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
88+
.AddTransient<ILoggerFactory, LoggerFactory>();
8789

8890
if (updateOptions != null)
8991
{

test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Extensions.DependencyInjection;
2020
using Microsoft.Extensions.FileProviders;
2121
using Microsoft.Extensions.Logging;
22+
using Microsoft.Extensions.ObjectPool;
2223
using Microsoft.Extensions.Options;
2324
using Moq;
2425
using Newtonsoft.Json.Linq;
@@ -233,7 +234,9 @@ private static IServiceProvider GetServiceProvider(Action<IServiceCollection> ac
233234
{
234235
var serviceCollection = new ServiceCollection();
235236
serviceCollection.AddMvc();
236-
serviceCollection.AddTransient<ILoggerFactory, LoggerFactory>();
237+
serviceCollection
238+
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
239+
.AddTransient<ILoggerFactory, LoggerFactory>();
237240

238241
if (action != null)
239242
{

test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/RemoteAttributeTest.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Microsoft.Extensions.Localization;
1818
using Microsoft.Extensions.Logging;
1919
using Microsoft.Extensions.Logging.Testing;
20+
using Microsoft.Extensions.ObjectPool;
2021
using Microsoft.Extensions.Options;
2122
using Microsoft.Extensions.WebEncoders.Testing;
2223
using Moq;
@@ -1038,8 +1039,10 @@ private static ActionContext GetActionContext(IServiceProvider serviceProvider,
10381039
private static ServiceCollection GetServiceCollection(IStringLocalizerFactory localizerFactory)
10391040
{
10401041
var serviceCollection = new ServiceCollection();
1041-
serviceCollection.AddSingleton<ILoggerFactory>(new NullLoggerFactory());
1042-
serviceCollection.AddSingleton<UrlEncoder>(new UrlTestEncoder());
1042+
serviceCollection
1043+
.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
1044+
.AddSingleton<ILoggerFactory>(new NullLoggerFactory())
1045+
.AddSingleton<UrlEncoder>(new UrlTestEncoder());
10431046

10441047
serviceCollection.AddOptions();
10451048
serviceCollection.AddRouting();

0 commit comments

Comments
 (0)