Skip to content

Commit 4f1a138

Browse files
authored
[iOS][non-icu] HybridGlobalization clean up the code (#96974)
Clean up the code
1 parent 13ab6eb commit 4f1a138

File tree

60 files changed

+181
-180
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+181
-180
lines changed

docs/design/features/globalization-hybrid-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,9 @@ The Hybrid responses may differ because they use Web API functions. To better il
364364
| ShortTimePattern | `Intl.DateTimeFormat(locale, { timeStyle: "medium" })` | bg-BG | HH:mm | H:mm |
365365
| YearMonthPattern | `Date.prototype.toLocaleDateString(locale, { year: "numeric", month: "long" })` | ar-SA | MMMM yyyy | MMMM yyyy g |
366366

367-
### OSX
367+
### Apple platforms
368368

369-
For OSX platforms we are using native apis instead of ICU data.
369+
For Apple platforms (iOS/tvOS/maccatalyst) we are using native apis instead of ICU data.
370370

371371
## String comparison
372372

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,16 @@ public static string GetDistroVersionString()
382382
public static bool IsInvariantGlobalization => m_isInvariant.Value;
383383
public static bool IsHybridGlobalization => m_isHybrid.Value;
384384
public static bool IsHybridGlobalizationOnBrowser => m_isHybrid.Value && IsBrowser;
385-
public static bool IsHybridGlobalizationOnOSX => m_isHybrid.Value && (IsOSX || IsMacCatalyst || IsiOS || IstvOS);
385+
public static bool IsHybridGlobalizationOnApplePlatform => m_isHybrid.Value && (IsMacCatalyst || IsiOS || IstvOS);
386386
public static bool IsNotHybridGlobalizationOnBrowser => !IsHybridGlobalizationOnBrowser;
387387
public static bool IsNotInvariantGlobalization => !IsInvariantGlobalization;
388388
public static bool IsNotHybridGlobalization => !IsHybridGlobalization;
389-
public static bool IsNotHybridGlobalizationOnOSX => !IsHybridGlobalizationOnOSX;
389+
public static bool IsNotHybridGlobalizationOnApplePlatform => !IsHybridGlobalizationOnApplePlatform;
390390

391-
// HG on apple platforms implies ICU
392-
public static bool IsIcuGlobalization => !IsInvariantGlobalization && (IsHybridGlobalizationOnOSX || ICUVersion > new Version(0, 0, 0, 0));
391+
// HG on apple platforms implies ICU
392+
public static bool IsIcuGlobalization => !IsInvariantGlobalization && (IsHybridGlobalizationOnApplePlatform || ICUVersion > new Version(0, 0, 0, 0));
393393

394394
public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser;
395-
public static bool IsIcuGlobalizationAndNotHybrid => IsIcuGlobalization && IsNotHybridGlobalization;
396395
public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization && !IsHybridGlobalization;
397396

398397
public static bool IsSubstAvailable
@@ -421,7 +420,7 @@ private static Version GetICUVersion()
421420
{
422421
int version = 0;
423422
// When HG on Apple platforms, our ICU lib is not loaded
424-
if (IsNotHybridGlobalizationOnOSX)
423+
if (IsNotHybridGlobalizationOnApplePlatform)
425424
{
426425
try
427426
{

src/libraries/Common/tests/Tests/System/StringTests.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ public static void MakeSureNoCompareToChecksGoOutOfRange_StringComparison()
10091009
}
10101010

10111011
[Fact]
1012-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
1012+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
10131013
public static void CompareToNoMatch_StringComparison()
10141014
{
10151015
for (int length = 1; length < 150; length++)
@@ -1284,7 +1284,7 @@ public static void ContainsMatchDifferentSpans_StringComparison()
12841284
}
12851285

12861286
[Fact]
1287-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
1287+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
12881288
[ActiveIssue("https://github.com/dotnet/runtime/issues/95471", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
12891289
public static void ContainsNoMatch_StringComparison()
12901290
{
@@ -1663,7 +1663,7 @@ public static IEnumerable<object[]> EndsWith_StringComparison_TestData()
16631663
yield return new object[] { "", "", StringComparison.CurrentCulture, true };
16641664
yield return new object[] { "", "a", StringComparison.CurrentCulture, false };
16651665

1666-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
1666+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
16671667
yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.CurrentCulture, true };
16681668

16691669
// CurrentCultureIgnoreCase
@@ -1675,7 +1675,7 @@ public static IEnumerable<object[]> EndsWith_StringComparison_TestData()
16751675
yield return new object[] { "", "", StringComparison.CurrentCultureIgnoreCase, true };
16761676
yield return new object[] { "", "a", StringComparison.CurrentCultureIgnoreCase, false };
16771677

1678-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
1678+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
16791679
yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.CurrentCultureIgnoreCase, true };
16801680

16811681
// InvariantCulture
@@ -1688,7 +1688,7 @@ public static IEnumerable<object[]> EndsWith_StringComparison_TestData()
16881688
yield return new object[] { "", "", StringComparison.InvariantCulture, true };
16891689
yield return new object[] { "", "a", StringComparison.InvariantCulture, false };
16901690

1691-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
1691+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
16921692
yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.InvariantCulture, true };
16931693

16941694
// InvariantCultureIgnoreCase
@@ -1700,7 +1700,7 @@ public static IEnumerable<object[]> EndsWith_StringComparison_TestData()
17001700
yield return new object[] { "", "", StringComparison.InvariantCultureIgnoreCase, true };
17011701
yield return new object[] { "", "a", StringComparison.InvariantCultureIgnoreCase, false };
17021702

1703-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
1703+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
17041704
yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.InvariantCultureIgnoreCase, true };
17051705

17061706
// Ordinal
@@ -2113,7 +2113,7 @@ public static void EndsWithMatchDifferentSpans_StringComparison()
21132113
}
21142114

21152115
[Fact]
2116-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
2116+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
21172117
public static void EndsWithNoMatch_StringComparison()
21182118
{
21192119
for (int length = 1; length < 150; length++)
@@ -3199,7 +3199,7 @@ public static void IndexOf_TurkishI_EnglishUSCulture()
31993199
}
32003200
}
32013201

