Skip to content

Commit 4c1dffc

Browse files
[release/8.0-staging] Fix wrong Region Info Names (#108550)
* Fix wrong RegionInfo Names * Exclude the test on Windows 8 for the lack of full globalization data --------- Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
1 parent 40bd96e commit 4c1dffc

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Collections.Generic;
55
using System.Diagnostics;
66
using System.Linq;
7+
using System.Reflection;
78
using System.Tests;
89
using Microsoft.DotNet.RemoteExecutor;
910
using Xunit;
@@ -267,5 +268,19 @@ public void ValidateThrowingWhenUsingCustomUnspecifiedLcid()
267268

268269
AssertExtensions.Throws<ArgumentException>("culture", () => new RegionInfo(4096));
269270
}
271+
272+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotWindows8x))]
273+
public void BuiltInRegionListTest()
274+
{
275+
// Ensure we can create all region info objects from the built-in list
276+
Dictionary<string, string> regionNames = (Dictionary<string, string>)typeof(RegionInfo).Assembly.GetType("System.Globalization.CultureData").GetProperty("RegionNames", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null);
277+
278+
foreach (var kvp in regionNames)
279+
{
280+
RegionInfo ri1 = new RegionInfo(kvp.Key);
281+
RegionInfo ri2 = new RegionInfo(kvp.Value == "" ? kvp.Key : kvp.Value); // invariant culture
282+
Assert.Equal(ri1.Name, ri2.Name);
283+
}
284+
}
270285
}
271286
}

src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ internal sealed partial class CultureData
164164
{ "AL", "sq-AL" },
165165
{ "AM", "hy-AM" },
166166
{ "AO", "pt-AO" },
167-
{ "AQ", "en-A" },
167+
{ "AQ", "en-AQ" },
168168
{ "AR", "es-AR" },
169169
{ "AS", "en-AS" },
170170
{ "AT", "de-AT" },
@@ -189,7 +189,7 @@ internal sealed partial class CultureData
189189
{ "BR", "pt-BR" },
190190
{ "BS", "en-BS" },
191191
{ "BT", "dz-BT" },
192-
{ "BV", "nb-B" },
192+
{ "BV", "nb-BV" },
193193
{ "BW", "en-BW" },
194194
{ "BY", "be-BY" },
195195
{ "BZ", "en-BZ" },
@@ -202,7 +202,7 @@ internal sealed partial class CultureData
202202
{ "CI", "fr-CI" },
203203
{ "CK", "en-CK" },
204204
{ "CL", "es-CL" },
205-
{ "CM", "fr-C" },
205+
{ "CM", "fr-CM" },
206206
{ "CN", "zh-CN" },
207207
{ "CO", "es-CO" },
208208
{ "CR", "es-CR" },
@@ -245,13 +245,13 @@ internal sealed partial class CultureData
245245
{ "GP", "fr-GP" },
246246
{ "GQ", "es-GQ" },
247247
{ "GR", "el-GR" },
248-
{ "GS", "en-G" },
248+
{ "GS", "en-GS" },
249249
{ "GT", "es-GT" },
250250
{ "GU", "en-GU" },
251251
{ "GW", "pt-GW" },
252252
{ "GY", "en-GY" },
253253
{ "HK", "zh-HK" },
254-
{ "HM", "en-H" },
254+
{ "HM", "en-HM" },
255255
{ "HN", "es-HN" },
256256
{ "HR", "hr-HR" },
257257
{ "HT", "fr-HT" },
@@ -372,7 +372,7 @@ internal sealed partial class CultureData
372372
{ "SZ", "ss-SZ" },
373373
{ "TC", "en-TC" },
374374
{ "TD", "fr-TD" },
375-
{ "TF", "fr-T" },
375+
{ "TF", "fr-TF" },
376376
{ "TG", "fr-TG" },
377377
{ "TH", "th-TH" },
378378
{ "TJ", "tg-Cyrl-TJ" },

0 commit comments

Comments
 (0)