diff --git a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs index 362d4f2507..dc6e2d04a3 100644 --- a/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs +++ b/src/Microsoft.AspNet.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs @@ -123,7 +123,7 @@ namespace Microsoft.Extensions.DependencyInjection { if (CompilationServices.Default != null) { - services.TryAdd(ServiceDescriptor.Instance(CompilationServices.Default.LibraryExporter)); + services.TryAddSingleton(CompilationServices.Default.LibraryExporter); } services.TryAddEnumerable( @@ -165,7 +165,7 @@ namespace Microsoft.Extensions.DependencyInjection if (PlatformServices.Default?.AssemblyLoadContextAccessor != null) { - services.TryAdd(ServiceDescriptor.Instance(PlatformServices.Default.AssemblyLoadContextAccessor)); + services.TryAddSingleton(PlatformServices.Default.AssemblyLoadContextAccessor); } } } diff --git a/test/Microsoft.AspNet.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs b/test/Microsoft.AspNet.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs index d6a7c7c4e4..1eef28a4af 100644 --- a/test/Microsoft.AspNet.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs +++ b/test/Microsoft.AspNet.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs @@ -67,7 +67,7 @@ namespace Microsoft.AspNet.Mvc.Localization.Internal collection.Add(ServiceDescriptor.Singleton(typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory))); collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>))); collection.Add(ServiceDescriptor.Transient(typeof(IViewLocalizer), typeof(TestViewLocalizer))); - collection.Add(ServiceDescriptor.Instance(typeof(HtmlEncoder), testEncoder)); + collection.Add(ServiceDescriptor.Singleton(typeof(HtmlEncoder), testEncoder)); MvcLocalizationServices.AddMvcLocalizationServices( collection, @@ -125,7 +125,7 @@ namespace Microsoft.AspNet.Mvc.Localization.Internal collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>))); collection.Add(ServiceDescriptor.Transient(typeof(IHtmlLocalizer), typeof(TestViewLocalizer))); - collection.Add(ServiceDescriptor.Instance(typeof(HtmlEncoder), typeof(HtmlTestEncoder))); + collection.Add(ServiceDescriptor.Singleton(typeof(HtmlEncoder), typeof(HtmlTestEncoder))); // Assert Assert.Collection(collection,