CultureInfoCache.GetCultureInfo Should not be case sensitive

This commit is contained in:
Hisham Bin Ateya 2015-10-06 00:42:26 +03:00
Родитель b22474afb3
Коммит 722fbc4ef5
3 изменённых файлов: 30 добавлений и 2 удалений

Просмотреть файл

@ -34,6 +34,7 @@ namespace CultureInfoGenerator
// *************************** THIS FILE IS GENERATED BY A TOOL ***************************
// To make changes to this file look at the CultureInfoGenerator project in this solution.
using System;
using System.Collections.Generic;
namespace Microsoft.Extensions.Globalization
@ -49,7 +50,7 @@ namespace Microsoft.Extensions.Globalization
/// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it
/// contains the latest culture names.
/// </summary>
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{{"
);

Просмотреть файл

@ -4,6 +4,7 @@
// *************************** THIS FILE IS GENERATED BY A TOOL ***************************
// To make changes to this file look at the CultureInfoGenerator project in this solution.
using System;
using System.Collections.Generic;
namespace Microsoft.Extensions.Globalization
@ -19,7 +20,7 @@ namespace Microsoft.Extensions.Globalization
/// As new versions of .NET Framework and Windows are released, this list should be regenerated to ensure it
/// contains the latest culture names.
/// </summary>
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>
public static readonly HashSet<string> KnownCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"",
"af",

Просмотреть файл

@ -167,5 +167,31 @@ namespace Microsoft.Extensions.Localization.Tests
var response = await client.GetAsync("/page?c=ar-SA&uic=ar-YE");
}
}
[Fact]
public async void GetTheRightCultureInfoRegardlessOfCultureNameCasing()
{
using (var server = TestServer.Create(app =>
{
var options = new RequestLocalizationOptions();
var provider = new QueryStringRequestCultureProvider();
provider.QueryStringKey = "c";
provider.UIQueryStringKey = "uic";
options.RequestCultureProviders.Insert(0, provider);
app.UseRequestLocalization(options);
app.Run(context =>
{
var requestCultureFeature = context.Features.Get<IRequestCultureFeature>();
var requestCulture = requestCultureFeature.RequestCulture;
Assert.Equal("fr", requestCulture.Culture.ToString());
Assert.Equal("fr", requestCulture.UICulture.ToString());
return Task.FromResult(0);
});
}))
{
var client = server.CreateClient();
var response = await client.GetAsync("/page?c=FR&uic=FR");
}
}
}
}