Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix creating RegionInfo object using names with different casing. #40052

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,24 @@ public void CurrentRegion_Windows()
}).Dispose();
}


[ConditionalTheory(typeof(RemoteExecutor), nameof(RemoteExecutor.IsSupported))]
// We are testing with "no" as it match a neutral culture name. We want ensure this not conflict with region name.
[InlineData("no")]
[InlineData("No")]
[InlineData("NO")]
public void ValidateUsingCasedRegionName(string regionName)
{
RemoteExecutor.Invoke(name =>
{
// It is important to do this test in the following order because we have internal cache for regions.
// creating the region with the original input name should be the first to do to ensure not cached before.
string resultedName = new RegionInfo(name).Name;
string expectedName = new RegionInfo(name.ToUpperInvariant()).Name;
Assert.Equal(expectedName, resultedName);
}, regionName).Dispose();
}

[Theory]
[InlineData("en-US", "United States")]
[OuterLoop("May fail on machines with multiple language packs installed")] // see https://github.com/dotnet/runtime/issues/30132
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ internal partial class CultureData
/// </remarks>
private static Dictionary<string, string> RegionNames =>
s_regionNames ??=
new Dictionary<string, string>(257 /* prime */)
new Dictionary<string, string>(257 /* prime */, StringComparer.OrdinalIgnoreCase)
{
{ "001", "en-001" },
{ "029", "en-029" },
Expand Down