From 1ca6ce33775dd74e7f0d930301160e9db4827d3d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 9 May 2018 17:40:28 -0700 Subject: [PATCH] setupAction parameter in MvcLocalizationServices.AddLocalizationServices is never used Fixes #7761 --- .../MvcLocalizationMvcBuilderExtensions.cs | 2 +- ...MvcLocalizationMvcCoreBuilderExtensions.cs | 2 +- .../{Internal => }/MvcLocalizationServices.cs | 9 ++-- .../Properties/AssemblyInfo.cs | 6 +++ ...lizationServiceCollectionExtensionsTest.cs | 41 ++++--------------- 5 files changed, 19 insertions(+), 41 deletions(-) rename src/Microsoft.AspNetCore.Mvc.Localization/{Internal => }/MvcLocalizationServices.cs (84%) create mode 100644 src/Microsoft.AspNetCore.Mvc.Localization/Properties/AssemblyInfo.cs rename test/Microsoft.AspNetCore.Mvc.Localization.Test/{Internal => }/MvcLocalizationServiceCollectionExtensionsTest.cs (82%) diff --git a/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs index ddeb4f25b4..d5c3c6df4c 100644 --- a/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcBuilderExtensions.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.DataAnnotations; -using Microsoft.AspNetCore.Mvc.Localization.Internal; +using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Localization; diff --git a/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs index 27b1f90a7f..e0a970ab88 100644 --- a/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.Localization/DependencyInjection/MvcLocalizationMvcCoreBuilderExtensions.cs @@ -3,7 +3,7 @@ using System; using Microsoft.AspNetCore.Mvc.DataAnnotations; -using Microsoft.AspNetCore.Mvc.Localization.Internal; +using Microsoft.AspNetCore.Mvc.Localization; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.Localization; diff --git a/src/Microsoft.AspNetCore.Mvc.Localization/Internal/MvcLocalizationServices.cs b/src/Microsoft.AspNetCore.Mvc.Localization/MvcLocalizationServices.cs similarity index 84% rename from src/Microsoft.AspNetCore.Mvc.Localization/Internal/MvcLocalizationServices.cs rename to src/Microsoft.AspNetCore.Mvc.Localization/MvcLocalizationServices.cs index 4e1f26ebc0..a1b056250b 100644 --- a/src/Microsoft.AspNetCore.Mvc.Localization/Internal/MvcLocalizationServices.cs +++ b/src/Microsoft.AspNetCore.Mvc.Localization/MvcLocalizationServices.cs @@ -7,16 +7,16 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Localization; -namespace Microsoft.AspNetCore.Mvc.Localization.Internal +namespace Microsoft.AspNetCore.Mvc.Localization { - public static class MvcLocalizationServices + internal static class MvcLocalizationServices { public static void AddLocalizationServices( IServiceCollection services, LanguageViewLocationExpanderFormat format, Action setupAction) { - AddMvcViewLocalizationServices(services, format, setupAction); + AddMvcViewLocalizationServices(services, format); if (setupAction == null) { @@ -31,8 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal // To enable unit testing only 'MVC' specific services public static void AddMvcViewLocalizationServices( IServiceCollection services, - LanguageViewLocationExpanderFormat format, - Action setupAction) + LanguageViewLocationExpanderFormat format) { services.Configure( options => diff --git a/src/Microsoft.AspNetCore.Mvc.Localization/Properties/AssemblyInfo.cs b/src/Microsoft.AspNetCore.Mvc.Localization/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..8110c12929 --- /dev/null +++ b/src/Microsoft.AspNetCore.Mvc.Localization/Properties/AssemblyInfo.cs @@ -0,0 +1,6 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Mvc.Localization.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] diff --git a/test/Microsoft.AspNetCore.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Localization.Test/MvcLocalizationServiceCollectionExtensionsTest.cs similarity index 82% rename from test/Microsoft.AspNetCore.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs rename to test/Microsoft.AspNetCore.Mvc.Localization.Test/MvcLocalizationServiceCollectionExtensionsTest.cs index 50f4c7626a..f67e5f466d 100644 --- a/test/Microsoft.AspNetCore.Mvc.Localization.Test/Internal/MvcLocalizationServiceCollectionExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Localization.Test/MvcLocalizationServiceCollectionExtensionsTest.cs @@ -5,16 +5,13 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Text.Encodings.Web; using Microsoft.AspNetCore.Mvc.Razor; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Localization; -using Microsoft.Extensions.Options; -using Microsoft.Extensions.WebEncoders.Testing; using Xunit; -namespace Microsoft.AspNetCore.Mvc.Localization.Internal +namespace Microsoft.AspNetCore.Mvc.Localization { public class MvcLocalizationServicesTest { @@ -27,8 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal // Act MvcLocalizationServices.AddMvcViewLocalizationServices( collection, - LanguageViewLocationExpanderFormat.Suffix, - setupAction: null); + LanguageViewLocationExpanderFormat.Suffix); // Assert AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(HtmlLocalizerFactory)); @@ -49,8 +45,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal MvcLocalizationServices.AddMvcViewLocalizationServices( collection, - LanguageViewLocationExpanderFormat.Suffix, - setupAction: null); + LanguageViewLocationExpanderFormat.Suffix); AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory)); AssertContainsSingle(collection, typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>)); @@ -84,21 +79,10 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal public class TestViewLocalizer : IViewLocalizer { - public LocalizedHtmlString this[string name] - { - get - { - throw new NotImplementedException(); - } - } + public LocalizedHtmlString this[string name] => throw new NotImplementedException(); public LocalizedHtmlString this[string name, params object[] arguments] - { - get - { - throw new NotImplementedException(); - } - } + => throw new NotImplementedException(); public LocalizedString GetString(string name) { @@ -123,21 +107,10 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal public class TestHtmlLocalizer : IHtmlLocalizer { - public LocalizedHtmlString this[string name] - { - get - { - throw new NotImplementedException(); - } - } + public LocalizedHtmlString this[string name] => throw new NotImplementedException(); public LocalizedHtmlString this[string name, params object[] arguments] - { - get - { - throw new NotImplementedException(); - } - } + => throw new NotImplementedException(); public LocalizedString GetString(string name) {