Skip to content

Commit 2ac31f3

Browse files
authored
[iOS] HybridGlobalization Implement missing cases for GlobalizationNative_GetLocaleInfoString (#89296)
Implement missing locale properties for GlobalizationNative_GetLocaleInfoString
1 parent 728e32b commit 2ac31f3

23 files changed

+192
-127
lines changed

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoEnglishName.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static IEnumerable<object[]> EnglishName_TestData()
1515
{
1616
yield return new object[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.EnglishName };
1717

18-
if (SupportFullGlobalizationData)
18+
if (SupportFullGlobalizationData || PlatformDetection.IsHybridGlobalizationOnOSX)
1919
{
2020
yield return new object[] { "en-US", "English (United States)" };
2121
yield return new object[] { "fr-FR", "French (France)" };

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoNativeName.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ public static IEnumerable<object[]> NativeName_TestData()
1313
yield return new object[] { CultureInfo.CurrentCulture.Name, CultureInfo.CurrentCulture.NativeName };
1414

1515
// Android has its own ICU, which doesn't 100% map to UsingLimitedCultures
16-
if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid)
16+
if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid || PlatformDetection.IsHybridGlobalizationOnOSX)
1717
{
1818
yield return new object[] { "en-US", "English (United States)" };
1919
yield return new object[] { "en-CA", "English (Canada)" };
20+
yield return new object[] { "en-GB", "English (United Kingdom)" };
2021
}
2122
else
2223
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Xunit;
5+
using System.Collections.Generic;
6+
7+
namespace System.Globalization.Tests
8+
{
9+
public class CultureInfoThreeLetterISOInfo
10+
{
11+
public static IEnumerable<object[]> RegionInfo_TestData()
12+
{
13+
yield return new object[] { 0x409, 244, "en-US", "USA", "eng" };
14+
yield return new object[] { 0x411, 122, "ja-JP", "JPN", "jpn" };
15+
yield return new object[] { 0x804, 45, "zh-CN", "CHN", "zho" };
16+
yield return new object[] { 0x401, 205, "ar-SA", "SAU", "ara" };
17+
yield return new object[] { 0x412, 134, "ko-KR", "KOR", "kor" };
18+
yield return new object[] { 0x40d, 117, "he-IL", "ISR", "heb" };
19+
}
20+
21+
[Theory]
22+
[MemberData(nameof(RegionInfo_TestData))]
23+
public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName)
24+
{
25+
RegionInfo ri = new RegionInfo(lcid); // create it with lcid
26+
Assert.Equal(geoId, ri.GeoId);
27+
Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName);
28+
Assert.Equal(threeLetterISOLanguageName, new CultureInfo(name).ThreeLetterISOLanguageName);
29+
}
30+
}
31+
}

src/libraries/System.Globalization/tests/Hybrid/HybridMode.cs

-48
This file was deleted.

src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj

+26-21
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,44 @@
55
<HybridGlobalization>true</HybridGlobalization>
66
</PropertyGroup>
77
<ItemGroup>
8-
<Compile Include="HybridMode.cs" />
8+
<Compile Include="..\CultureInfo\CultureInfoEnglishName.cs" />
99
<Compile Include="..\CultureInfo\CultureInfoNumberFormat.cs" />
1010
<Compile Include="..\CultureInfo\CultureInfoNames.cs" />
11+
<Compile Include="..\CultureInfo\CultureInfoNativeName.cs" />
12+
<Compile Include="..\CultureInfo\CultureInfoParent.cs" />
13+
<Compile Include="..\CultureInfo\CultureInfoThreeLetterISOInfo.cs" />
14+
<Compile Include="..\CultureInfo\CultureInfoTwoLetterISOLanguageName.cs" />
15+
<Compile Include="..\CompareInfo\CompareInfoTestsBase.cs" />
16+
<Compile Include="..\CompareInfo\CompareInfoTests.Compare.cs" />
17+
<Compile Include="..\CompareInfo\CompareInfoTests.IndexOf.cs" />
18+
<Compile Include="..\CompareInfo\CompareInfoTests.IsPrefix.cs" />
19+
<Compile Include="..\CompareInfo\CompareInfoTests.IsSuffix.cs" />
20+
<Compile Include="..\CompareInfo\CompareInfoTests.LastIndexOf.cs" />
21+
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoCalendarWeekRule.cs" />
1122
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoData.cs" />
1223
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoFirstDayOfWeek.cs" />
13-
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoCalendarWeekRule.cs" />
14-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoValidateParseStyle.cs" />
15-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoData.cs" />
1624
<Compile Include="..\NumberFormatInfo\NumberFormatInfoCurrencySymbol.cs" />
25+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoData.cs" />
1726
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNaNSymbol.cs" />
18-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentGroupSeparator.cs" />
19-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentDecimalSeparator.cs" />
20-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentDecimalDigits.cs" />
21-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPerMilleSymbol.cs" />
22-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentSymbol.cs" />
23-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPositiveSign.cs" />
24-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPositiveInfinitySymbol.cs" />
25-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNegativeSign.cs" />
2627
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNegativeInfinitySymbol.cs" />
27-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberGroupSeparator.cs" />
28-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberDecimalSeparator.cs" />
28+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNegativeSign.cs" />
2929
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberDecimalDigits.cs" />
30+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberDecimalSeparator.cs" />
31+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberGroupSeparator.cs" />
3032
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberGroupSizes.cs" />
3133
<Compile Include="..\NumberFormatInfo\NumberFormatInfoNumberNegativePattern.cs" />
32-
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentNegativePattern.cs" />
34+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentDecimalDigits.cs" />
35+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentDecimalSeparator.cs" />
36+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentGroupSeparator.cs" />
3337
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentGroupSizes.cs" />
38+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentNegativePattern.cs" />
3439
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentPositivePattern.cs" />
35-
<Compile Include="..\CompareInfo\CompareInfoTestsBase.cs" />
36-
<Compile Include="..\CompareInfo\CompareInfoTests.Compare.cs" />
37-
<Compile Include="..\CompareInfo\CompareInfoTests.IndexOf.cs" />
38-
<Compile Include="..\CompareInfo\CompareInfoTests.LastIndexOf.cs" />
39-
<Compile Include="..\CompareInfo\CompareInfoTests.IsPrefix.cs" />
40-
<Compile Include="..\CompareInfo\CompareInfoTests.IsSuffix.cs" />
40+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPercentSymbol.cs" />
41+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPerMilleSymbol.cs" />
42+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPositiveInfinitySymbol.cs" />
43+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoPositiveSign.cs" />
44+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoTests.cs" />
45+
<Compile Include="..\NumberFormatInfo\NumberFormatInfoValidateParseStyle.cs" />
4146
<Compile Include="..\System\Globalization\TextInfoTests.cs" />
4247
</ItemGroup>
4348
</Project>

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