3202-
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
3202+
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnApplePlatform))]
32033203
[ActiveIssue("https://github.com/dotnet/runtime/issues/60568", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
32043204
public static void IndexOf_HungarianDoubleCompression_HungarianCulture()
32053205
{
@@ -4856,7 +4856,7 @@ public static IEnumerable<object[]> StartsWith_StringComparison_TestData()
48564856
yield return new object[] { "", "", StringComparison.CurrentCulture, true };
48574857
yield return new object[] { "", "hello", StringComparison.CurrentCulture, false };
48584858

4859-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
4859+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
48604860
{
48614861
// "https://github.com/dotnet/runtime/issues/95473"
48624862
if (PlatformDetection.IsNotHybridGlobalizationOnBrowser)
@@ -4872,7 +4872,7 @@ public static IEnumerable<object[]> StartsWith_StringComparison_TestData()
48724872
yield return new object[] { "", "", StringComparison.CurrentCultureIgnoreCase, true };
48734873
yield return new object[] { "", "hello", StringComparison.CurrentCultureIgnoreCase, false };
48744874

4875-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
4875+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
48764876
yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.CurrentCultureIgnoreCase, true };
48774877

48784878
// InvariantCulture
@@ -4884,7 +4884,7 @@ public static IEnumerable<object[]> StartsWith_StringComparison_TestData()
48844884
yield return new object[] { "", "", StringComparison.InvariantCulture, true };
48854885
yield return new object[] { "", "hello", StringComparison.InvariantCulture, false };
48864886

4887-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
4887+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
48884888
yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.InvariantCulture, true };
48894889

48904890
// InvariantCultureIgnoreCase
@@ -4896,7 +4896,7 @@ public static IEnumerable<object[]> StartsWith_StringComparison_TestData()
48964896
yield return new object[] { "", "", StringComparison.InvariantCultureIgnoreCase, true };
48974897
yield return new object[] { "", "hello", StringComparison.InvariantCultureIgnoreCase, false };
48984898

4899-
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX)
4899+
if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnApplePlatform)
49004900
yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.InvariantCultureIgnoreCase, true };
49014901

