Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS][non-icu] HybridGlobalization use system ICU #93220

Merged
merged 123 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
2d149a4
comment loading icu when hybrid mode
mkhamoyan Oct 4, 2023
4bd2918
Fix failing tests without loading icu
mkhamoyan Oct 9, 2023
8bf39c6
Merge branch 'main' into system_icu
mkhamoyan Oct 9, 2023
d5bcd12
Uncomment calendar test cases
mkhamoyan Oct 9, 2023
c2f7ac4
fix build failures
mkhamoyan Oct 16, 2023
064b71b
Remove other ICU references
Oct 17, 2023
47f0271
Load pal_idna.c
mkhamoyan Oct 18, 2023
82c04b1
clean the branch
mkhamoyan Oct 18, 2023
6796080
Merge branch 'main' into system_icu
mkhamoyan Oct 20, 2023
d3fcc60
Remove not needed function
mkhamoyan Oct 20, 2023
fb34efc
minor fix
mkhamoyan Oct 20, 2023
2e0900c
Add country and language tables
mkhamoyan Oct 23, 2023
a91cdf7
Add check for hybrid mode
mkhamoyan Oct 23, 2023
7d6641d
minor fix
mkhamoyan Oct 23, 2023
5097d38
Fix build
akoeplinger Oct 23, 2023
4ad9b4e
link to -licucore in the appbuilder
mkhamoyan Oct 23, 2023
455aa2a
Fix System.Globalization.Tests on hybrid mode
mkhamoyan Oct 24, 2023
64b9309
revert changes in IOS tests
mkhamoyan Oct 24, 2023
39785db
revert ios tests csproj changes
mkhamoyan Oct 24, 2023
1caed2e
inlcude utypes.h
mkhamoyan Oct 24, 2023
7beec5c
Adjust idna mapping tests
mkhamoyan Oct 24, 2023
f097dec
Fix idna mapping tests
mkhamoyan Oct 25, 2023
87f2011
Fix System.Runtime.Tests,disable some of the tests
mkhamoyan Oct 25, 2023
bbf590e
Merge branch 'main' into system_icu
mkhamoyan Oct 25, 2023
125ce63
Merge branch 'main' into system_icu
mkhamoyan Oct 30, 2023
182e069
fix build on non Apple platforms
mkhamoyan Oct 30, 2023
662d5ea
Fix non Apple platform builds
mkhamoyan Oct 30, 2023
6360fd4
Merge branch 'main' into system_icu
mkhamoyan Nov 1, 2023
a3db930
Fix merge conflicts
mkhamoyan Nov 1, 2023
5860103
Fix failed tests after merge
mkhamoyan Nov 2, 2023
16b3847
Include pal files for non Apple platforms
mkhamoyan Nov 2, 2023
710ce29
fix nativeaot build failure
mkhamoyan Nov 6, 2023
71ad42f
Merge branch 'main' into system_icu
mkhamoyan Nov 6, 2023
ef3f945
Fix -licucore related failures
mkhamoyan Nov 6, 2023
49ef3ab
Fix CMake if block
mkhamoyan Nov 6, 2023
3bbe6d8
Remove "pal_icushim_internal.h" from headers
mkhamoyan Nov 6, 2023
380efe4
fix osx failures
mkhamoyan Nov 6, 2023
429d777
Fix OSX failures
mkhamoyan Nov 6, 2023
1d1021e
Fix osx build failures
mkhamoyan Nov 6, 2023
6ecdeae
Fix maccatalyst x64 failure
mkhamoyan Nov 7, 2023
814cadc
Fix native crash when running tests on osx
mkhamoyan Nov 7, 2023
7702cf7
Fix maccatalyst failure
mkhamoyan Nov 7, 2023
b0c1a51
Fix build on iOSLike platforms
mkhamoyan Nov 7, 2023
d9d1136
use TARGET_OS_MAC
mkhamoyan Nov 7, 2023
fc9d472
Fix osx build
mkhamoyan Nov 7, 2023
7e7bf74
include TargetConditionals header
mkhamoyan Nov 8, 2023
d165171
check only using TARGET_OS_IPHONE
mkhamoyan Nov 8, 2023
7049e31
Fix osx build
mkhamoyan Nov 8, 2023
6debeb5
fix build failure
mkhamoyan Nov 8, 2023
68b8b88
Fix osx build
mkhamoyan Nov 8, 2023
7b640e0
Fix browser build failure
mkhamoyan Nov 8, 2023
7330fdf
run iOS.DEVICE.Aot.Tests also on hybrid mode
mkhamoyan Nov 8, 2023
760de2a
Fix native aot build
mkhamoyan Nov 9, 2023
1cf723c
fix nativeaot build
mkhamoyan Nov 9, 2023
b381ef0
fix bowser build
mkhamoyan Nov 9, 2023
2e29b1d
Fix nativeaot build
mkhamoyan Nov 13, 2023
1171ce0
add target definitions
mkhamoyan Nov 13, 2023
043e638
Merge branch 'main' into system_icu
mkhamoyan Nov 13, 2023
b8c697b
Fix native aot build
mkhamoyan Nov 14, 2023
37681f2
set hybridglobalization for functional tests
mkhamoyan Nov 14, 2023
e7111bd
Try without checking hybrid mode
mkhamoyan Nov 14, 2023
8c5d9f0
change IcuInitSortHandle
mkhamoyan Nov 14, 2023
a6fe664
Set hybrid without checking target
mkhamoyan Nov 15, 2023
d8658ce
fix nativeaot build
mkhamoyan Nov 15, 2023
45428ef
add hybrid only for osx in ILLink
mkhamoyan Nov 15, 2023
cf153d9
Fix osx-x64 linker failure
mkhamoyan Nov 15, 2023
90026f0
Cleanup code
mkhamoyan Nov 15, 2023
696ff66
Clean up and fix runtime-extra-platform failure
mkhamoyan Nov 15, 2023
5354f28
enable hybrid mode in nativeaot runtime tests
mkhamoyan Nov 15, 2023
f446fcd
Fix nativeaot and iossimulator failure
mkhamoyan Nov 15, 2023
bd73666
include in LibraryBuilder template -licucore
mkhamoyan Nov 15, 2023
5788349
Merge branch 'main' into system_icu
mkhamoyan Nov 15, 2023
914a7aa
check if hybrid mode is set
mkhamoyan Nov 16, 2023
ba92af7
include licucore when LibraryMode
mkhamoyan Nov 16, 2023
eff8512
Fix nativeaot runtime tests build failure
mkhamoyan Nov 20, 2023
5c53525
Implement GetSortKeyNative function
mkhamoyan Nov 21, 2023
6d5ecde
Update SortKey implementation for hybrid mode
mkhamoyan Nov 23, 2023
8e2dd91
Fix IgnoreKanaType related test failures
mkhamoyan Nov 23, 2023
32d5db1
Do minor fixes and mark active issue
mkhamoyan Nov 24, 2023
1134b7a
Revert ValidCompareMaskOffFlags changes
mkhamoyan Nov 24, 2023
714ac50
Implement IgnoreKanaType for hybrid
mkhamoyan Nov 24, 2023
f16988c
Fix System.Runtime.Tests
mkhamoyan Nov 24, 2023
af8ba6a
Enable some tests
mkhamoyan Nov 24, 2023
ba37d39
Merge branch 'main' into system_icu
mkhamoyan Nov 27, 2023
52b8f35
fix crash on System.Private.Xml.Tests
mkhamoyan Nov 27, 2023
222d528
Fix failure
mkhamoyan Nov 27, 2023
940042b
Fix failure
mkhamoyan Nov 28, 2023
9ecc945
Disable startswith test
mkhamoyan Nov 28, 2023
317bd6a
Skip NoMatch_stringComparisonTests
mkhamoyan Nov 28, 2023
a18110c
enable hybrid mode on XmlFormatWriterGeneratorAot
mkhamoyan Nov 28, 2023
caafa6b
check if utf16 convertion is needed
mkhamoyan Nov 28, 2023
352c1c2
Test GlobalizationNative_GetSortKeyNative
mkhamoyan Nov 29, 2023
d29f2b5
Enable SortKey tests on hybrid mode
mkhamoyan Nov 30, 2023
3e4a8ba
Fix XmlFormatWriterGeneratorAot test
mkhamoyan Nov 30, 2023
2944f96
refactor GetSortKey function
mkhamoyan Dec 4, 2023
8a2ce03
Merge branch 'main' into system_icu
mkhamoyan Dec 4, 2023
09dd476
check if calendar is the cause
mkhamoyan Dec 4, 2023
43aca30
check if _calendars is null
mkhamoyan Dec 4, 2023
d94c917
check for _calendars?.Length
mkhamoyan Dec 4, 2023
6193794
Refactor GetSortKey
mkhamoyan Dec 5, 2023
6321784
Stop using GlobalizationMode Settings static constructor because we d…
Dec 5, 2023
d7613f3
Merge remote-tracking branch 'meri/system_icu' into system_icu
Dec 5, 2023
8ec7727
Fix syntax error
mkhamoyan Dec 6, 2023
6cb3ff0
Merge branch 'main' into system_icu
mkhamoyan Dec 6, 2023
3fe8320
Merge branch 'main' into system_icu
mkhamoyan Dec 6, 2023
6ca8bd1
Refactor
mkhamoyan Dec 6, 2023
a50fb14
Fix wrong merge
mkhamoyan Dec 6, 2023
f6708f0
Changes requested by review
mkhamoyan Dec 7, 2023
7dfc908
Align lines
mkhamoyan Dec 7, 2023
213f6a4
Mark test cases as activeissue
mkhamoyan Dec 12, 2023
35d3b34
Merge branch 'main' into system_icu
mkhamoyan Dec 12, 2023
5127785
Revert the change and update documentation
mkhamoyan Dec 12, 2023
20096cd
include ICU headers in pal_icushim_internal.h
mkhamoyan Dec 12, 2023
cdb2ba2
Merge branch 'main' into system_icu
mkhamoyan Dec 12, 2023
1245214
Fix nativeaot failures
mkhamoyan Dec 12, 2023
336f050
Merge branch 'main' into system_icu
mkhamoyan Dec 15, 2023
ae7d959
Merge branch 'main' into system_icu
mkhamoyan Dec 15, 2023
b602e0a
mark the function as static
mkhamoyan Dec 15, 2023
71d9717
Merge branch 'main' into system_icu
mkhamoyan Dec 18, 2023
83076e0
Fix nativeaot failures
mkhamoyan Dec 18, 2023
c422d07
check if this broke nativeaot tests
mkhamoyan Dec 18, 2023
2b42a43
Fix nativeaot failure
mkhamoyan Dec 18, 2023
ba3aecb
review refactoring
mkhamoyan Dec 19, 2023
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
5 changes: 4 additions & 1 deletion eng/testing/tests.ioslike.targets
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" />
</ItemGroup>