+9-9
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@
332332
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Nls.cs" />
333333
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.Utf8.cs" />
334334
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.WebAssembly.cs" Condition="'$(TargetsBrowser)' == 'true'" />
335-
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.OSX.cs" Condition="'$(IsOSXLike)' == 'true'" />
335+
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareInfo.iOS.cs" Condition="'$(IsiOSLike)' == 'true'" />
336336
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CompareOptions.cs" />
337337
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.cs" />
338338
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Icu.cs" />
339-
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.OSX.cs" Condition="'$(IsOSXLike)' == 'true'" />
339+
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.iOS.cs" Condition="'$(IsiOSLike)' == 'true'" />
340340
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Nls.cs" />
341341
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureInfo.cs" />
342342
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureNotFoundException.cs" />
@@ -391,7 +391,7 @@
391391
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.cs" />
392392
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.Icu.cs" />
393393
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.Nls.cs" />
394-
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.OSX.cs" Condition="'$(IsOSXLike)' == 'true'" />
394+
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.iOS.cs" Condition="'$(IsiOSLike)' == 'true'" />
395395
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TextInfo.WebAssembly.cs" Condition="'$(TargetsBrowser)' == 'true'" />
396396
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\ThaiBuddhistCalendar.cs" />
397397
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\TimeSpanFormat.cs" />
@@ -1290,14 +1290,14 @@
12901290
<Compile Include="$(CommonPath)Interop\Interop.Casing.cs">
12911291
<Link>Common\Interop\Interop.Casing.cs</Link>
12921292
</Compile>
1293-
<Compile Include="$(CommonPath)Interop\Interop.Casing.OSX.cs" Condition="'$(IsOSXLike)' == 'true'">
1294-
<Link>Common\Interop\Interop.Casing.OSX.cs</Link>
1293+
<Compile Include="$(CommonPath)Interop\Interop.Casing.iOS.cs" Condition="'$(IsiOSLike)' == 'true'">
1294+
<Link>Common\Interop\Interop.Casing.iOS.cs</Link>
12951295
</Compile>
12961296
<Compile Include="$(CommonPath)Interop\Interop.Collation.cs">
12971297
<Link>Common\Interop\Interop.Collation.cs</Link>
12981298
</Compile>
1299-
<Compile Include="$(CommonPath)Interop\Interop.Collation.OSX.cs" Condition="'$(IsOSXLike)' == 'true'">
1300-
<Link>Common\Interop\Interop.Collation.OSX.cs</Link>
1299+
<Compile Include="$(CommonPath)Interop\Interop.Collation.iOS.cs" Condition="'$(IsiOSLike)' == 'true'">
1300+
<Link>Common\Interop\Interop.Collation.iOS.cs</Link>
13011301
</Compile>
13021302
<Compile Include="$(CommonPath)Interop\Interop.ICU.cs">
13031303
<Link>Common\Interop\Interop.ICU.cs</Link>
@@ -1311,8 +1311,8 @@
13111311
<Compile Include="$(CommonPath)Interop\Interop.Locale.cs">
13121312
<Link>Common\Interop\Interop.Locale.cs</Link>
13131313
</Compile>
1314-
<Compile Include="$(CommonPath)Interop\Interop.Locale.OSX.cs" Condition="'$(IsOSXLike)' == 'true'">
1315-
<Link>Common\Interop\Interop.Locale.OSX.cs</Link>
1314+
<Compile Include="$(CommonPath)Interop\Interop.Locale.iOS.cs" Condition="'$(IsiOSLike)' == 'true'">
1315+
<Link>Common\Interop\Interop.Locale.iOS.cs</Link>
13161316
</Compile>
13171317
<Compile Include="$(CommonPath)Interop\Interop.Normalization.cs">
13181318
<Link>Common\Interop\Interop.Normalization.cs</Link>

