setupAction parameter in MvcLocalizationServices.AddLocalizationServices is never used

Fixes #7761
This commit is contained in:
Pranav K 2018-05-09 17:40:28 -07:00
parent 504da3c565
commit 1ca6ce3377
5 changed files with 19 additions and 41 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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<LocalizationOptions> 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<LocalizationOptions> setupAction)
LanguageViewLocationExpanderFormat format)
{
services.Configure<RazorViewEngineOptions>(
options =>

View File

@ -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")]

View File

@ -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<HomeController> : IHtmlLocalizer<HomeController>
{
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)
{