Skip to content

Commit

Permalink
[release/8.0-staging] Fix wrong Region Info Names (#108550)
Browse files Browse the repository at this point in the history
* Fix wrong RegionInfo Names

* Exclude the test on Windows 8 for the lack of full globalization data

---------

Co-authored-by: Tarek Mahmoud Sayed <[email protected]>
  • Loading branch information
github-actions[bot] and tarekgh authored Oct 4, 2024
1 parent 40bd96e commit 4c1dffc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Tests;
using Microsoft.DotNet.RemoteExecutor;
using Xunit;
Expand Down Expand Up @@ -267,5 +268,19 @@ public void ValidateThrowingWhenUsingCustomUnspecifiedLcid()

AssertExtensions.Throws<ArgumentException>("culture", () => new RegionInfo(4096));
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindows8x))]
public void BuiltInRegionListTest()
{
// Ensure we can create all region info objects from the built-in list
Dictionary<string, string> regionNames = (Dictionary<string, string>)typeof(RegionInfo).Assembly.GetType("System.Globalization.CultureData").GetProperty("RegionNames", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);

foreach (var kvp in regionNames)
{
RegionInfo ri1 = new RegionInfo(kvp.Key);
RegionInfo ri2 = new RegionInfo(kvp.Value == "" ? kvp.Key : kvp.Value); // invariant culture
Assert.Equal(ri1.Name, ri2.Name);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ internal sealed partial class CultureData
{ "AL", "sq-AL" },
{ "AM", "hy-AM" },
{ "AO", "pt-AO" },
{ "AQ", "en-A" },
{ "AQ", "en-AQ" },
{ "AR", "es-AR" },
{ "AS", "en-AS" },
{ "AT", "de-AT" },
Expand All @@ -189,7 +189,7 @@ internal sealed partial class CultureData
{ "BR", "pt-BR" },
{ "BS", "en-BS" },
{ "BT", "dz-BT" },
{ "BV", "nb-B" },
{ "BV", "nb-BV" },
{ "BW", "en-BW" },
{ "BY", "be-BY" },
{ "BZ", "en-BZ" },
Expand All @@ -202,7 +202,7 @@ internal sealed partial class CultureData
{ "CI", "fr-CI" },
{ "CK", "en-CK" },
{ "CL", "es-CL" },
{ "CM", "fr-C" },
{ "CM", "fr-CM" },
{ "CN", "zh-CN" },
{ "CO", "es-CO" },
{ "CR", "es-CR" },
Expand Down Expand Up @@ -245,13 +245,13 @@ internal sealed partial class CultureData
{ "GP", "fr-GP" },
{ "GQ", "es-GQ" },
{ "GR", "el-GR" },
{ "GS", "en-G" },
{ "GS", "en-GS" },
{ "GT", "es-GT" },
{ "GU", "en-GU" },
{ "GW", "pt-GW" },
{ "GY", "en-GY" },
{ "HK", "zh-HK" },
{ "HM", "en-H" },
{ "HM", "en-HM" },
{ "HN", "es-HN" },
{ "HR", "hr-HR" },
{ "HT", "fr-HT" },
Expand Down Expand Up @@ -372,7 +372,7 @@ internal sealed partial class CultureData
{ "SZ", "ss-SZ" },
{ "TC", "en-TC" },
{ "TD", "fr-TD" },
{ "TF", "fr-T" },
{ "TF", "fr-TF" },
{ "TG", "fr-TG" },
{ "TH", "th-TH" },
{ "TJ", "tg-Cyrl-TJ" },
Expand Down

0 comments on commit 4c1dffc

Please sign in to comment.