<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true'">
<ItemGroup Condition="'$(UseNativeAOTRuntime)' == 'true' and '$(HybridGlobalization)' == 'false'" >
<BundleFiles Include="$(MicrosoftNetCoreAppRuntimePackDir)/runtimes/$(TargetOS)-$(TargetArchitecture)/native/icudt.dat"
TargetDir="publish" />
<BundleFiles Include="$(MicrosoftNetCoreAppRuntimePackDir)/runtimes/$(TargetOS)-$(TargetArchitecture)/native/libicudata.a"
Expand Down Expand Up @@ -157,6 +157,9 @@
<WriteLinesToFile File="$(PublishDir)xunit-excludes.txt" Lines="$(XunitExcludesTxtFileContent)" Overwrite="true" />

<PropertyGroup>
<!-- Default for now. If we can remove our ICU and rely on the system one, then HybridGlobalization becomes the default and we can remove checks for it -->
<HybridGlobalization>true</HybridGlobalization>
ilonatommy marked this conversation as resolved.
Show resolved Hide resolved

<IncludesTestRunner Condition="'$(IncludesTestRunner)' == ''">true</IncludesTestRunner>
<Optimized Condition="'$(Configuration)' == 'Release'">true</Optimized>
<MainLibraryFileName Condition="'$(MainLibraryFileName)' == '' and '$(IsRuntimeTests)' != 'true' and '$(IncludesTestRunner)' == 'true'">AppleTestRunner.dll</MainLibraryFileName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ The .NET Foundation licenses this file to you under the MIT license.
<NetCoreAppNativeLibrary Include="System.Security.Cryptography.Native.Apple" Condition="'$(_IsApplePlatform)' == 'true'" />
<!-- Not compliant for iOS-like platforms -->
<NetCoreAppNativeLibrary Include="System.Security.Cryptography.Native.OpenSsl" Condition="'$(StaticOpenSslLinking)' != 'true' and '$(_IsiOSLikePlatform)' != 'true'" />
<NetCoreAppNativeLibrary Include="icudata" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="icui18n" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="icuuc" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="icudata" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true' and '$(HybridGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="icui18n" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true' and '$(HybridGlobalization)' != 'true'" />
<NetCoreAppNativeLibrary Include="icuuc" Condition="'$(_IsiOSLikePlatform)' == 'true' and '$(InvariantGlobalization)' != 'true' and '$(HybridGlobalization)' != 'true'" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public static string GetDistroVersionString()
public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0);
public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser;
public static bool IsIcuGlobalizationAndNotHybrid => IsIcuGlobalization && IsNotHybridGlobalization;
public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization;
public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization && !IsHybridGlobalization;

