Skip to content

Commit

Permalink
Fix creating RegionInfo object using names with different casing. (do…
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekgh authored and Jacksondr5 committed Aug 10, 2020
1 parent 553f9d5 commit a1dd56d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit a1dd56d

Please sign in to comment.