49024902
// Ordinal
@@ -5354,7 +5354,7 @@ private static IEnumerable<object[]> ToLower_Culture_TestData()
53545354
}
53555355

53565356
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
5357-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
5357+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
53585358
[ActiveIssue("https://github.com/dotnet/runtime/issues/95503", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
53595359
public static void Test_ToLower_Culture()
53605360
{
@@ -5871,7 +5871,7 @@ public static IEnumerable<object[]> ToUpper_Culture_TestData()
58715871
}
58725872

58735873
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
5874-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
5874+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
58755875
[MemberData(nameof(ToUpper_Culture_TestData))]
58765876
[ActiveIssue("https://github.com/dotnet/runtime/issues/95503", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
58775877
public static void Test_ToUpper_Culture(string actual, string expected, CultureInfo culture)
@@ -5971,7 +5971,7 @@ public static IEnumerable<object[]> ToUpper_TurkishI_InvariantCulture_MemberData
59715971
new KeyValuePair<char, char>('\u0130', '\u0130'),
59725972
new KeyValuePair<char, char>('\u0131', '\u0131'));
59735973

5974-
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
5974+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnApplePlatform))]
59755975
[MemberData(nameof(ToUpper_TurkishI_InvariantCulture_MemberData))]
59765976
[ActiveIssue("https://github.com/dotnet/runtime/issues/95471", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
59775977
public static void ToUpper_TurkishI_InvariantCulture(string s, string expected)
@@ -7242,7 +7242,7 @@ public static void StartsWithMatchDifferentSpans_StringComparison()
72427242
}
72437243

72447244
[Fact]
7245-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
7245+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
72467246
public static void StartsWithNoMatch_StringComparison()
72477247
{
72487248
for (int length = 1; length < 150; length++)

src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void Ctor_CultureInfo_Compare(object a, object b, int expected)
6666

6767
[Fact]
6868
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
69-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
69+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
7070
public void Ctor_CultureInfo_Compare_TurkishI()
7171
{
7272
var cultureNames = Helpers.TestCultureNames;

src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o
9696

9797
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))]
9898
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
99-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
99+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
100100
public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
101101
{
102102
var cultureNames = Helpers.TestCultureNames;
@@ -153,7 +153,7 @@ public void Default_GetHashCodeCompare(object a, object b, bool expected)
153153

154154
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))]
155155
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
156-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
156+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
157157
public void Default_Compare_TurkishI()
158158
{
159159
// Turkish has lower-case and upper-case version of the dotted "i", so the upper case of "i" (U+0069) isn't "I" (U+0049)

src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public void AdjustScale()
196196
}
197197

198198
[Fact]
199-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
199+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
200200
public void ConvertToPrecScale()
201201
{
202202
Assert.Equal(new SqlDecimal(6464.6m).Value, SqlDecimal.ConvertToPrecScale(_test1, 5, 1).Value);

src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public static class SqlStringSortingTest
3838
private static readonly UnicodeEncoding s_unicodeEncoding = new UnicodeEncoding(bigEndian: false, byteOrderMark: false, throwOnInvalidBytes: true);
3939

4040
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
41-
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
41+
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
4242
[InlineData("ja-JP", 0x0411)] // Japanese - Japan
4343
[InlineData("ar-SA", 0x0401)] // Arabic - Saudi Arabia
4444
[InlineData("de-DE", 0x0407)] // German - Germany

0 commit comments

Comments
 (0)