setupAction parameter in MvcLocalizationServices.AddLocalizationServices is never used
Fixes #7761
This commit is contained in:
parent
504da3c565
commit
1ca6ce3377
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Mvc.DataAnnotations;
|
using Microsoft.AspNetCore.Mvc.DataAnnotations;
|
||||||
using Microsoft.AspNetCore.Mvc.Localization.Internal;
|
using Microsoft.AspNetCore.Mvc.Localization;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Mvc.DataAnnotations;
|
using Microsoft.AspNetCore.Mvc.DataAnnotations;
|
||||||
using Microsoft.AspNetCore.Mvc.Localization.Internal;
|
using Microsoft.AspNetCore.Mvc.Localization;
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,16 @@ using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Localization;
|
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(
|
public static void AddLocalizationServices(
|
||||||
IServiceCollection services,
|
IServiceCollection services,
|
||||||
LanguageViewLocationExpanderFormat format,
|
LanguageViewLocationExpanderFormat format,
|
||||||
Action<LocalizationOptions> setupAction)
|
Action<LocalizationOptions> setupAction)
|
||||||
{
|
{
|
||||||
AddMvcViewLocalizationServices(services, format, setupAction);
|
AddMvcViewLocalizationServices(services, format);
|
||||||
|
|
||||||
if (setupAction == null)
|
if (setupAction == null)
|
||||||
{
|
{
|
||||||
|
|
@ -31,8 +31,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
||||||
// To enable unit testing only 'MVC' specific services
|
// To enable unit testing only 'MVC' specific services
|
||||||
public static void AddMvcViewLocalizationServices(
|
public static void AddMvcViewLocalizationServices(
|
||||||
IServiceCollection services,
|
IServiceCollection services,
|
||||||
LanguageViewLocationExpanderFormat format,
|
LanguageViewLocationExpanderFormat format)
|
||||||
Action<LocalizationOptions> setupAction)
|
|
||||||
{
|
{
|
||||||
services.Configure<RazorViewEngineOptions>(
|
services.Configure<RazorViewEngineOptions>(
|
||||||
options =>
|
options =>
|
||||||
|
|
@ -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")]
|
||||||
|
|
@ -5,16 +5,13 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Encodings.Web;
|
|
||||||
using Microsoft.AspNetCore.Mvc.Razor;
|
using Microsoft.AspNetCore.Mvc.Razor;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Localization;
|
using Microsoft.Extensions.Localization;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Microsoft.Extensions.WebEncoders.Testing;
|
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
namespace Microsoft.AspNetCore.Mvc.Localization
|
||||||
{
|
{
|
||||||
public class MvcLocalizationServicesTest
|
public class MvcLocalizationServicesTest
|
||||||
{
|
{
|
||||||
|
|
@ -27,8 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
||||||
// Act
|
// Act
|
||||||
MvcLocalizationServices.AddMvcViewLocalizationServices(
|
MvcLocalizationServices.AddMvcViewLocalizationServices(
|
||||||
collection,
|
collection,
|
||||||
LanguageViewLocationExpanderFormat.Suffix,
|
LanguageViewLocationExpanderFormat.Suffix);
|
||||||
setupAction: null);
|
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(HtmlLocalizerFactory));
|
AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(HtmlLocalizerFactory));
|
||||||
|
|
@ -49,8 +45,7 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
||||||
|
|
||||||
MvcLocalizationServices.AddMvcViewLocalizationServices(
|
MvcLocalizationServices.AddMvcViewLocalizationServices(
|
||||||
collection,
|
collection,
|
||||||
LanguageViewLocationExpanderFormat.Suffix,
|
LanguageViewLocationExpanderFormat.Suffix);
|
||||||
setupAction: null);
|
|
||||||
|
|
||||||
AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory));
|
AssertContainsSingle(collection, typeof(IHtmlLocalizerFactory), typeof(TestHtmlLocalizerFactory));
|
||||||
AssertContainsSingle(collection, typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>));
|
AssertContainsSingle(collection, typeof(IHtmlLocalizer<>), typeof(TestHtmlLocalizer<>));
|
||||||
|
|
@ -84,21 +79,10 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
||||||
|
|
||||||
public class TestViewLocalizer : IViewLocalizer
|
public class TestViewLocalizer : IViewLocalizer
|
||||||
{
|
{
|
||||||
public LocalizedHtmlString this[string name]
|
public LocalizedHtmlString this[string name] => throw new NotImplementedException();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalizedHtmlString this[string name, params object[] arguments]
|
public LocalizedHtmlString this[string name, params object[] arguments]
|
||||||
{
|
=> throw new NotImplementedException();
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalizedString GetString(string name)
|
public LocalizedString GetString(string name)
|
||||||
{
|
{
|
||||||
|
|
@ -123,21 +107,10 @@ namespace Microsoft.AspNetCore.Mvc.Localization.Internal
|
||||||
|
|
||||||
public class TestHtmlLocalizer<HomeController> : IHtmlLocalizer<HomeController>
|
public class TestHtmlLocalizer<HomeController> : IHtmlLocalizer<HomeController>
|
||||||
{
|
{
|
||||||
public LocalizedHtmlString this[string name]
|
public LocalizedHtmlString this[string name] => throw new NotImplementedException();
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalizedHtmlString this[string name, params object[] arguments]
|
public LocalizedHtmlString this[string name, params object[] arguments]
|
||||||
{
|
=> throw new NotImplementedException();
|
||||||
get
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public LocalizedString GetString(string name)
|
public LocalizedString GetString(string name)
|
||||||
{
|
{
|
||||||
Loading…
Reference in New Issue