Skip to content
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 @@ -163,7 +163,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 @@ -188,7 +188,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 @@ -201,7 +201,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 @@ -244,13 +244,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 @@ -371,7 +371,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
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 @@ -266,5 +267,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);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there another source we could be enumerating? e.g. how does this related to the cultures enumerable from CultureInfo.GetCultures(All)... if we were to parse the regions out of those, would that be equivalent to (some of) this data?

@tarekgh tarekgh Oct 2, 2024

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Culture enumeration can be done too but, in our data, we add some extra data that is not getting from the enumeration. That is why I decided to se the data we build.


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);
}
}
}
}