src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ private void IcuInitSortHandle(string interopCultureName)
2424
_isAsciiEqualityOrdinal = GetIsAsciiEqualityOrdinal(interopCultureName);
2525
if (!GlobalizationMode.Invariant)
2626
{
27-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER
27+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER
2828
if (GlobalizationMode.Hybrid)
2929
return;
3030
#endif
@@ -84,7 +84,7 @@ private unsafe int IcuIndexOfCore(ReadOnlySpan<char> source, ReadOnlySpan<char>
8484
fixed (char* pSource = &MemoryMarshal.GetReference(source))
8585
fixed (char* pTarget = &MemoryMarshal.GetReference(target))
8686
{
87-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
87+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
8888
if (GlobalizationMode.Hybrid)
8989
return IndexOfCoreNative(pTarget, target.Length, pSource, source.Length, options, fromBeginning, matchLengthPtr);
9090
#endif
@@ -203,7 +203,7 @@ private unsafe int IndexOfOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source, Rea
203203
throw new Exception((string)ex_result);
204204
return result;
205205
}
206-
#elif TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
206+
#elif TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
207207
if (GlobalizationMode.Hybrid)
208208
return IndexOfCoreNative(b, target.Length, a, source.Length, options, fromBeginning, matchLengthPtr);
209209
#endif
@@ -305,7 +305,7 @@ private unsafe int IndexOfOrdinalHelper(ReadOnlySpan<char> source, ReadOnlySpan<
305305
throw new Exception((string)ex_result);
306306
return result;
307307
}
308-
#elif TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
308+
#elif TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
309309
if (GlobalizationMode.Hybrid)
310310
return IndexOfCoreNative(b, target.Length, a, source.Length, options, fromBeginning, matchLengthPtr);
311311
#endif
@@ -337,7 +337,7 @@ private unsafe bool IcuStartsWith(ReadOnlySpan<char> source, ReadOnlySpan<char>
337337
fixed (char* pSource = &MemoryMarshal.GetReference(source)) // could be null (or otherwise unable to be dereferenced)
338338
fixed (char* pPrefix = &MemoryMarshal.GetReference(prefix))
339339
{
340-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
340+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
341341
if (GlobalizationMode.Hybrid)
342342
return NativeStartsWith(pPrefix, prefix.Length, pSource, source.Length, options);
343343
#endif
@@ -420,7 +420,7 @@ private unsafe bool StartsWithOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source,
420420
return true;
421421

422422
InteropCall:
423-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
423+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
424424
if (GlobalizationMode.Hybrid)
425425
return NativeStartsWith(bp, prefix.Length, ap, source.Length, options);
426426
#endif
@@ -492,7 +492,7 @@ private unsafe bool StartsWithOrdinalHelper(ReadOnlySpan<char> source, ReadOnlyS
492492
return true;
493493

494494
InteropCall:
495-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
495+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
496496
if (GlobalizationMode.Hybrid)
497497
return NativeStartsWith(bp, prefix.Length, ap, source.Length, options);
498498
#endif
@@ -521,7 +521,7 @@ private unsafe bool IcuEndsWith(ReadOnlySpan<char> source, ReadOnlySpan<char> su
521521
fixed (char* pSource = &MemoryMarshal.GetReference(source)) // could be null (or otherwise unable to be dereferenced)
522522
fixed (char* pSuffix = &MemoryMarshal.GetReference(suffix))
523523
{
524-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
524+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
525525
if (GlobalizationMode.Hybrid)
526526
return NativeEndsWith(pSuffix, suffix.Length, pSource, source.Length, options);
527527
#endif
@@ -605,7 +605,7 @@ private unsafe bool EndsWithOrdinalIgnoreCaseHelper(ReadOnlySpan<char> source, R
605605
return true;
606606

607607
InteropCall:
608-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
608+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
609609
if (GlobalizationMode.Hybrid)
610610
return NativeEndsWith(bp, suffix.Length, ap, source.Length, options);
611611
#endif
@@ -677,7 +677,7 @@ private unsafe bool EndsWithOrdinalHelper(ReadOnlySpan<char> source, ReadOnlySpa
677677
return true;
678678

679679
InteropCall:
680-
#if TARGET_OSX || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
680+
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
681681
if (GlobalizationMode.Hybrid)
682682
return NativeEndsWith(bp, suffix.Length, ap, source.Length, options);
683683
#endif

0 commit comments

Comments
 (0)