public static bool IsSubstAvailable
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void Ctor_CultureInfo_Compare(object a, object b, int expected)
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
mkhamoyan marked this conversation as resolved.
Show resolved Hide resolved
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
public void Ctor_CultureInfo_Compare_TurkishI()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o
}
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI()
{
Expand Down Expand Up @@ -154,12 +154,15 @@ public void Default_GetHashCodeCompare(object a, object b, bool expected)
[ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)]
public void Default_Compare_TurkishI()
{
// 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)
// but rather U+0130.
using (new ThreadCultureChange("tr-TR"))
if (PlatformDetection.IsNotHybridGlobalizationOnOSX)
{
Assert.False(CaseInsensitiveHashCodeProvider.Default.GetHashCode("file") == CaseInsensitiveHashCodeProvider.Default.GetHashCode("FILE"));
Assert.True(CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode("file") == CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode("FILE"));
// 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)
// but rather U+0130.
using (new ThreadCultureChange("tr-TR"))
{
Assert.False(CaseInsensitiveHashCodeProvider.Default.GetHashCode("file") == CaseInsensitiveHashCodeProvider.Default.GetHashCode("FILE"));
Assert.True(CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode("file") == CaseInsensitiveHashCodeProvider.DefaultInvariant.GetHashCode("FILE"));
}
}

using (new ThreadCultureChange("en-US"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ public void AdjustScale()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void ConvertToPrecScale()
{
Assert.Equal(new SqlDecimal(6464.6m).Value, SqlDecimal.ConvertToPrecScale(_test1, 5, 1).Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static class SqlStringSortingTest
private static readonly UnicodeEncoding s_unicodeEncoding = new UnicodeEncoding(bigEndian: false, byteOrderMark: false, throwOnInvalidBytes: true);

[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
[InlineData("ja-JP", 0x0411)] // Japanese - Japan
[InlineData("ar-SA", 0x0401)] // Arabic - Saudi Arabia
[InlineData("de-DE", 0x0407)] // German - Germany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public SqlStringTest()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void Constructor_Value_Success()
{
const string value = "foo";
Expand Down Expand Up @@ -219,6 +220,7 @@ public void CompareToSqlTypeException()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void CompareTo()
{
Assert.True(_test1.CompareTo(_test3) < 0);
Expand Down Expand Up @@ -259,6 +261,7 @@ public void CompareTo()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void EqualsMethods()
{
Assert.False(_test1.Equals(_test2));
Expand All @@ -275,6 +278,7 @@ public void EqualsMethods()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void Greaters()
{
// GreateThan ()
Expand All @@ -289,6 +293,7 @@ public void Greaters()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void Lessers()
{
// LessThan()
Expand All @@ -304,6 +309,7 @@ public void Lessers()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void NotEquals()
{
Assert.True(SqlString.NotEquals(_test1, _test2).Value);
Expand All @@ -314,6 +320,7 @@ public void NotEquals()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void Concat()
{
_test1 = new SqlString("First TestString");
Expand All @@ -325,6 +332,7 @@ public void Concat()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void Clone()
{
SqlString testSqlString = _test1.Clone();
Expand All @@ -344,6 +352,7 @@ public void CompareOptionsFromSqlCompareOptions()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void UnicodeBytes()
{
Assert.Equal((byte)105, _test1.GetNonUnicodeBytes()[1]);
Expand Down Expand Up @@ -540,6 +549,7 @@ public void Conversions()
// OPERATORS

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void ArithmeticOperators()
{
SqlString testString = new SqlString("...Testing...");
Expand All @@ -548,6 +558,7 @@ public void ArithmeticOperators()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))]
public void ThanOrEqualOperators()
{
// == -operator
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<linker>
<assembly fullname="System.Private.CoreLib">
<type fullname="System.Globalization.GlobalizationMode">
<method signature="System.Boolean get_Hybrid()" body="stub" value="true" feature="System.Globalization.Hybrid" featurevalue="true" />
</type>
<type fullname="System.Globalization.GlobalizationMode/Settings">
<method signature="System.Boolean get_Hybrid()" body="stub" value="true" feature="System.Globalization.Hybrid" featurevalue="true" />
</type>
</assembly>
</linker>
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.NoX86Intrinsics.xml" Condition="'$(SupportsX86Intrinsics)' != 'true'" />
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.NoWasmIntrinsics.xml" Condition="'$(SupportsWasmIntrinsics)' != 'true'" />
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.OSX.xml" Condition="'$(IsOSXLike)' == 'true'" />
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.iOS.xml" Condition="'$(IsiOSLike)' == 'true'" />
rolfbjarne marked this conversation as resolved.
Show resolved Hide resolved
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.Windows.xml" Condition="'$(TargetsWindows)' == 'true'" />
<ILLinkSubstitutionsXmls Include="$(ILLinkSharedDirectory)ILLink.Substitutions.Browser.xml" Condition="'$(TargetsBrowser)' == 'true'" />
<ILLinkLinkAttributesXmls Include="$(ILLinkSharedDirectory)ILLink.LinkAttributes.Shared.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,7 @@ private int GetSortKeyLengthCore(ReadOnlySpan<char> source, CompareOptions optio
NlsGetSortKeyLength(source, options) :
#if TARGET_BROWSER
GlobalizationMode.Hybrid ?
throw new PlatformNotSupportedException(GetPNSEText("SortKey")) :
throw new PlatformNotSupportedException(GetPNSEText("SortKey")) :
#endif
IcuGetSortKeyLength(source, options);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static void AssertComparisonSupported(CompareOptions options)
throw new PlatformNotSupportedException(GetPNSE(options));
}

private const CompareOptions SupportedCompareOptions = CompareOptions.None | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace |
private const CompareOptions SupportedCompareOptions = CompareOptions.None | CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreNonSpace |
CompareOptions.IgnoreWidth | CompareOptions.StringSort;

private static string GetPNSE(CompareOptions options) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ private static partial class Settings
/// the GlobalizationMode.Invariant check. Globalization P/Invokes, e.g. in CompareInfo.GetSortKey,
/// rely on ICU already being loaded before they are called.
/// </summary>
#if !TARGET_MACCATALYST && !TARGET_IOS && !TARGET_TVOS
static Settings()
{
// Use GlobalizationMode.Invariant to allow ICU initialization to be trimmed when Invariant=true
Expand All @@ -32,6 +33,7 @@ static Settings()
}
}
}
#endif

private static string GetIcuLoadFailureMessage()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ internal static partial class GlobalizationMode
private static partial class Settings
{
internal static bool Invariant { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Invariant", "DOTNET_SYSTEM_GLOBALIZATION_INVARIANT");
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
internal static bool Hybrid { get; } = true;
Copy link
Member

Choose a reason for hiding this comment

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

This does not look right. We ignore the user's setting now if they would like to disable HG (keep in mind that while setting HG as default it has certain differences in behavior that users might not want to accept and they would prefer to switch HG off). Use DOTNET_SYSTEM_GLOBALIZATION_HYBRID to propagate the MSBuild setting to managed code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done intentionally as we were facing issue with some FunctionalTests.
This PR does not allow for iOS to have Hybrid as switch, instead it will work only with Hybrid mode.
The reason is in runtime we need to duplicate a lot of files and build 2 runtimes (1. Loading ICU libs 2. Hybrid using system ICU) to be able to have Hybrid mode as switch. We decided for now to make changes the way to have only one runtime with Hybrid mode.

#elif TARGET_BROWSER
internal static bool Hybrid { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Hybrid", "DOTNET_SYSTEM_GLOBALIZATION_HYBRID");
#endif
internal static bool PredefinedCulturesOnly { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.PredefinedCulturesOnly", "DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY", GlobalizationMode.Invariant);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void GetStringComparer_Invalid()
AssertExtensions.Throws<ArgumentException>("options", () => new CultureInfo("tr-TR").CompareInfo.GetStringComparer(CompareOptions.OrdinalIgnoreCase | CompareOptions.IgnoreCase));
}

[Theory]
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))]
[InlineData("hello", "hello", "fr-FR", CompareOptions.IgnoreCase, 0, 0)]
[InlineData("hello", "HELLo", "fr-FR", CompareOptions.IgnoreCase, 0, 0)]
[InlineData("hello", null, "fr-FR", CompareOptions.IgnoreCase, 1, 1)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static string RemoveComment(string line)
private static Stream GetIdnaTestTxt()
{
string fileName = null;
if (PlatformDetection.ICUVersion >= new Version(66, 0))
if (PlatformDetection.ICUVersion >= new Version(66, 0) || PlatformDetection.IsHybridGlobalizationOnOSX)
fileName = "IdnaTest_13.txt";
else if (PlatformDetection.IsWindows7)
fileName = "IdnaTest_Win7.txt";
Expand Down Expand Up @@ -61,7 +61,7 @@ private static IEnumerable<IConformanceIdnaTest> ParseFile(Stream stream, Func<s

private static IConformanceIdnaTest GetConformanceIdnaTest(string line, int lineCount)
{
if (PlatformDetection.ICUVersion >= new Version(66, 0))
if (PlatformDetection.ICUVersion >= new Version(66, 0) || PlatformDetection.IsHybridGlobalizationOnOSX)
return new Unicode_13_0_IdnaTest(line, lineCount);
else if (PlatformDetection.IsWindows7)
return new Unicode_Win7_IdnaTest(line, lineCount);
Expand All @@ -88,7 +88,7 @@ public static IEnumerable<IConformanceIdnaTest> GetDataset()
{
// Nls is transitional so we filter out non transitional test cases.
// Icu is the opposite.
IdnType idnFilter = PlatformDetection.IsNlsGlobalization ? IdnType.Nontransitional : IdnType.Transitional;
IdnType idnFilter = PlatformDetection.IsNlsGlobalization || PlatformDetection.IsHybridGlobalizationOnOSX ? IdnType.Nontransitional : IdnType.Transitional;
foreach (var entry in ParseFile(GetIdnaTestTxt(), GetConformanceIdnaTest))
{
if (entry.Type != idnFilter && entry.Source != string.Empty)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IEnumerable<object[]> GetAscii_TestData()
}

string ascii = c.ToString();
if (!PlatformDetection.IsIcuGlobalization || c != '-') // expected platform differences, see https://github.com/dotnet/runtime/issues/17190
if ((!PlatformDetection.IsIcuGlobalization && !PlatformDetection.IsHybridGlobalizationOnOSX) || c != '-') // expected platform differences, see https://github.com/dotnet/runtime/issues/17190
{
yield return new object[] { ascii, 0, 1, ascii };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void UseStd3AsciiRules_ChangesGetAsciiBehavior(string unicode, bool conta
var idnStd3False = new IdnMapping { UseStd3AsciiRules = false };
var idnStd3True = new IdnMapping { UseStd3AsciiRules = true };

if (containsInvalidHyphen && PlatformDetection.IsIcuGlobalization)
if (containsInvalidHyphen && (PlatformDetection.IsIcuGlobalization || PlatformDetection.IsHybridGlobalizationOnOSX))
{
// ICU always fails on leading/trailing hyphens regardless of the Std3 rules option.
AssertExtensions.Throws<ArgumentException>("unicode", () => idnStd3False.GetAscii(unicode));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Cale
{
dtfi.Calendar = calendar;

if (PlatformDetection.IsNotUsingLimitedCultures)
if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsHybridGlobalizationOnOSX)
{
// Mobile / Browser ICU doesn't contain NativeCalendarName,
Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public void CultureName_Set(AssemblyName assemblyName, string originalCultureNam
Assert.Equal(new AssemblyName(expectedEqualString).FullName, assemblyName.FullName);
}

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
public void CultureName_Set_Invalid_ThrowsCultureNotFoundException()
{
var assemblyName = new AssemblyName("Test");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class ConvertToDateTimeTests : ConvertTestBase<DateTime>
{
private static readonly DateTimeFormatInfo s_dateTimeFormatInfo = new DateTimeFormatInfo();

[Fact]
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))]
public void FromString()
{
DateTime[] expectedValues = { new DateTime(1999, 12, 31, 23, 59, 59), new DateTime(100, 1, 1, 0, 0, 0), new DateTime(2216, 2, 29, 0, 0, 0), new DateTime(1, 1, 1, 0, 0, 0) };
Expand Down
Loading
Loading