From 2d149a43e632117e7249ddf0f30d0fd509214c2e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 4 Oct 2023 15:23:20 +0200 Subject: [PATCH 001/105] comment loading icu when hybrid mode --- .../CompareInfoTests.LastIndexOf.cs | 2 +- .../Globalization/GlobalizationMode.Unix.cs | 24 +++++++++---------- .../pal_icushim_static.c | 2 +- src/tasks/AppleAppBuilder/Templates/runtime.m | 7 +++--- src/tasks/AppleAppBuilder/Xcode.cs | 11 ++++++--- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs index 498290ccf8213..a64c77aa89d46 100644 --- a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs +++ b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs @@ -173,7 +173,7 @@ public static IEnumerable LastIndexOf_U_WithDiaeresis_TestData() [MemberData(nameof(LastIndexOf_TestData))] [MemberData(nameof(LastIndexOf_U_WithDiaeresis_TestData))] public void LastIndexOf_String(CompareInfo compareInfo, string source, string value, int startIndex, int count, CompareOptions options, int expected, int expectedMatchLength) - { + {// failing test case if (value.Length == 1) { LastIndexOf_Char(compareInfo, source, value[0], startIndex, count, options, expected); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index 46850d3d090df..d24f0b65719e8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -18,18 +18,18 @@ static Settings() // and PredefinedCulturesOnly is unspecified. if (!GlobalizationMode.Invariant) { - if (TryGetAppLocalIcuSwitchValue(out string? icuSuffixAndVersion)) - { - LoadAppLocalIcu(icuSuffixAndVersion); - } - else - { - int loaded = LoadICU(); - if (loaded == 0) - { - Environment.FailFast(GetIcuLoadFailureMessage()); - } - } + // if (TryGetAppLocalIcuSwitchValue(out string? icuSuffixAndVersion)) + // { + // LoadAppLocalIcu(icuSuffixAndVersion); + // } + // else + // { + // int loaded = LoadICU(); + // if (loaded == 0) + // { + // Environment.FailFast(GetIcuLoadFailureMessage()); + // } + // } } } diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index ebf271429573e..1fe5c1078dd1d 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -169,7 +169,7 @@ cstdlib_load_icu_data(const char *path) int32_t GlobalizationNative_LoadICUData(const char* path) -{ +{// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) if (path && path[0] != '/') { diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index d577f06a3a1de..c05f2f8b2cc64 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -291,7 +291,8 @@ static bool is_pinvoke_override_library (const char* libraryName) char icu_dat_path [1024]; int res; #if defined(HYBRID_GLOBALIZATION) - res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); + //res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); + res = 1; #else res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); #endif @@ -302,7 +303,7 @@ static bool is_pinvoke_override_library (const char* libraryName) "RUNTIME_IDENTIFIER", "APP_CONTEXT_BASE_DIRECTORY", "PINVOKE_OVERRIDE", -#if !defined(INVARIANT_GLOBALIZATION) +#if !defined(INVARIANT_GLOBALIZATION) && !defined(HYBRID_GLOBALIZATION) "ICU_DAT_FILE_PATH" #endif }; @@ -310,7 +311,7 @@ static bool is_pinvoke_override_library (const char* libraryName) APPLE_RUNTIME_IDENTIFIER, bundle, pinvoke_override, -#if !defined(INVARIANT_GLOBALIZATION) +#if !defined(INVARIANT_GLOBALIZATION) && !defined(HYBRID_GLOBALIZATION) icu_dat_path #endif }; diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index 0e05d9168423e..4a42a0698b86d 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -258,7 +258,11 @@ public string GenerateCMake( bool isLibraryMode = false) { // bundle everything as resources excluding native files - var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; + List predefinedExcludes; + // if (hybridGlobalization) + // predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib"}; + // else + predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; predefinedExcludes = predefinedExcludes.Concat(excludes).ToList(); if (!preferDylibs) { @@ -270,8 +274,9 @@ public string GenerateCMake( } string[] resources = Directory.GetFileSystemEntries(workspace, "", SearchOption.TopDirectoryOnly) - .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) && - !(hybridGlobalization ? Path.GetFileName(f) == "icudt_hybrid.dat" : Path.GetFileName(f) == "icudt.dat")))) + .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) + // && !(hybridGlobalization ? Path.GetFileName(f) == "icudt_hybrid.dat" : Path.GetFileName(f) == "icudt.dat") + ))) .ToArray(); if (string.IsNullOrEmpty(nativeMainSource)) From 4bd2918600beffc60b78f3dba38eb31fc923e067 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 9 Oct 2023 15:52:02 +0200 Subject: [PATCH 002/105] Fix failing tests without loading icu --- .../TestUtilities/System/PlatformDetection.cs | 2 +- .../CompareInfo/CompareInfoTests.IsSuffix.cs | 2 +- .../DateTimeFormatInfoTests.cs | 200 +++++++++--------- .../System.Globalization.IOS.Tests.csproj | 2 + .../NumberFormatInfo/NumberFormatInfoData.cs | 2 +- .../System/Globalization/RegionInfoTests.cs | 2 +- .../src/System/Globalization/CultureData.cs | 4 +- .../src/System/Globalization/RegionInfo.cs | 2 +- .../System.Globalization.Native/pal_locale.m | 4 +- 9 files changed, 111 insertions(+), 109 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 5baf88cd19b0d..2ea0549c5a565 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -368,7 +368,7 @@ public static string GetDistroVersionString() public static bool IsNotInvariantGlobalization => !IsInvariantGlobalization; public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0); public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser; - public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !IsIcuGlobalization; + public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !(IsIcuGlobalization || IsHybridGlobalizationOnOSX); public static bool IsSubstAvailable { diff --git a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IsSuffix.cs b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IsSuffix.cs index 8b83094efe3be..906392ba3fed9 100644 --- a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IsSuffix.cs +++ b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IsSuffix.cs @@ -162,7 +162,7 @@ public void IsSuffix(CompareInfo compareInfo, string source, string value, Compa [Fact] public void IsSuffix_UnassignedUnicode() { - bool result = PlatformDetection.IsIcuGlobalization ? false : true; + bool result = PlatformDetection.IsIcuGlobalization || PlatformDetection.IsHybridGlobalizationOnOSX ? false : true; int expectedMatchLength = (result) ? 6 : 0; IsSuffix(s_invariantCompare, "FooBar", "Foo\uFFFFBar", CompareOptions.None, result, expectedMatchLength); diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs index eacdfb0455a67..740e5f8130906 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs @@ -59,34 +59,34 @@ public void DateSeparatorTimeSeparator_Get_ReturnsExpected() Assert.Equal(expectedFormattedString, d.ToString("HH:mm:ss", dtfi)); } - [Theory] - [MemberData(nameof(DateTimeFormatInfo_TestData))] - public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Calendar calendar, string nativeCalendarName) - { - try - { - dtfi.Calendar = calendar; - - if (PlatformDetection.IsNotUsingLimitedCultures) - { - // Mobile / Browser ICU doesn't contain NativeCalendarName, - Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); - } - } - catch - { - if (PlatformDetection.IsNlsGlobalization) - { - // Persian calendar is recently supported as one of the optional calendars for fa-IR - Assert.True(calendar is PersianCalendar, "Exception can occur only with PersianCalendar"); - } - else // !PlatformDetection.IsNlsGlobalization - { - Assert.True(calendar is HijriCalendar || calendar is UmAlQuraCalendar || calendar is ThaiBuddhistCalendar || - calendar is HebrewCalendar || calendar is KoreanCalendar, "failed to set the calendar on DTFI"); - } - } - } + // [Theory] + // [MemberData(nameof(DateTimeFormatInfo_TestData))] + // public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Calendar calendar, string nativeCalendarName) + // { + // try + // { + // dtfi.Calendar = calendar; + + // if (PlatformDetection.IsNotUsingLimitedCultures) + // { + // // Mobile / Browser ICU doesn't contain NativeCalendarName, + // Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); + // } + // } + // catch + // { + // if (PlatformDetection.IsNlsGlobalization) + // { + // // Persian calendar is recently supported as one of the optional calendars for fa-IR + // Assert.True(calendar is PersianCalendar, "Exception can occur only with PersianCalendar"); + // } + // else // !PlatformDetection.IsNlsGlobalization + // { + // Assert.True(calendar is HijriCalendar || calendar is UmAlQuraCalendar || calendar is ThaiBuddhistCalendar || + // calendar is HebrewCalendar || calendar is KoreanCalendar, "failed to set the calendar on DTFI"); + // } + // } + // } [Theory] [MemberData(nameof(CultureNames_TestData))] @@ -138,78 +138,78 @@ public void GetShortestDayName_Invoke_ReturnsExpected(string cultureName) } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - public void Months_GetHebrew_ReturnsExpected() - { - CultureInfo ci = new CultureInfo("he-IL"); - ci.DateTimeFormat.Calendar = new HebrewCalendar(); - - Assert.Equal(13, ci.DateTimeFormat.MonthNames.Length); - Assert.Equal(13, ci.DateTimeFormat.MonthGenitiveNames.Length); - Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthNames.Length); - Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthGenitiveNames.Length); - - DateTime dt = ci.DateTimeFormat.Calendar.ToDateTime(5779, 1, 1, 0, 0, 0, 0); // leap year - for (int i = 0; i < 13; i++) - { - string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); - Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); - dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); - } - - dt = ci.DateTimeFormat.Calendar.ToDateTime(5778, 1, 1, 0, 0, 0, 0); // non leap year - for (int i = 0; i < 12; i++) - { - string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); - Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); - dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); - } - } - - [Fact] - public void TestFirstYearOfJapaneseEra() - { - DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; - jpnFormat.Calendar = new JapaneseCalendar(); - - string pattern = "gg yyyy'\u5E74' MM'\u6708' dd'\u65E5'"; - DateTime dt = new DateTime(1989, 01, 08); // Start of Heisei Era - - string formattedDateWithGannen = "\u5E73\u6210 \u5143\u5E74 01\u6708 08\u65E5"; - - string formattedDate = dt.ToString(pattern, jpnFormat); - - Assert.True(DateTime.TryParseExact(formattedDate, pattern, jpnFormat, DateTimeStyles.None, out DateTime parsedDate)); - Assert.Equal(dt, parsedDate); - - // If the formatting with Gan-nen is supported, then parsing should succeed. otherwise parsing should fail. - Assert.True(formattedDate.IndexOf("\u5143", StringComparison.Ordinal) >= 0 == - DateTime.TryParseExact(formattedDateWithGannen, pattern, jpnFormat, DateTimeStyles.None, out parsedDate), - $"Parsing '{formattedDateWithGannen}' result should match if '{formattedDate}' has Gan-nen symbol" - ); - } - - [Fact] - public void JapaneseAbbreviatedEnglishEraNamesTest() - { - string [] eraNames = { "M", "T", "S", "H", "R" }; - - var ci = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() }}; - - int eraNumber = ci.DateTimeFormat.GetEra("Q"); - if (eraNumber == 4 || eraNumber == 5) - { - // Skip the test on Windows versions which have wrong Japanese Era information. - // Windows at some point used "Q" as fake era name before getting the official name. - return; - } - - int numberOfErasToTest = Math.Min(eraNames.Length, ci.DateTimeFormat.Calendar.Eras.Length); - for (int i = 0; i < numberOfErasToTest; i++) - { - Assert.Equal(i + 1, ci.DateTimeFormat.GetEra(eraNames[i])); - } - } + // [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + // public void Months_GetHebrew_ReturnsExpected() + // { + // CultureInfo ci = new CultureInfo("he-IL"); + // ci.DateTimeFormat.Calendar = new HebrewCalendar(); + + // Assert.Equal(13, ci.DateTimeFormat.MonthNames.Length); + // Assert.Equal(13, ci.DateTimeFormat.MonthGenitiveNames.Length); + // Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthNames.Length); + // Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthGenitiveNames.Length); + + // DateTime dt = ci.DateTimeFormat.Calendar.ToDateTime(5779, 1, 1, 0, 0, 0, 0); // leap year + // for (int i = 0; i < 13; i++) + // { + // string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); + // Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); + // dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); + // } + + // dt = ci.DateTimeFormat.Calendar.ToDateTime(5778, 1, 1, 0, 0, 0, 0); // non leap year + // for (int i = 0; i < 12; i++) + // { + // string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); + // Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); + // dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); + // } + // } + + // [Fact] + // public void TestFirstYearOfJapaneseEra() + // { + // DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; + // jpnFormat.Calendar = new JapaneseCalendar(); + + // string pattern = "gg yyyy'\u5E74' MM'\u6708' dd'\u65E5'"; + // DateTime dt = new DateTime(1989, 01, 08); // Start of Heisei Era + + // string formattedDateWithGannen = "\u5E73\u6210 \u5143\u5E74 01\u6708 08\u65E5"; + + // string formattedDate = dt.ToString(pattern, jpnFormat); + + // Assert.True(DateTime.TryParseExact(formattedDate, pattern, jpnFormat, DateTimeStyles.None, out DateTime parsedDate)); + // Assert.Equal(dt, parsedDate); + + // // If the formatting with Gan-nen is supported, then parsing should succeed. otherwise parsing should fail. + // Assert.True(formattedDate.IndexOf("\u5143", StringComparison.Ordinal) >= 0 == + // DateTime.TryParseExact(formattedDateWithGannen, pattern, jpnFormat, DateTimeStyles.None, out parsedDate), + // $"Parsing '{formattedDateWithGannen}' result should match if '{formattedDate}' has Gan-nen symbol" + // ); + // } + + // [Fact] + // public void JapaneseAbbreviatedEnglishEraNamesTest() + // { + // string [] eraNames = { "M", "T", "S", "H", "R" }; + + // var ci = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() }}; + + // int eraNumber = ci.DateTimeFormat.GetEra("Q"); + // if (eraNumber == 4 || eraNumber == 5) + // { + // // Skip the test on Windows versions which have wrong Japanese Era information. + // // Windows at some point used "Q" as fake era name before getting the official name. + // return; + // } + + // int numberOfErasToTest = Math.Min(eraNames.Length, ci.DateTimeFormat.Calendar.Eras.Length); + // for (int i = 0; i < numberOfErasToTest; i++) + // { + // Assert.Equal(i + 1, ci.DateTimeFormat.GetEra(eraNames[i])); + // } + // } [Fact] public void TestFrenchCanadaTimeFormat() diff --git a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj index eac50b0d2f3e0..3358f1f1bde45 100644 --- a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj +++ b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj @@ -2,6 +2,7 @@ $(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst true + true true @@ -74,5 +75,6 @@ + diff --git a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoData.cs b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoData.cs index 36ff2977b807d..96911b398714b 100644 --- a/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoData.cs +++ b/src/libraries/System.Globalization/tests/NumberFormatInfo/NumberFormatInfoData.cs @@ -7,7 +7,7 @@ internal static class NumberFormatInfoData { public static int[] UrINNumberGroupSizes() { - if (PlatformDetection.WindowsVersion >= 10 || PlatformDetection.ICUVersion.Major >= 55) + if (PlatformDetection.WindowsVersion >= 10 || PlatformDetection.ICUVersion.Major >= 55 || PlatformDetection.IsHybridGlobalizationOnOSX) { return new int[] { 3 }; } diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index 6fd30317d7f06..746f196e9d2c4 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -212,7 +212,7 @@ public static IEnumerable RegionInfo_TestData() } [Theory] - [MemberData(nameof(RegionInfo_TestData))] + [MemberData(nameof(RegionInfo_TestData))]// public void MiscTest(int lcid, int geoId, string currencyEnglishName, string currencyShortName, string alternativeCurrencyEnglishName, string currencyNativeName, string threeLetterISORegionName, string threeLetterWindowsRegionName) { RegionInfo ri = new RegionInfo(lcid); // create it with lcid diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 5628bf35fc506..3f80a4851b9df 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -1109,7 +1109,7 @@ internal string SpecificCultureName /// /// iso 639 language name, ie: eng - /// + /// // internal string ThreeLetterISOLanguageName => _sISO639Language2 ??= GetLocaleInfoCore(LocaleStringData.Iso639LanguageThreeLetterName); /// @@ -1211,7 +1211,7 @@ internal string LocalizedCountryName /// /// 3 letter ISO 3166 country code - /// + /// // internal string ThreeLetterISOCountryName => _sISO3166CountryName2 ??= GetLocaleInfoCore(LocaleStringData.Iso3166CountryName2); internal int KeyboardLayoutId diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs index 091f3a8f6561c..2c49623ce825b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs @@ -139,7 +139,7 @@ public virtual string Name /// /// Returns the three letter ISO region name (ie: USA) - /// + /// // public virtual string ThreeLetterISORegionName => _cultureData.ThreeLetterISOCountryName; /// diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index d8ab7da1fbee0..8495c1753cb2f 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -190,7 +190,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso639LanguageThreeLetterName: { NSString *iso639_2 = [currentLocale objectForKey:NSLocaleLanguageCode]; - value = uloc_getISO3LanguageByLangCode([iso639_2 UTF8String]); + value = uloc_getISO3LanguageByLangCode([iso639_2 UTF8String]);//implement without icu break; } case LocaleString_Iso3166CountryName: @@ -199,7 +199,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso3166CountryName2: { const char *countryCode = strdup([[currentLocale objectForKey:NSLocaleCountryCode] UTF8String]); - value = uloc_getISO3CountryByCountryCode(countryCode); + value = uloc_getISO3CountryByCountryCode(countryCode);//implement without icu break; } case LocaleString_NaNSymbol: From d5bcd128555dabf81bb5a8986a401a57d0af8c48 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 9 Oct 2023 16:33:44 +0200 Subject: [PATCH 003/105] Uncomment calendar test cases --- .../CompareInfoTests.LastIndexOf.cs | 2 +- .../DateTimeFormatInfoTests.cs | 200 +++++++++--------- .../System.Globalization.IOS.Tests.csproj | 4 +- 3 files changed, 103 insertions(+), 103 deletions(-) diff --git a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs index a64c77aa89d46..498290ccf8213 100644 --- a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs +++ b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.LastIndexOf.cs @@ -173,7 +173,7 @@ public static IEnumerable LastIndexOf_U_WithDiaeresis_TestData() [MemberData(nameof(LastIndexOf_TestData))] [MemberData(nameof(LastIndexOf_U_WithDiaeresis_TestData))] public void LastIndexOf_String(CompareInfo compareInfo, string source, string value, int startIndex, int count, CompareOptions options, int expected, int expectedMatchLength) - {// failing test case + { if (value.Length == 1) { LastIndexOf_Char(compareInfo, source, value[0], startIndex, count, options, expected); diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs index 740e5f8130906..eacdfb0455a67 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs @@ -59,34 +59,34 @@ public void DateSeparatorTimeSeparator_Get_ReturnsExpected() Assert.Equal(expectedFormattedString, d.ToString("HH:mm:ss", dtfi)); } - // [Theory] - // [MemberData(nameof(DateTimeFormatInfo_TestData))] - // public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Calendar calendar, string nativeCalendarName) - // { - // try - // { - // dtfi.Calendar = calendar; - - // if (PlatformDetection.IsNotUsingLimitedCultures) - // { - // // Mobile / Browser ICU doesn't contain NativeCalendarName, - // Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); - // } - // } - // catch - // { - // if (PlatformDetection.IsNlsGlobalization) - // { - // // Persian calendar is recently supported as one of the optional calendars for fa-IR - // Assert.True(calendar is PersianCalendar, "Exception can occur only with PersianCalendar"); - // } - // else // !PlatformDetection.IsNlsGlobalization - // { - // Assert.True(calendar is HijriCalendar || calendar is UmAlQuraCalendar || calendar is ThaiBuddhistCalendar || - // calendar is HebrewCalendar || calendar is KoreanCalendar, "failed to set the calendar on DTFI"); - // } - // } - // } + [Theory] + [MemberData(nameof(DateTimeFormatInfo_TestData))] + public void NativeCalendarName_Get_ReturnsExpected(DateTimeFormatInfo dtfi, Calendar calendar, string nativeCalendarName) + { + try + { + dtfi.Calendar = calendar; + + if (PlatformDetection.IsNotUsingLimitedCultures) + { + // Mobile / Browser ICU doesn't contain NativeCalendarName, + Assert.Equal(nativeCalendarName, dtfi.NativeCalendarName); + } + } + catch + { + if (PlatformDetection.IsNlsGlobalization) + { + // Persian calendar is recently supported as one of the optional calendars for fa-IR + Assert.True(calendar is PersianCalendar, "Exception can occur only with PersianCalendar"); + } + else // !PlatformDetection.IsNlsGlobalization + { + Assert.True(calendar is HijriCalendar || calendar is UmAlQuraCalendar || calendar is ThaiBuddhistCalendar || + calendar is HebrewCalendar || calendar is KoreanCalendar, "failed to set the calendar on DTFI"); + } + } + } [Theory] [MemberData(nameof(CultureNames_TestData))] @@ -138,78 +138,78 @@ public void GetShortestDayName_Invoke_ReturnsExpected(string cultureName) } } - // [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] - // public void Months_GetHebrew_ReturnsExpected() - // { - // CultureInfo ci = new CultureInfo("he-IL"); - // ci.DateTimeFormat.Calendar = new HebrewCalendar(); - - // Assert.Equal(13, ci.DateTimeFormat.MonthNames.Length); - // Assert.Equal(13, ci.DateTimeFormat.MonthGenitiveNames.Length); - // Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthNames.Length); - // Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthGenitiveNames.Length); - - // DateTime dt = ci.DateTimeFormat.Calendar.ToDateTime(5779, 1, 1, 0, 0, 0, 0); // leap year - // for (int i = 0; i < 13; i++) - // { - // string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); - // Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); - // dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); - // } - - // dt = ci.DateTimeFormat.Calendar.ToDateTime(5778, 1, 1, 0, 0, 0, 0); // non leap year - // for (int i = 0; i < 12; i++) - // { - // string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); - // Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); - // dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); - // } - // } - - // [Fact] - // public void TestFirstYearOfJapaneseEra() - // { - // DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; - // jpnFormat.Calendar = new JapaneseCalendar(); - - // string pattern = "gg yyyy'\u5E74' MM'\u6708' dd'\u65E5'"; - // DateTime dt = new DateTime(1989, 01, 08); // Start of Heisei Era - - // string formattedDateWithGannen = "\u5E73\u6210 \u5143\u5E74 01\u6708 08\u65E5"; - - // string formattedDate = dt.ToString(pattern, jpnFormat); - - // Assert.True(DateTime.TryParseExact(formattedDate, pattern, jpnFormat, DateTimeStyles.None, out DateTime parsedDate)); - // Assert.Equal(dt, parsedDate); - - // // If the formatting with Gan-nen is supported, then parsing should succeed. otherwise parsing should fail. - // Assert.True(formattedDate.IndexOf("\u5143", StringComparison.Ordinal) >= 0 == - // DateTime.TryParseExact(formattedDateWithGannen, pattern, jpnFormat, DateTimeStyles.None, out parsedDate), - // $"Parsing '{formattedDateWithGannen}' result should match if '{formattedDate}' has Gan-nen symbol" - // ); - // } - - // [Fact] - // public void JapaneseAbbreviatedEnglishEraNamesTest() - // { - // string [] eraNames = { "M", "T", "S", "H", "R" }; - - // var ci = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() }}; - - // int eraNumber = ci.DateTimeFormat.GetEra("Q"); - // if (eraNumber == 4 || eraNumber == 5) - // { - // // Skip the test on Windows versions which have wrong Japanese Era information. - // // Windows at some point used "Q" as fake era name before getting the official name. - // return; - // } - - // int numberOfErasToTest = Math.Min(eraNames.Length, ci.DateTimeFormat.Calendar.Eras.Length); - // for (int i = 0; i < numberOfErasToTest; i++) - // { - // Assert.Equal(i + 1, ci.DateTimeFormat.GetEra(eraNames[i])); - // } - // } + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + public void Months_GetHebrew_ReturnsExpected() + { + CultureInfo ci = new CultureInfo("he-IL"); + ci.DateTimeFormat.Calendar = new HebrewCalendar(); + + Assert.Equal(13, ci.DateTimeFormat.MonthNames.Length); + Assert.Equal(13, ci.DateTimeFormat.MonthGenitiveNames.Length); + Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthNames.Length); + Assert.Equal(13, ci.DateTimeFormat.AbbreviatedMonthGenitiveNames.Length); + + DateTime dt = ci.DateTimeFormat.Calendar.ToDateTime(5779, 1, 1, 0, 0, 0, 0); // leap year + for (int i = 0; i < 13; i++) + { + string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); + Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); + dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); + } + + dt = ci.DateTimeFormat.Calendar.ToDateTime(5778, 1, 1, 0, 0, 0, 0); // non leap year + for (int i = 0; i < 12; i++) + { + string formatted = dt.ToString(ci.DateTimeFormat.LongDatePattern, ci); + Assert.Equal(dt, DateTime.ParseExact(formatted, ci.DateTimeFormat.LongDatePattern, ci)); + dt = ci.DateTimeFormat.Calendar.AddMonths(dt, 1); + } + } + + [Fact] + public void TestFirstYearOfJapaneseEra() + { + DateTimeFormatInfo jpnFormat = new CultureInfo("ja-JP").DateTimeFormat; + jpnFormat.Calendar = new JapaneseCalendar(); + + string pattern = "gg yyyy'\u5E74' MM'\u6708' dd'\u65E5'"; + DateTime dt = new DateTime(1989, 01, 08); // Start of Heisei Era + + string formattedDateWithGannen = "\u5E73\u6210 \u5143\u5E74 01\u6708 08\u65E5"; + + string formattedDate = dt.ToString(pattern, jpnFormat); + + Assert.True(DateTime.TryParseExact(formattedDate, pattern, jpnFormat, DateTimeStyles.None, out DateTime parsedDate)); + Assert.Equal(dt, parsedDate); + + // If the formatting with Gan-nen is supported, then parsing should succeed. otherwise parsing should fail. + Assert.True(formattedDate.IndexOf("\u5143", StringComparison.Ordinal) >= 0 == + DateTime.TryParseExact(formattedDateWithGannen, pattern, jpnFormat, DateTimeStyles.None, out parsedDate), + $"Parsing '{formattedDateWithGannen}' result should match if '{formattedDate}' has Gan-nen symbol" + ); + } + + [Fact] + public void JapaneseAbbreviatedEnglishEraNamesTest() + { + string [] eraNames = { "M", "T", "S", "H", "R" }; + + var ci = new CultureInfo("ja-JP") { DateTimeFormat = { Calendar = new JapaneseCalendar() }}; + + int eraNumber = ci.DateTimeFormat.GetEra("Q"); + if (eraNumber == 4 || eraNumber == 5) + { + // Skip the test on Windows versions which have wrong Japanese Era information. + // Windows at some point used "Q" as fake era name before getting the official name. + return; + } + + int numberOfErasToTest = Math.Min(eraNames.Length, ci.DateTimeFormat.Calendar.Eras.Length); + for (int i = 0; i < numberOfErasToTest; i++) + { + Assert.Equal(i + 1, ci.DateTimeFormat.GetEra(eraNames[i])); + } + } [Fact] public void TestFrenchCanadaTimeFormat() diff --git a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj index 3358f1f1bde45..d143dba0e83a0 100644 --- a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj +++ b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj @@ -2,7 +2,7 @@ $(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst true - true + true @@ -75,6 +75,6 @@ - + From c2f7ac4e81cd6f5aa2bdf7e75f91cf732f18ec3a Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 16 Oct 2023 15:21:12 +0200 Subject: [PATCH 004/105] fix build failures --- .../Common/src/Interop/Interop.Locale.cs | 2 +- .../Common/src/Interop/Interop.Locale.iOS.cs | 8 ++ .../CultureInfoThreeLetterISOInfo.cs | 18 ++--- .../System.Globalization.IOS.Tests.csproj | 3 +- .../System/Globalization/CultureData.Icu.cs | 17 +++- .../System/Globalization/CultureInfo.Unix.cs | 17 +++- .../Globalization/GlobalizationMode.Unix.cs | 2 +- src/mono/mono/mini/CMakeLists.txt | 9 --- .../CMakeLists.txt | 24 +----- .../System.Globalization.Native/entrypoints.c | 80 ++++++++++--------- .../System.Globalization.Native/pal_casing.h | 1 + .../System.Globalization.Native/pal_icushim.c | 1 + .../pal_icushim_internal.h | 41 +++++----- .../pal_icushim_static.c | 20 ++--- .../System.Globalization.Native/pal_idna.h | 1 + .../System.Globalization.Native/pal_locale.h | 5 ++ .../System.Globalization.Native/pal_locale.m | 64 ++++++++++++++- .../pal_normalization.h | 1 + 18 files changed, 200 insertions(+), 114 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs index 051f2763a11b8..0ac42841f6f08 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.cs @@ -16,7 +16,7 @@ internal static partial class Globalization internal static unsafe partial bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength, string? uiLocaleName = null); [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleName", StringMarshalling = StringMarshalling.Utf16)] - [return: MarshalAs(UnmanagedType.Bool)] + [return: MarshalAs(UnmanagedType.Bool)]//implement for hybrid internal static unsafe partial bool GetDefaultLocaleName(char* value, int valueLength); [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocale", StringMarshalling = StringMarshalling.Utf16)] diff --git a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs index 0f7b1763d5850..1bc31432f91c6 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs @@ -13,6 +13,9 @@ internal static partial class Globalization [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoStringNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial string GetLocaleInfoStringNative(string localeName, uint localeStringData); + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleNameNative", StringMarshalling = StringMarshalling.Utf8)] + internal static unsafe partial string GetDefaultLocaleNameNative(); + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoIntNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial int GetLocaleInfoIntNative(string localeName, uint localeNumberData); @@ -24,5 +27,10 @@ internal static partial class Globalization [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleTimeFormatNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial string GetLocaleTimeFormatNative(string localeName, [MarshalAs(UnmanagedType.Bool)] bool shortFormat); + + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocalesNative", StringMarshalling = StringMarshalling.Utf16)] + internal static partial int GetLocalesNative([Out] char[]? value, int valueLength); + + } } diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs index 4801d9d9d1428..57ace0100ad67 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs @@ -18,14 +18,14 @@ public static IEnumerable RegionInfo_TestData() yield return new object[] { 0x40d, 117, "he-IL", "ISR", "heb" }; } - [Theory] - [MemberData(nameof(RegionInfo_TestData))] - public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName) - { - RegionInfo ri = new RegionInfo(lcid); // create it with lcid - Assert.Equal(geoId, ri.GeoId); - Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName); - Assert.Equal(threeLetterISOLanguageName, new CultureInfo(name).ThreeLetterISOLanguageName); - } + // [Theory] implement for hybrid mode + // [MemberData(nameof(RegionInfo_TestData))]// + // public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName) + // { + // RegionInfo ri = new RegionInfo(lcid); // create it with lcid + // Assert.Equal(geoId, ri.GeoId); + // Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName); + // Assert.Equal(threeLetterISOLanguageName, new CultureInfo(name).ThreeLetterISOLanguageName); + // } } } diff --git a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj index d143dba0e83a0..93bd0923df65b 100644 --- a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj +++ b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj @@ -1,8 +1,9 @@ $(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst + true true - + true true diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs index 0d4dad112249c..226cedcf648d8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs @@ -420,7 +420,15 @@ private static CultureInfo[] IcuEnumCultures(CultureTypes types) return Array.Empty(); } - int bufferLength = Interop.Globalization.GetLocales(null, 0); + int bufferLength; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + bufferLength = Interop.Globalization.GetLocalesNative(null, 0); + else + bufferLength = Interop.Globalization.GetLocales(null, 0); +#else + bufferLength = Interop.Globalization.GetLocales(null, 0); +#endif if (bufferLength <= 0) { return Array.Empty(); @@ -428,7 +436,14 @@ private static CultureInfo[] IcuEnumCultures(CultureTypes types) char [] chars = new char[bufferLength]; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + bufferLength = Interop.Globalization.GetLocalesNative(chars, bufferLength); + else + bufferLength = Interop.Globalization.GetLocales(chars, bufferLength); +#else bufferLength = Interop.Globalization.GetLocales(chars, bufferLength); +#endif if (bufferLength <= 0) { return Array.Empty(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs index a35b88c220609..361c218da2077 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs @@ -13,7 +13,22 @@ internal static CultureInfo GetUserDefaultCulture() return CultureInfo.InvariantCulture; CultureInfo cultureInfo; - if (CultureData.GetDefaultLocaleName(out string? localeName)) + string? localeName; + bool result = false; +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + { + localeName = Interop.Globalization.GetDefaultLocaleNameNative(); + result = localeName != null; + } + else + { + result = CultureData.GetDefaultLocaleName(out localeName); + } +#else + result = CultureData.GetDefaultLocaleName(out localeName); +#endif + if (result) { Debug.Assert(localeName != null); cultureInfo = GetCultureByName(localeName); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index d24f0b65719e8..a803ae918b2c2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -70,7 +70,7 @@ private static void LoadAppLocalIcuCore(ReadOnlySpan version, ReadOnlySpan // it on the same path, we load it before loading the other two libraries. LoadLibrary(CreateLibraryName("libicudata", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); #endif - +// IntPtr icuucLib = LoadLibrary(CreateLibraryName("libicuuc", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); IntPtr icuinLib = LoadLibrary(CreateLibraryName("libicui18n", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index b7d7b6d029a59..8a3ff296bd864 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -55,15 +55,6 @@ if(HAVE_SYS_ICU) endif() set(icu_shim_sources_base - pal_calendarData.c - pal_casing.c - pal_collation.c - pal_idna.c - pal_locale.c - pal_localeNumberData.c - pal_localeStringData.c - pal_normalization.c - pal_timeZoneInfo.c entrypoints.c ${pal_icushim_sources_base}) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 25f91b4cfab08..3b4596d4618cc 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -21,10 +21,9 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") endif() - find_path(UCURR_H "unicode/ucurr.h" PATHS ${ICU_HOMEBREW_INC_PATH}) + find_path(UCURR_H "unicode/ucurr.h") if(UCURR_H STREQUAL UCURR_H-NOTFOUND) message(FATAL_ERROR "Cannot find ucurr.h, try installing libicu-dev (or the appropriate package for your platform)") return() @@ -53,22 +52,6 @@ endif() include(configure.cmake) -set(NATIVEGLOBALIZATION_SOURCES - pal_calendarData.c - pal_casing.c - pal_collation.c - pal_idna.c - pal_locale.c - pal_localeNumberData.c - pal_localeStringData.c - pal_normalization.c -) - -if (DEFINED CMAKE_ICU_DIR) - include_directories(${CMAKE_ICU_DIR}/include) - link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) - link_libraries(stdc++) -endif() if (CMAKE_USE_PTHREADS) add_compile_options(-pthread) @@ -104,10 +87,7 @@ if (CLR_CMAKE_TARGET_APPLE) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} ${NATIVEGLOBALIZATION_SOURCES_OBJC}) endif() -# time zone names are filtered out of icu data for the browser and associated functionality is disabled -if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) - set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) -endif() + if (MSVC) set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 1cae8c378b828..6dcb04be7d412 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,45 +19,45 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { - DllImportEntry(GlobalizationNative_ChangeCase) - DllImportEntry(GlobalizationNative_ChangeCaseInvariant) - DllImportEntry(GlobalizationNative_ChangeCaseTurkish) - DllImportEntry(GlobalizationNative_CloseSortHandle) - DllImportEntry(GlobalizationNative_CompareString) - DllImportEntry(GlobalizationNative_EndsWith) - DllImportEntry(GlobalizationNative_EnumCalendarInfo) - DllImportEntry(GlobalizationNative_GetCalendarInfo) - DllImportEntry(GlobalizationNative_GetCalendars) - DllImportEntry(GlobalizationNative_GetDefaultLocaleName) - DllImportEntry(GlobalizationNative_GetICUVersion) - DllImportEntry(GlobalizationNative_GetJapaneseEraStartDate) - DllImportEntry(GlobalizationNative_GetLatestJapaneseEra) - DllImportEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) - DllImportEntry(GlobalizationNative_GetLocaleInfoInt) - DllImportEntry(GlobalizationNative_GetLocaleInfoString) - DllImportEntry(GlobalizationNative_GetLocaleName) - DllImportEntry(GlobalizationNative_GetLocales) - DllImportEntry(GlobalizationNative_GetLocaleTimeFormat) - DllImportEntry(GlobalizationNative_GetSortHandle) - DllImportEntry(GlobalizationNative_GetSortKey) - DllImportEntry(GlobalizationNative_GetSortVersion) - DllImportEntry(GlobalizationNative_GetTimeZoneDisplayName) - DllImportEntry(GlobalizationNative_IanaIdToWindowsId) - DllImportEntry(GlobalizationNative_IndexOf) - DllImportEntry(GlobalizationNative_InitICUFunctions) - DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) - DllImportEntry(GlobalizationNative_IsNormalized) - DllImportEntry(GlobalizationNative_IsPredefinedLocale) - DllImportEntry(GlobalizationNative_LastIndexOf) - DllImportEntry(GlobalizationNative_LoadICU) -#if defined(STATIC_ICU) - DllImportEntry(GlobalizationNative_LoadICUData) -#endif - DllImportEntry(GlobalizationNative_NormalizeString) - DllImportEntry(GlobalizationNative_StartsWith) - DllImportEntry(GlobalizationNative_ToAscii) - DllImportEntry(GlobalizationNative_ToUnicode) - DllImportEntry(GlobalizationNative_WindowsIdToIanaId) +// DllImportEntry(GlobalizationNative_ChangeCase) +// DllImportEntry(GlobalizationNative_ChangeCaseInvariant) +// DllImportEntry(GlobalizationNative_ChangeCaseTurkish) +// DllImportEntry(GlobalizationNative_CloseSortHandle) +// DllImportEntry(GlobalizationNative_CompareString) +// DllImportEntry(GlobalizationNative_EndsWith) +// DllImportEntry(GlobalizationNative_EnumCalendarInfo) +// DllImportEntry(GlobalizationNative_GetCalendarInfo) +// DllImportEntry(GlobalizationNative_GetCalendars) +// DllImportEntry(GlobalizationNative_GetDefaultLocaleName) +// DllImportEntry(GlobalizationNative_GetICUVersion) +// DllImportEntry(GlobalizationNative_GetJapaneseEraStartDate) +// DllImportEntry(GlobalizationNative_GetLatestJapaneseEra) +// DllImportEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) +// DllImportEntry(GlobalizationNative_GetLocaleInfoInt) +// DllImportEntry(GlobalizationNative_GetLocaleInfoString) +// DllImportEntry(GlobalizationNative_GetLocaleName) +// DllImportEntry(GlobalizationNative_GetLocales) +// DllImportEntry(GlobalizationNative_GetLocaleTimeFormat) +// DllImportEntry(GlobalizationNative_GetSortHandle) +// DllImportEntry(GlobalizationNative_GetSortKey) +// DllImportEntry(GlobalizationNative_GetSortVersion) +// DllImportEntry(GlobalizationNative_GetTimeZoneDisplayName) +// DllImportEntry(GlobalizationNative_IanaIdToWindowsId) +// DllImportEntry(GlobalizationNative_IndexOf) +// DllImportEntry(GlobalizationNative_InitICUFunctions) +// DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) +// DllImportEntry(GlobalizationNative_IsNormalized) +// DllImportEntry(GlobalizationNative_IsPredefinedLocale) +// DllImportEntry(GlobalizationNative_LastIndexOf) +// DllImportEntry(GlobalizationNative_LoadICU) +// #if defined(STATIC_ICU) +// DllImportEntry(GlobalizationNative_LoadICUData) +// #endif +// DllImportEntry(GlobalizationNative_NormalizeString) +// DllImportEntry(GlobalizationNative_StartsWith) +// DllImportEntry(GlobalizationNative_ToAscii) +// DllImportEntry(GlobalizationNative_ToUnicode) +// DllImportEntry(GlobalizationNative_WindowsIdToIanaId) #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) @@ -72,12 +72,14 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_GetLocaleInfoSecondaryGroupingSizeNative) DllImportEntry(GlobalizationNative_GetLocaleInfoStringNative) DllImportEntry(GlobalizationNative_GetLocaleNameNative) + DllImportEntry(GlobalizationNative_GetLocalesNative) DllImportEntry(GlobalizationNative_GetLocaleTimeFormatNative) DllImportEntry(GlobalizationNative_GetTimeZoneDisplayNameNative) DllImportEntry(GlobalizationNative_IndexOfNative) DllImportEntry(GlobalizationNative_IsNormalizedNative) DllImportEntry(GlobalizationNative_NormalizeStringNative) DllImportEntry(GlobalizationNative_StartsWithNative) + DllImportEntry(GlobalizationNative_GetDefaultLocaleNameNative) #endif }; diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index e39d38ecb1c11..75c3386ca9709 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,6 +3,7 @@ #include "pal_locale.h" #include "pal_compiler.h" +#include "pal_icushim_internal.h" PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, diff --git a/src/native/libs/System.Globalization.Native/pal_icushim.c b/src/native/libs/System.Globalization.Native/pal_icushim.c index 11b4ea6b748b3..10a2870a1d54e 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim.c @@ -264,6 +264,7 @@ static void GetVersionedLibFileName(const char* baseFileName, int majorVer, int // Try to open the necessary ICU libraries static int OpenICULibraries(int majorVer, int minorVer, int subVer, const char* versionPrefix, char* symbolName, char* symbolVersion) { +// char libicuucName[VERSIONED_LIB_NAME_LEN]; char libicui18nName[VERSIONED_LIB_NAME_LEN]; diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index bc04acaf55b1e..444a56bb3b602 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -18,28 +18,33 @@ #if !defined(LOCAL_BUILD) #define U_DISABLE_RENAMING 1 #endif +#ifdef __OBJC__ +// This code will only be included when compiling Objective-C code +// #import + // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include +// #include #include -#include -#include +// #include +// #include +#endif // __OBJC__ #endif diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 1fe5c1078dd1d..6d6cd9d7cdc97 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -10,7 +10,7 @@ #include #include #include -#include +// #include #if defined(TARGET_UNIX) #include @@ -26,16 +26,16 @@ static void log_shim_error(const char* format, ...) { va_list args; - va_start(args, format); - vfprintf(stderr, format, args); + //va_start(args, format); + //vfprintf(stderr, format, args); fputc('\n', stderr); - va_end(args); + //va_end(args); } static void log_icu_error(const char* name, UErrorCode status) { - const char * statusText = u_errorName(status); - log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText); + // const char * statusText = u_errorName(status); + // log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText); } #if defined(ICU_TRACING) @@ -83,7 +83,7 @@ static int32_t load_icu_data(const void* pData) { UErrorCode status = 0; - udata_setCommonData(pData, &status); + //udata_setCommonData(pData, &status); if (U_FAILURE(status)) { @@ -169,7 +169,7 @@ cstdlib_load_icu_data(const char *path) int32_t GlobalizationNative_LoadICUData(const char* path) -{// +{ #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) if (path && path[0] != '/') { @@ -217,7 +217,7 @@ int32_t GlobalizationNative_LoadICU(void) UVersionInfo version; // Request the CLDR version to perform basic ICU initialization and find out // whether it worked. - ulocdata_getCLDRVersion(version, &status); + //ulocdata_getCLDRVersion(version, &status); if (U_FAILURE(status)) { @@ -243,7 +243,7 @@ int32_t GlobalizationNative_GetICUVersion(void) return 0; UVersionInfo versionInfo; - u_getVersion(versionInfo); + // u_getVersion(versionInfo); return (versionInfo[0] << 24) + (versionInfo[1] << 16) + (versionInfo[2] << 8) + versionInfo[3]; } diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index d50f90f36ad94..df440d67d7da8 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -6,6 +6,7 @@ #include "pal_locale.h" #include "pal_compiler.h" +#include "pal_icushim_internal.h" PALEXPORT int32_t GlobalizationNative_ToAscii(uint32_t flags, const UChar* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 7fe89f667f213..03cd79beac7c5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -4,6 +4,7 @@ #pragma once #include "pal_compiler.h" +#include "pal_icushim_internal.h" PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); @@ -18,7 +19,11 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #ifdef __APPLE__ +PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); + PALEXPORT const char* GlobalizationNative_GetLocaleNameNative(const char* localeName); PALEXPORT const char* GlobalizationNative_GetLocaleTimeFormatNative(const char* localeName, int shortFormat); + +PALEXPORT int32_t GlobalizationNative_GetLocalesNative(char* locales, int32_t length); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 8495c1753cb2f..ea3ee5cd6f7d2 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -190,7 +190,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso639LanguageThreeLetterName: { NSString *iso639_2 = [currentLocale objectForKey:NSLocaleLanguageCode]; - value = uloc_getISO3LanguageByLangCode([iso639_2 UTF8String]);//implement without icu + value = "";//uloc_getISO3LanguageByLangCode([iso639_2 UTF8String]);////implement without icu break; } case LocaleString_Iso3166CountryName: @@ -199,7 +199,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso3166CountryName2: { const char *countryCode = strdup([[currentLocale objectForKey:NSLocaleCountryCode] UTF8String]); - value = uloc_getISO3CountryByCountryCode(countryCode);//implement without icu + value = "";//uloc_getISO3CountryByCountryCode(countryCode);////implement without icu break; } case LocaleString_NaNSymbol: @@ -689,4 +689,64 @@ Returns time format information (in native format, it needs to be converted to . return strdup([dataPath UTF8String]); } } + +const char* GlobalizationNative_GetDefaultLocaleNameNative(void) +{ + @autoreleasepool + { + NSLocale *currentLocale = [NSLocale currentLocale]; + NSString *localeName = @""; + + if (!currentLocale) + { + return strdup([localeName UTF8String]); + } + + if ([currentLocale.languageCode length] > 0 && [currentLocale.countryCode length] > 0) + { + localeName = [NSString stringWithFormat:@"%@-%@", currentLocale.languageCode, currentLocale.countryCode]; + } + else + { + localeName = currentLocale.localeIdentifier; + } + + return strdup([localeName UTF8String]); + } +} + +int32_t GlobalizationNative_GetLocalesNative(char* value, int32_t length) +{ + NSArray* availableLocaleIdentifiers = [NSLocale availableLocaleIdentifiers]; + int32_t index = 0; + int32_t totalLength = 0; + for (NSInteger i = 0; i < [availableLocaleIdentifiers count]; i++) + { + NSString *localeIdentifier = availableLocaleIdentifiers[i]; + const char* pLocaleName = [localeIdentifier UTF8String]; + int32_t localeNameLength = (int32_t)strlen(pLocaleName); + totalLength += localeNameLength + 1; // add 1 for the name length + if (value != NULL) + { + if (totalLength > length) + return -3; + + value[index++] = (UChar) localeNameLength; + + for (int j=0; j Date: Tue, 17 Oct 2023 09:03:25 -0400 Subject: [PATCH 005/105] Remove other ICU references --- eng/testing/tests.ioslike.targets | 3 +++ src/mono/CMakeLists.txt | 2 +- src/mono/mono/mini/CMakeLists.txt | 2 +- .../libs/System.Globalization.Native/CMakeLists.txt | 9 ++++++--- src/native/libs/build-native.proj | 2 +- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index 76b8b004b9f33..5d41f23a62287 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -157,6 +157,9 @@ + + true + true true AppleTestRunner.dll diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 62220db825721..db1d652374680 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -741,7 +741,7 @@ elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) - set(ICU_LIBS icuuc icui18n icudata) + #set(ICU_LIBS icuuc icui18n icudata) elseif(HOST_ANDROID) set(ICU_FLAGS "-DPALEXPORT=\"\" -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -DTARGET_ANDROID -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 8a3ff296bd864..985eee50e065f 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -413,7 +413,7 @@ if(NOT DISABLE_SHARED_LIBS) # to avoid a conflict we rename the import library with the .import.lib suffix set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib") endif() - target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 3b4596d4618cc..31b8db69aaa8b 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -18,7 +18,8 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-extra-semi-stmt) add_compile_options(-Wno-unknown-warning-option) - if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ICU_DIR) + # The mobile configurations in particular bring their own ICU, so skip + if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) endif() @@ -52,6 +53,10 @@ endif() include(configure.cmake) +#if (DEFINED CMAKE_ICU_DIR) +# include_directories(${CMAKE_ICU_DIR}/include) +#endif() + if (CMAKE_USE_PTHREADS) add_compile_options(-pthread) @@ -87,8 +92,6 @@ if (CLR_CMAKE_TARGET_APPLE) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} ${NATIVEGLOBALIZATION_SOURCES_OBJC}) endif() - - if (MSVC) set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) endif() diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index f0b394604a7a2..ca92818606800 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -16,7 +16,7 @@ <_UsePThreads /> <_UsePThreads Condition="'$(MonoWasmBuildVariant)' == 'multithread'"> usepthreads - <_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native + <_IcuDir Condition="'$(TargetsAppleMobile)' != 'true' and '$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native <_IcuDirArg Condition="'$(_IcuDir)' != ''"> icudir "$(_IcuDir)" <_BuildNativeArgs>$(_BuildNativeArgs)$(_IcuDirArg)$(_UsePThreads) From 47f0271afccc1bf4a4d6ace5f63906776e4bcf15 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 18 Oct 2023 16:48:00 +0200 Subject: [PATCH 006/105] Load pal_idna.c --- src/mono/mono/mini/CMakeLists.txt | 9 +++++++++ .../libs/System.Globalization.Native/CMakeLists.txt | 11 +++++++++++ .../pal_icushim_internal.h | 6 ++++-- .../libs/System.Globalization.Native/pal_idna.h | 2 ++ .../libs/System.Globalization.Native/pal_locale.h | 1 + 5 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 985eee50e065f..45ac9c38840df 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -55,6 +55,15 @@ if(HAVE_SYS_ICU) endif() set(icu_shim_sources_base + #pal_calendarData.c + #pal_casing.c + #pal_collation.c + pal_idna.c + #pal_locale.c + #pal_localeNumberData.c + #pal_localeStringData.c + #pal_normalization.c + #pal_timeZoneInfo.c entrypoints.c ${pal_icushim_sources_base}) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 31b8db69aaa8b..d58e322184ca6 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -53,6 +53,17 @@ endif() include(configure.cmake) +set(NATIVEGLOBALIZATION_SOURCES + #pal_calendarData.c + #pal_casing.c + #pal_collation.c + pal_idna.c + #pal_locale.c + #pal_localeNumberData.c + #pal_localeStringData.c + #pal_normalization.c +) + #if (DEFINED CMAKE_ICU_DIR) # include_directories(${CMAKE_ICU_DIR}/include) #endif() diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 444a56bb3b602..8ee3292f7ec09 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -20,7 +20,8 @@ #endif #ifdef __OBJC__ // This code will only be included when compiling Objective-C code -// #import +#import +#include // All ICU headers need to be included here so that all function prototypes are @@ -35,7 +36,8 @@ // #include // #include // #include -// #include + #include + #include // #include // #include // #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index df440d67d7da8..797bdb85f6d53 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,6 +7,8 @@ #include "pal_locale.h" #include "pal_compiler.h" #include "pal_icushim_internal.h" +#include +#include PALEXPORT int32_t GlobalizationNative_ToAscii(uint32_t flags, const UChar* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 03cd79beac7c5..d9c6ca421977e 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -5,6 +5,7 @@ #include "pal_compiler.h" #include "pal_icushim_internal.h" +#include PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); From 82c04b1edaba4a2a27a0ef4a800d972ed0486965 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 18 Oct 2023 17:29:08 +0200 Subject: [PATCH 007/105] clean the branch --- src/libraries/Common/src/Interop/Interop.Locale.cs | 2 +- .../tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs | 4 ++-- .../tests/System/Globalization/RegionInfoTests.cs | 2 +- .../src/System/Globalization/CultureData.cs | 2 +- .../src/System/Globalization/GlobalizationMode.Unix.cs | 2 +- .../src/System/Globalization/RegionInfo.cs | 2 +- src/native/libs/System.Globalization.Native/CMakeLists.txt | 6 ++++++ src/native/libs/System.Globalization.Native/pal_icushim.c | 1 - 8 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs index 0ac42841f6f08..051f2763a11b8 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.cs @@ -16,7 +16,7 @@ internal static partial class Globalization internal static unsafe partial bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength, string? uiLocaleName = null); [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleName", StringMarshalling = StringMarshalling.Utf16)] - [return: MarshalAs(UnmanagedType.Bool)]//implement for hybrid + [return: MarshalAs(UnmanagedType.Bool)] internal static unsafe partial bool GetDefaultLocaleName(char* value, int valueLength); [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocale", StringMarshalling = StringMarshalling.Utf16)] diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs index 57ace0100ad67..57112048e73b3 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs @@ -18,8 +18,8 @@ public static IEnumerable RegionInfo_TestData() yield return new object[] { 0x40d, 117, "he-IL", "ISR", "heb" }; } - // [Theory] implement for hybrid mode - // [MemberData(nameof(RegionInfo_TestData))]// + // [Theory] + // [MemberData(nameof(RegionInfo_TestData))] // public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName) // { // RegionInfo ri = new RegionInfo(lcid); // create it with lcid diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index 746f196e9d2c4..6fd30317d7f06 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -212,7 +212,7 @@ public static IEnumerable RegionInfo_TestData() } [Theory] - [MemberData(nameof(RegionInfo_TestData))]// + [MemberData(nameof(RegionInfo_TestData))] public void MiscTest(int lcid, int geoId, string currencyEnglishName, string currencyShortName, string alternativeCurrencyEnglishName, string currencyNativeName, string threeLetterISORegionName, string threeLetterWindowsRegionName) { RegionInfo ri = new RegionInfo(lcid); // create it with lcid diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 3f80a4851b9df..34c71891afd40 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -1211,7 +1211,7 @@ internal string LocalizedCountryName /// /// 3 letter ISO 3166 country code - /// // + /// internal string ThreeLetterISOCountryName => _sISO3166CountryName2 ??= GetLocaleInfoCore(LocaleStringData.Iso3166CountryName2); internal int KeyboardLayoutId diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index a803ae918b2c2..d24f0b65719e8 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -70,7 +70,7 @@ private static void LoadAppLocalIcuCore(ReadOnlySpan version, ReadOnlySpan // it on the same path, we load it before loading the other two libraries. LoadLibrary(CreateLibraryName("libicudata", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); #endif -// + IntPtr icuucLib = LoadLibrary(CreateLibraryName("libicuuc", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); IntPtr icuinLib = LoadLibrary(CreateLibraryName("libicui18n", suffixAndSeparator, extension, version, versionAtEnd), failOnLoadFailure: true); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs index 2c49623ce825b..091f3a8f6561c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/RegionInfo.cs @@ -139,7 +139,7 @@ public virtual string Name /// /// Returns the three letter ISO region name (ie: USA) - /// // + /// public virtual string ThreeLetterISORegionName => _cultureData.ThreeLetterISOCountryName; /// diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index d58e322184ca6..6f01656d8fb61 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -103,6 +103,12 @@ if (CLR_CMAKE_TARGET_APPLE) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} ${NATIVEGLOBALIZATION_SOURCES_OBJC}) endif() + +# time zone names are filtered out of icu data for the browser and associated functionality is disabled +#if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) +# set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) +#endif() + if (MSVC) set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) endif() diff --git a/src/native/libs/System.Globalization.Native/pal_icushim.c b/src/native/libs/System.Globalization.Native/pal_icushim.c index 10a2870a1d54e..11b4ea6b748b3 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim.c @@ -264,7 +264,6 @@ static void GetVersionedLibFileName(const char* baseFileName, int majorVer, int // Try to open the necessary ICU libraries static int OpenICULibraries(int majorVer, int minorVer, int subVer, const char* versionPrefix, char* symbolName, char* symbolVersion) { -// char libicuucName[VERSIONED_LIB_NAME_LEN]; char libicui18nName[VERSIONED_LIB_NAME_LEN]; From d3fcc603fb1282621937b9f6ca8be0f12a309c02 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 20 Oct 2023 13:59:56 +0200 Subject: [PATCH 008/105] Remove not needed function --- .../src/System/Globalization/CultureData.cs | 2 +- .../CMakeLists.txt | 1 - .../System.Globalization.Native/pal_locale.m | 34 ------------------- 3 files changed, 1 insertion(+), 36 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 34c71891afd40..5628bf35fc506 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -1109,7 +1109,7 @@ internal string SpecificCultureName /// /// iso 639 language name, ie: eng - /// // + /// internal string ThreeLetterISOLanguageName => _sISO639Language2 ??= GetLocaleInfoCore(LocaleStringData.Iso639LanguageThreeLetterName); /// diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index fcdd2cc6490d3..54c3779d78b10 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -106,7 +106,6 @@ if (CLR_CMAKE_TARGET_APPLE) set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} ${NATIVEGLOBALIZATION_SOURCES_OBJC}) endif() - # time zone names are filtered out of icu data for the browser and associated functionality is disabled #if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) # set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index b0959035910c9..9940f8c976b71 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -760,38 +760,4 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } -int32_t GlobalizationNative_GetLocalesNative(char* value, int32_t length) -{ - NSArray* availableLocaleIdentifiers = [NSLocale availableLocaleIdentifiers]; - int32_t index = 0; - int32_t totalLength = 0; - for (NSInteger i = 0; i < [availableLocaleIdentifiers count]; i++) - { - NSString *localeIdentifier = availableLocaleIdentifiers[i]; - const char* pLocaleName = [localeIdentifier UTF8String]; - int32_t localeNameLength = (int32_t)strlen(pLocaleName); - totalLength += localeNameLength + 1; // add 1 for the name length - if (value != NULL) - { - if (totalLength > length) - return -3; - - value[index++] = (UChar) localeNameLength; - - for (int j=0; j Date: Fri, 20 Oct 2023 14:27:44 +0200 Subject: [PATCH 009/105] minor fix --- .../libs/System.Globalization.Native/pal_icushim_internal.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_locale.m | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 8ee3292f7ec09..dadd5dfe46798 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -36,8 +36,8 @@ // #include // #include // #include - #include - #include +// #include +// #include // #include // #include // #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 9940f8c976b71..e6b2c7245ad4c 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -190,7 +190,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso639LanguageThreeLetterName: { NSString *iso639_2 = [currentLocale objectForKey:NSLocaleLanguageCode]; - return iso639_2 == nil ? strdup("") : strdup(uloc_getISO3LanguageByLangCode([iso639_2 UTF8String])); + return strdup("");//iso639_2 == nil ? strdup("") : strdup(uloc_getISO3LanguageByLangCode([iso639_2 UTF8String])); } case LocaleString_Iso3166CountryName: value = [currentLocale objectForKey:NSLocaleCountryCode]; @@ -198,7 +198,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso3166CountryName2: { NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; - return countryCode == nil ? strdup("") : strdup(uloc_getISO3CountryByCountryCode([countryCode UTF8String])); + return strdup("");//countryCode == nil ? strdup("") : strdup(uloc_getISO3CountryByCountryCode([countryCode UTF8String])); } case LocaleString_NaNSymbol: value = numberFormatter.notANumberSymbol; From 2e0900c448421d9ce62aab15731383380ae3173f Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 23 Oct 2023 11:09:37 +0200 Subject: [PATCH 010/105] Add country and language tables --- .../CultureInfoThreeLetterISOInfo.cs | 18 +- .../System.Globalization.Native/pal_locale.h | 373 ++++++++++++++++++ .../System.Globalization.Native/pal_locale.m | 46 ++- 3 files changed, 426 insertions(+), 11 deletions(-) diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs index 57112048e73b3..4801d9d9d1428 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoThreeLetterISOInfo.cs @@ -18,14 +18,14 @@ public static IEnumerable RegionInfo_TestData() yield return new object[] { 0x40d, 117, "he-IL", "ISR", "heb" }; } - // [Theory] - // [MemberData(nameof(RegionInfo_TestData))] - // public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName) - // { - // RegionInfo ri = new RegionInfo(lcid); // create it with lcid - // Assert.Equal(geoId, ri.GeoId); - // Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName); - // Assert.Equal(threeLetterISOLanguageName, new CultureInfo(name).ThreeLetterISOLanguageName); - // } + [Theory] + [MemberData(nameof(RegionInfo_TestData))] + public void MiscTest(int lcid, int geoId, string name, string threeLetterISORegionName, string threeLetterISOLanguageName) + { + RegionInfo ri = new RegionInfo(lcid); // create it with lcid + Assert.Equal(geoId, ri.GeoId); + Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName); + Assert.Equal(threeLetterISOLanguageName, new CultureInfo(name).ThreeLetterISOLanguageName); + } } } diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index bdd5361c4722b..e8bc41ad3a8e0 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -7,6 +7,379 @@ #include "pal_icushim_internal.h" #include +/* ### Data tables **************************************************/ + +/** + * Table of language codes, both 2- and 3-letter, with preference + * given to 2-letter codes where possible. Includes 3-letter codes + * that lack a 2-letter equivalent. + * + * This list must be in sorted order. This list is returned directly + * to the user by some API. + * + * This list must be kept in sync with LANGUAGES_3, with corresponding + * entries matched. + * + * This table should be terminated with a NULL entry, followed by a + * second list, and another NULL entry. The first list is visible to + * user code when this array is returned by API. The second list + * contains codes we support, but do not expose through user API. + * + * Notes + * + * Tables updated per http://lcweb.loc.gov/standards/iso639-2/ to + * include the revisions up to 2001/7/27 *CWB* + * + * The 3 character codes are the terminology codes like RFC 3066. + * + * "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in the + * table but now at the end of the table because 3 character codes are + * duplicates. This avoids bad searches going from 3 to 2 character + * codes. + * + * The range qaa-qtz is reserved for local use + */ +/* Subsequent hand addition of selected languages */ +static const char * const LANGUAGES[] = { + "aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb", + "af", "afh", "agq", "ain", "ak", "akk", "akz", "ale", + "aln", "alt", "am", "an", "ang", "anp", "ar", "arc", + "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "as", + "asa", "ase", "ast", "av", "avk", "awa", "ay", "az", + "ba", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", + "be", "bej", "bem", "bew", "bez", "bfd", "bfq", "bg", + "bgn", "bho", "bi", "bik", "bin", "bjn", "bkm", "bla", + "bm", "bn", "bo", "bpy", "bqi", "br", "bra", "brh", + "brx", "bs", "bss", "bua", "bug", "bum", "byn", "byv", + "ca", "cad", "car", "cay", "cch", "ccp", "ce", "ceb", "cgg", + "ch", "chb", "chg", "chk", "chm", "chn", "cho", "chp", + "chr", "chy", "ckb", "co", "cop", "cps", "cr", "crh", + "cs", "csb", "cu", "cv", "cy", + "da", "dak", "dar", "dav", "de", "del", "den", "dgr", + "din", "dje", "doi", "dsb", "dtp", "dua", "dum", "dv", + "dyo", "dyu", "dz", "dzg", + "ebu", "ee", "efi", "egl", "egy", "eka", "el", "elx", + "en", "enm", "eo", "es", "esu", "et", "eu", "ewo", + "ext", + "fa", "fan", "fat", "ff", "fi", "fil", "fit", "fj", + "fo", "fon", "fr", "frc", "frm", "fro", "frp", "frr", + "frs", "fur", "fy", + "ga", "gaa", "gag", "gan", "gay", "gba", "gbz", "gd", + "gez", "gil", "gl", "glk", "gmh", "gn", "goh", "gom", + "gon", "gor", "got", "grb", "grc", "gsw", "gu", "guc", + "gur", "guz", "gv", "gwi", + "ha", "hai", "hak", "haw", "he", "hi", "hif", "hil", + "hit", "hmn", "ho", "hr", "hsb", "hsn", "ht", "hu", + "hup", "hy", "hz", + "ia", "iba", "ibb", "id", "ie", "ig", "ii", "ik", + "ilo", "inh", "io", "is", "it", "iu", "izh", + "ja", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut", + "jv", + "ka", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd", + "kbl", "kcg", "kde", "kea", "ken", "kfo", "kg", "kgp", + "kha", "kho", "khq", "khw", "ki", "kiu", "kj", "kk", + "kkj", "kl", "kln", "km", "kmb", "kn", "ko", "koi", + "kok", "kos", "kpe", "kr", "krc", "kri", "krj", "krl", + "kru", "ks", "ksb", "ksf", "ksh", "ku", "kum", "kut", + "kv", "kw", "ky", + "la", "lad", "lag", "lah", "lam", "lb", "lez", "lfn", + "lg", "li", "lij", "liv", "lkt", "lmo", "ln", "lo", + "lol", "loz", "lrc", "lt", "ltg", "lu", "lua", "lui", + "lun", "luo", "lus", "luy", "lv", "lzh", "lzz", + "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", + "mdf", "mdh", "mdr", "men", "mer", "mfe", "mg", "mga", + "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", + "ml", "mn", "mnc", "mni", "mo", + "moh", "mos", "mr", "mrj", + "ms", "mt", "mua", "mul", "mus", "mwl", "mwr", "mwv", + "my", "mye", "myv", "mzn", + "na", "nan", "nap", "naq", "nb", "nd", "nds", "ne", + "new", "ng", "nia", "niu", "njo", "nl", "nmg", "nn", + "nnh", "no", "nog", "non", "nov", "nqo", "nr", "nso", + "nus", "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", + "oc", "oj", "om", "or", "os", "osa", "ota", + "pa", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", + "pdt", "peo", "pfl", "phn", "pi", "pl", "pms", "pnt", + "pon", "prg", "pro", "ps", "pt", + "qu", "quc", "qug", + "raj", "rap", "rar", "rgn", "rif", "rm", "rn", "ro", + "rof", "rom", "rtm", "ru", "rue", "rug", "rup", + "rw", "rwk", + "sa", "sad", "sah", "sam", "saq", "sas", "sat", "saz", + "sba", "sbp", "sc", "scn", "sco", "sd", "sdc", "sdh", + "se", "see", "seh", "sei", "sel", "ses", "sg", "sga", + "sgs", "shi", "shn", "shu", "si", "sid", "sk", + "sl", "sli", "sly", "sm", "sma", "smj", "smn", "sms", + "sn", "snk", "so", "sog", "sq", "sr", "srn", "srr", + "ss", "ssy", "st", "stq", "su", "suk", "sus", "sux", + "sv", "sw", "swb", "swc", "syc", "syr", "szl", + "ta", "tcy", "te", "tem", "teo", "ter", "tet", "tg", + "th", "ti", "tig", "tiv", "tk", "tkl", "tkr", "tl", + "tlh", "tli", "tly", "tmh", "tn", "to", "tog", "tpi", + "tr", "tru", "trv", "ts", "tsd", "tsi", "tt", "ttt", + "tum", "tvl", "tw", "twq", "ty", "tyv", "tzm", + "udm", "ug", "uga", "uk", "umb", "und", "ur", "uz", + "vai", "ve", "vec", "vep", "vi", "vls", "vmf", "vo", + "vot", "vro", "vun", + "wa", "wae", "wal", "war", "was", "wbp", "wo", "wuu", + "xal", "xh", "xmf", "xog", + "yao", "yap", "yav", "ybb", "yi", "yo", "yrl", "yue", + "za", "zap", "zbl", "zea", "zen", "zgh", "zh", "zu", + "zun", "zxx", "zza", +NULL, + "in", "iw", "ji", "jw", "sh", /* obsolete language codes */ +NULL +}; + +/** + * Table of 3-letter language codes. + * + * This is a lookup table used to convert 3-letter language codes to + * their 2-letter equivalent, where possible. It must be kept in sync + * with LANGUAGES. For all valid i, LANGUAGES[i] must refer to the + * same language as LANGUAGES_3[i]. The commented-out lines are + * copied from LANGUAGES to make eyeballing this baby easier. + * + * Where a 3-letter language code has no 2-letter equivalent, the + * 3-letter code occupies both LANGUAGES[i] and LANGUAGES_3[i]. + * + * This table should be terminated with a NULL entry, followed by a + * second list, and another NULL entry. The two lists correspond to + * the two lists in LANGUAGES. + */ +/* Subsequent hand addition of selected languages */ +static const char * const LANGUAGES_3[] = { + "aar", "abk", "ace", "ach", "ada", "ady", "ave", "aeb", + "afr", "afh", "agq", "ain", "aka", "akk", "akz", "ale", + "aln", "alt", "amh", "arg", "ang", "anp", "ara", "arc", + "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "asm", + "asa", "ase", "ast", "ava", "avk", "awa", "aym", "aze", + "bak", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", + "bel", "bej", "bem", "bew", "bez", "bfd", "bfq", "bul", + "bgn", "bho", "bis", "bik", "bin", "bjn", "bkm", "bla", + "bam", "ben", "bod", "bpy", "bqi", "bre", "bra", "brh", + "brx", "bos", "bss", "bua", "bug", "bum", "byn", "byv", + "cat", "cad", "car", "cay", "cch", "ccp", "che", "ceb", "cgg", + "cha", "chb", "chg", "chk", "chm", "chn", "cho", "chp", + "chr", "chy", "ckb", "cos", "cop", "cps", "cre", "crh", + "ces", "csb", "chu", "chv", "cym", + "dan", "dak", "dar", "dav", "deu", "del", "den", "dgr", + "din", "dje", "doi", "dsb", "dtp", "dua", "dum", "div", + "dyo", "dyu", "dzo", "dzg", + "ebu", "ewe", "efi", "egl", "egy", "eka", "ell", "elx", + "eng", "enm", "epo", "spa", "esu", "est", "eus", "ewo", + "ext", + "fas", "fan", "fat", "ful", "fin", "fil", "fit", "fij", + "fao", "fon", "fra", "frc", "frm", "fro", "frp", "frr", + "frs", "fur", "fry", + "gle", "gaa", "gag", "gan", "gay", "gba", "gbz", "gla", + "gez", "gil", "glg", "glk", "gmh", "grn", "goh", "gom", + "gon", "gor", "got", "grb", "grc", "gsw", "guj", "guc", + "gur", "guz", "glv", "gwi", + "hau", "hai", "hak", "haw", "heb", "hin", "hif", "hil", + "hit", "hmn", "hmo", "hrv", "hsb", "hsn", "hat", "hun", + "hup", "hye", "her", + "ina", "iba", "ibb", "ind", "ile", "ibo", "iii", "ipk", + "ilo", "inh", "ido", "isl", "ita", "iku", "izh", + "jpn", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut", + "jav", + "kat", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd", + "kbl", "kcg", "kde", "kea", "ken", "kfo", "kon", "kgp", + "kha", "kho", "khq", "khw", "kik", "kiu", "kua", "kaz", + "kkj", "kal", "kln", "khm", "kmb", "kan", "kor", "koi", + "kok", "kos", "kpe", "kau", "krc", "kri", "krj", "krl", + "kru", "kas", "ksb", "ksf", "ksh", "kur", "kum", "kut", + "kom", "cor", "kir", + "lat", "lad", "lag", "lah", "lam", "ltz", "lez", "lfn", + "lug", "lim", "lij", "liv", "lkt", "lmo", "lin", "lao", + "lol", "loz", "lrc", "lit", "ltg", "lub", "lua", "lui", + "lun", "luo", "lus", "luy", "lav", "lzh", "lzz", + "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", + "mdf", "mdh", "mdr", "men", "mer", "mfe", "mlg", "mga", + "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", + "mal", "mon", "mnc", "mni", "mol", + "moh", "mos", "mar", "mrj", + "msa", "mlt", "mua", "mul", "mus", "mwl", "mwr", "mwv", + "mya", "mye", "myv", "mzn", + "nau", "nan", "nap", "naq", "nob", "nde", "nds", "nep", + "new", "ndo", "nia", "niu", "njo", "nld", "nmg", "nno", + "nnh", "nor", "nog", "non", "nov", "nqo", "nbl", "nso", + "nus", "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", + "oci", "oji", "orm", "ori", "oss", "osa", "ota", + "pan", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", + "pdt", "peo", "pfl", "phn", "pli", "pol", "pms", "pnt", + "pon", "prg", "pro", "pus", "por", + "que", "quc", "qug", + "raj", "rap", "rar", "rgn", "rif", "roh", "run", "ron", + "rof", "rom", "rtm", "rus", "rue", "rug", "rup", + "kin", "rwk", + "san", "sad", "sah", "sam", "saq", "sas", "sat", "saz", + "sba", "sbp", "srd", "scn", "sco", "snd", "sdc", "sdh", + "sme", "see", "seh", "sei", "sel", "ses", "sag", "sga", + "sgs", "shi", "shn", "shu", "sin", "sid", "slk", + "slv", "sli", "sly", "smo", "sma", "smj", "smn", "sms", + "sna", "snk", "som", "sog", "sqi", "srp", "srn", "srr", + "ssw", "ssy", "sot", "stq", "sun", "suk", "sus", "sux", + "swe", "swa", "swb", "swc", "syc", "syr", "szl", + "tam", "tcy", "tel", "tem", "teo", "ter", "tet", "tgk", + "tha", "tir", "tig", "tiv", "tuk", "tkl", "tkr", "tgl", + "tlh", "tli", "tly", "tmh", "tsn", "ton", "tog", "tpi", + "tur", "tru", "trv", "tso", "tsd", "tsi", "tat", "ttt", + "tum", "tvl", "twi", "twq", "tah", "tyv", "tzm", + "udm", "uig", "uga", "ukr", "umb", "und", "urd", "uzb", + "vai", "ven", "vec", "vep", "vie", "vls", "vmf", "vol", + "vot", "vro", "vun", + "wln", "wae", "wal", "war", "was", "wbp", "wol", "wuu", + "xal", "xho", "xmf", "xog", + "yao", "yap", "yav", "ybb", "yid", "yor", "yrl", "yue", + "zha", "zap", "zbl", "zea", "zen", "zgh", "zho", "zul", + "zun", "zxx", "zza", +NULL, +/* "in", "iw", "ji", "jw", "sh", */ + "ind", "heb", "yid", "jaw", "srp", +NULL +}; + +/** + * Table of 2-letter country codes. + * + * This list must be in sorted order. This list is returned directly + * to the user by some API. + * + * This list must be kept in sync with COUNTRIES_3, with corresponding + * entries matched. + * + * This table should be terminated with a NULL entry, followed by a + * second list, and another NULL entry. The first list is visible to + * user code when this array is returned by API. The second list + * contains codes we support, but do not expose through user API. + * + * Notes: + * + * ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per + * http://www.evertype.com/standards/iso3166/iso3166-1-en.html added + * new codes keeping the old ones for compatibility updated to include + * 1999/12/03 revisions *CWB* + * + * RO(ROM) is now RO(ROU) according to + * http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html + */ +static const char * const COUNTRIES[] = { + "AD", "AE", "AF", "AG", "AI", "AL", "AM", + "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", + "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", + "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", + "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", + "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", + "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", + "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", + "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", + "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", + "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", + "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", + "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", + "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", + "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", + "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", + "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", + "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", + "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", + "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", + "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", + "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", + "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", + "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", + "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", + "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", + "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", + "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", + "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", + "WS", "YE", "YT", "ZA", "ZM", "ZW", +NULL, + "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR", /* obsolete country codes */ +NULL +}; + +/** + * Table of 3-letter country codes. + * + * This is a lookup table used to convert 3-letter country codes to + * their 2-letter equivalent. It must be kept in sync with COUNTRIES. + * For all valid i, COUNTRIES[i] must refer to the same country as + * COUNTRIES_3[i]. The commented-out lines are copied from COUNTRIES + * to make eyeballing this baby easier. + * + * This table should be terminated with a NULL entry, followed by a + * second list, and another NULL entry. The two lists correspond to + * the two lists in COUNTRIES. + */ +static const char * const COUNTRIES_3[] = { +/* "AD", "AE", "AF", "AG", "AI", "AL", "AM", */ + "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", +/* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */ + "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE", +/* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */ + "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI", +/* "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", */ + "BEN", "BLM", "BMU", "BRN", "BOL", "BES", "BRA", "BHS", "BTN", "BVT", +/* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */ + "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG", +/* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */ + "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", +/* "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", */ + "CUB", "CPV", "CUW", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK", +/* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */ + "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI", +/* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */ + "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", +/* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */ + "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL", +/* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */ + "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM", +/* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */ + "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN", +/* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */ + "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL", +/* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */ + "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", +/* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */ + "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", +/* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */ + "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX", +/* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */ + "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD", +/* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */ + "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR", +/* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */ + "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", +/* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */ + "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", +/* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */ + "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG", +/* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */ + "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", +/* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */ + "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU", +/* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */ + "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM", +/* "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", */ + "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "SSD", "STP", "SLV", +/* "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */ + "SXM", "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK", +/* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */ + "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", +/* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */ + "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB", +/* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */ + "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", +/* "WS", "YE", "YT", "ZA", "ZM", "ZW", */ + "WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE", +NULL, +/* "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR" */ + "ANT", "BUR", "SCG", "FXX", "ROM", "SUN", "TMP", "YMD", "YUG", "ZAR", +NULL +}; + PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index e6b2c7245ad4c..3dd5183167e6d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -93,6 +93,48 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity parent[i] = 0; } +/** + * Lookup 'key' in the array 'list'. The array 'list' should contain + * a NULL entry, followed by more entries, and a second NULL entry. + * + * The 'list' param should be LANGUAGES, LANGUAGES_3, COUNTRIES, or + * COUNTRIES_3. + */ +static int16_t _findIndex(const char* const* list, const char* key) +{ + const char* const* anchor = list; + int32_t pass = 0; + + /* Make two passes through two NULL-terminated arrays at 'list' */ + while (pass++ < 2) { + while (*list) { + if (strcmp(key, *list) == 0) { + return (int16_t)(list - anchor); + } + list++; + } + ++list; /* skip final NULL *CWB*/ + } + return -1; +} + +static const char* getISO3CountryByCountryCode(const char* countryCode) +{ + int16_t offset = _findIndex(COUNTRIES, countryCode); + if (offset < 0) + return ""; + + return COUNTRIES_3[offset]; +} + +static const char* getISO3LanguageByLangCode(const char* langCode) +{ + int16_t offset = _findIndex(LANGUAGES, langCode); + if (offset < 0) + return ""; + return LANGUAGES_3[offset]; +} + const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData) { @autoreleasepool @@ -190,7 +232,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso639LanguageThreeLetterName: { NSString *iso639_2 = [currentLocale objectForKey:NSLocaleLanguageCode]; - return strdup("");//iso639_2 == nil ? strdup("") : strdup(uloc_getISO3LanguageByLangCode([iso639_2 UTF8String])); + return iso639_2 == nil ? strdup("") : strdup(getISO3LanguageByLangCode([iso639_2 UTF8String])); } case LocaleString_Iso3166CountryName: value = [currentLocale objectForKey:NSLocaleCountryCode]; @@ -198,7 +240,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity case LocaleString_Iso3166CountryName2: { NSString* countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; - return strdup("");//countryCode == nil ? strdup("") : strdup(uloc_getISO3CountryByCountryCode([countryCode UTF8String])); + return countryCode == nil ? strdup("") : strdup(getISO3CountryByCountryCode([countryCode UTF8String])); } case LocaleString_NaNSymbol: value = numberFormatter.notANumberSymbol; From a91cdf7244f6948022061f7e3beb06ce23e64591 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 23 Oct 2023 14:01:30 +0200 Subject: [PATCH 011/105] Add check for hybrid mode --- .../Globalization/GlobalizationMode.Unix.cs | 28 +++++++++++-------- src/tasks/AppleAppBuilder/Xcode.cs | 9 ++---- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index d24f0b65719e8..3c47652fbe256 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -18,18 +18,22 @@ static Settings() // and PredefinedCulturesOnly is unspecified. if (!GlobalizationMode.Invariant) { - // if (TryGetAppLocalIcuSwitchValue(out string? icuSuffixAndVersion)) - // { - // LoadAppLocalIcu(icuSuffixAndVersion); - // } - // else - // { - // int loaded = LoadICU(); - // if (loaded == 0) - // { - // Environment.FailFast(GetIcuLoadFailureMessage()); - // } - // } +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + return; +#endif + if (TryGetAppLocalIcuSwitchValue(out string? icuSuffixAndVersion)) + { + LoadAppLocalIcu(icuSuffixAndVersion); + } + else + { + int loaded = LoadICU(); + if (loaded == 0) + { + Environment.FailFast(GetIcuLoadFailureMessage()); + } + } } } diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index a05ecc6c41c19..e54d608dd2625 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -258,11 +258,7 @@ public string GenerateCMake( bool isLibraryMode = false) { // bundle everything as resources excluding native files - List predefinedExcludes; - // if (hybridGlobalization) - // predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib"}; - // else - predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; + List predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; predefinedExcludes = predefinedExcludes.Concat(excludes).ToList(); if (!preferDylibs) { @@ -275,8 +271,7 @@ public string GenerateCMake( string[] resources = Directory.GetFileSystemEntries(workspace, "", SearchOption.TopDirectoryOnly) .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) - // && !(hybridGlobalization ? Path.GetFileName(f) == "icudt_hybrid.dat" : Path.GetFileName(f) == "icudt.dat") - ))) + && !(!hybridGlobalization && Path.GetFileName(f) == "icudt.dat")))) .ToArray(); if (string.IsNullOrEmpty(nativeMainSource)) From 7d6641d89b976339dd9d5a584ad25bb5161c96cc Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 23 Oct 2023 14:12:40 +0200 Subject: [PATCH 012/105] minor fix --- src/tasks/AppleAppBuilder/Xcode.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/AppleAppBuilder/Xcode.cs b/src/tasks/AppleAppBuilder/Xcode.cs index e54d608dd2625..e3c4d8149249c 100644 --- a/src/tasks/AppleAppBuilder/Xcode.cs +++ b/src/tasks/AppleAppBuilder/Xcode.cs @@ -258,7 +258,7 @@ public string GenerateCMake( bool isLibraryMode = false) { // bundle everything as resources excluding native files - List predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; + var predefinedExcludes = new List { ".dll.o", ".dll.s", ".dwarf", ".m", ".h", ".a", ".bc", "libmonosgen-2.0.dylib", "libcoreclr.dylib", "icudt*" }; predefinedExcludes = predefinedExcludes.Concat(excludes).ToList(); if (!preferDylibs) { @@ -270,8 +270,8 @@ public string GenerateCMake( } string[] resources = Directory.GetFileSystemEntries(workspace, "", SearchOption.TopDirectoryOnly) - .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) - && !(!hybridGlobalization && Path.GetFileName(f) == "icudt.dat")))) + .Where(f => !predefinedExcludes.Any(e => (!e.EndsWith('*') && f.EndsWith(e, StringComparison.InvariantCultureIgnoreCase)) || (e.EndsWith('*') && Path.GetFileName(f).StartsWith(e.TrimEnd('*'), StringComparison.InvariantCultureIgnoreCase) && + !(!hybridGlobalization && Path.GetFileName(f) == "icudt.dat")))) .ToArray(); if (string.IsNullOrEmpty(nativeMainSource)) From 5097d38a1f0ba24a75deb0e8aac2b7fb513807ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Mon, 23 Oct 2023 17:09:45 +0200 Subject: [PATCH 013/105] Fix build --- src/mono/mono.proj | 6 +++++- src/mono/mono/mini/CMakeLists.txt | 2 ++ src/native/libs/System.Globalization.Native/CMakeLists.txt | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 78ea1292e48e2..bbde9204349ca 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -462,9 +462,11 @@ <_MonoCMakeVersionMin Condition="'$(TargetsiOS)' == 'true'">$(iOSVersionMin) <_MonoCMakeVersionMin Condition="'$(TargetstvOS)' == 'true'">$(tvOSVersionMin) + <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_NAME=$(_MonoCMakeSystemName)"/> <_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(_MonoCMakeVersionMin)" /> @@ -479,9 +481,11 @@ <_MonoCMakeArgs Condition="'$(Platform)' == 'arm'" Include=""-DCMAKE_OSX_ARCHITECTURES=armv7%3Barmv7s"" /> - <_MonoCMakeArgs Include="-DICU_LIBDIR=$(_IcuLibdir)"/> <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> + diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 45ac9c38840df..4d9d9957dadac 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -92,6 +92,8 @@ if(HAVE_SYS_ICU) endif() if(ICU_LIBDIR) set(ICU_LDFLAGS "-L${ICU_LIBDIR}") + else() + set(ICU_LDFLAGS "-licucore") endif() add_library(icu_shim_objects OBJECT "${icu_shim_sources}") diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 54c3779d78b10..684838675c987 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -71,6 +71,9 @@ set(NATIVEGLOBALIZATION_SOURCES # include_directories(${CMAKE_ICU_DIR}/include) #endif() +if ((CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND NOT DEFINED CMAKE_ICU_DIR) + link_libraries(icucore) +endif() if (CMAKE_USE_PTHREADS) add_compile_options(-pthread) From 4ad9b4e6f951f13271ca8797324a8f136a52b6fb Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 23 Oct 2023 18:29:32 +0200 Subject: [PATCH 014/105] link to -licucore in the appbuilder --- src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template index 8bd0126f7d2aa..614d9a7cf64fb 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists.txt.template @@ -75,6 +75,7 @@ target_link_libraries( "-lz" "-lc++" "-liconv" + "-licucore" %NativeLibrariesToLink% %APP_LINK_LIBRARIES% ) From 455aa2afc1238c73fdfde864ca7a0d5fc68e9a76 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 24 Oct 2023 14:39:41 +0200 Subject: [PATCH 015/105] Fix System.Globalization.Tests on hybrid mode --- .../Common/src/Interop/Interop.Locale.iOS.cs | 4 ++ .../TestUtilities/System/PlatformDetection.cs | 3 + .../tests/CompareInfo/CompareInfoTests.cs | 16 ++--- .../tests/CompareInfo/CompareInfoTestsBase.cs | 1 + .../tests/CultureInfo/CultureInfoAll.cs | 10 ++- .../tests/CultureInfo/CultureInfoCtor.cs | 72 +++++++++++++------ .../tests/CultureInfo/GetCultureInfo.cs | 23 ++++-- ...DateTimeFormatInfoGetAbbreviatedEraName.cs | 2 +- .../DateTimeFormatInfoGetEra.cs | 2 +- .../System.Globalization/tests/IcuTests.cs | 4 +- .../System/Globalization/RegionInfoTests.cs | 8 +-- .../System/Globalization/CultureData.Icu.cs | 25 +++++++ .../System/Globalization/CultureData.Unix.cs | 7 +- .../System/Globalization/CultureData.iOS.cs | 13 ---- .../System.Globalization.Native/pal_locale.h | 2 + .../System.Globalization.Native/pal_locale.m | 20 ++++++ 16 files changed, 147 insertions(+), 65 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs index 8fec953b4952f..86cb077e4364b 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs @@ -16,6 +16,10 @@ internal static partial class Globalization [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleNameNative", StringMarshalling = StringMarshalling.Utf8)] internal static unsafe partial string GetDefaultLocaleNameNative(); + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocaleNative", StringMarshalling = StringMarshalling.Utf8)] + [return: MarshalAs(UnmanagedType.Bool)] + internal static partial bool IsPredefinedLocaleNative(string localeName); + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoIntNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial int GetLocaleInfoIntNative(string localeName, uint localeNumberData); diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index d4944724a3d91..903db2f7210dd 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -365,10 +365,13 @@ public static string GetDistroVersionString() public static Version ICUVersion => m_icuVersion.Value; public static bool IsInvariantGlobalization => m_isInvariant.Value; + public static bool IsHybridGlobalization => m_isHybrid.Value; public static bool IsHybridGlobalizationOnBrowser => m_isHybrid.Value && IsBrowser; public static bool IsHybridGlobalizationOnOSX => m_isHybrid.Value && (IsOSX || IsMacCatalyst || IsiOS || IstvOS); public static bool IsNotHybridGlobalizationOnBrowser => !IsHybridGlobalizationOnBrowser; public static bool IsNotInvariantGlobalization => !IsInvariantGlobalization; + public static bool IsNotHybridGlobalization => !IsHybridGlobalization; + public static bool IsNotHybridGlobalizationOnOSX => !IsHybridGlobalizationOnOSX; public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0); public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser; public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !(IsIcuGlobalization || IsHybridGlobalizationOnOSX); diff --git a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.cs index 24ef09380db06..cbd011b96fa0c 100644 --- a/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.cs @@ -60,7 +60,7 @@ public void EqualsTest(CompareInfo compare1, object value, bool expected) new object[] { "", CompareOptions.None, "\u200c", CompareOptions.None, true }, // see comment at bottom of SortKey_TestData }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] [MemberData(nameof(GetHashCodeTestData))] public void GetHashCodeTest(string source1, CompareOptions options1, string source2, CompareOptions options2, bool expected) { @@ -345,14 +345,14 @@ public static void LcidTest(string cultureName, int lcid) Assert.Equal(lcid, ci.LCID); } - [ConditionalTheory(typeof(CompareInfoTests), nameof(IsNotWindowsKanaRegressedVersionAndNotHybridGlobalizationOnWasm))] + [ConditionalTheory(typeof(CompareInfoTests), nameof(IsNotWindowsKanaRegressedVersionAndNotHybridGlobalization))] [MemberData(nameof(SortKey_Kana_TestData))] public void SortKeyKanaTest(CompareInfo compareInfo, string string1, string string2, CompareOptions options, int expected) { SortKeyTest(compareInfo, string1, string2, options, expected); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalization))] public void SortKeyTestNotSupported() { try @@ -395,7 +395,7 @@ public void SortKeyTestNotSupported() private static bool WindowsVersionHasTheCompareStringRegression => PlatformDetection.IsNlsGlobalization && CompareStringEx("", NORM_LINGUISTIC_CASING, "", 0, "\u200C", 1, IntPtr.Zero, IntPtr.Zero, 0) != 2; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] [MemberData(nameof(SortKey_TestData))] public void SortKeyTest(CompareInfo compareInfo, string string1, string string2, CompareOptions options, int expectedSign) { @@ -444,7 +444,7 @@ unsafe static void RunSpanSortKeyTest(CompareInfo compareInfo, ReadOnlySpan !PlatformDetection.I s_invariantCompare.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) == 0; protected static bool IsNotWindowsKanaRegressedVersionAndNotHybridGlobalizationOnWasm() => !PlatformDetection.IsHybridGlobalizationOnBrowser && IsNotWindowsKanaRegressedVersion(); + protected static bool IsNotWindowsKanaRegressedVersionAndNotHybridGlobalization() => IsNotWindowsKanaRegressedVersionAndNotHybridGlobalizationOnWasm() && !PlatformDetection.IsHybridGlobalizationOnOSX; } } diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoAll.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoAll.cs index fb4692da1a0ab..e1ffaa4f25024 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoAll.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoAll.cs @@ -635,13 +635,19 @@ public static IEnumerable CultureInfo_TestData() yield return new object[] { 0x2009, new [] { "en-jm" }, "en-JM", "eng", "ENJ", "en-JM", "en-JM" }; yield return new object[] { 0x241a, new [] { "sr-latn-rs" }, "sr-Latn-RS", "srp", "SRM", "sr-Latn-RS", "sr-Latn-RS" }; yield return new object[] { 0x2809, new [] { "en-bz" }, "en-BZ", "eng", "ENL", "en-BZ", "en-BZ" }; - yield return new object[] { 0x281a, new [] { "sr-cyrl-rs" }, "sr-Cyrl-RS", "srp", "SRO", "sr-Cyrl-RS", "sr-Cyrl-RS" }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { 0x281a, new [] { "sr-cyrl-rs" }, "sr-Cyrl-RS", "srp", "SRO", "sr-Cyrl-RS", "sr-Cyrl-RS" }; + } yield return new object[] { 0x2c09, new [] { "en-tt" }, "en-TT", "eng", "ENT", "en-TT", "en-TT" }; yield return new object[] { 0x3009, new [] { "en-zw" }, "en-ZW", "eng", "ENW", "en-ZW", "en-ZW" }; yield return new object[] { 0x3409, new [] { "en-ph" }, "en-PH", "eng", "ENP", "en-PH", "en-PH" }; yield return new object[] { 0x4009, new [] { "en-in" }, "en-IN", "eng", "ENN", "en-IN", "en-IN" }; yield return new object[] { 0x4809, new [] { "en-sg" }, "en-SG", "eng", "ENE", "en-SG", "en-SG" }; - yield return new object[] { 0x6c1a, new [] { "sr-cyrl" }, "sr-Cyrl-RS", "srp", "SRO", "sr-Cyrl", "sr-Cyrl-RS" }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { 0x6c1a, new [] { "sr-cyrl" }, "sr-Cyrl-RS", "srp", "SRO", "sr-Cyrl", "sr-Cyrl-RS" }; + } yield return new object[] { 0x701a, new [] { "sr-latn" }, "sr-Latn-RS", "srp", "SRM", "sr-Latn", "sr-Latn-RS" }; yield return new object[] { 0x7804, new [] { "zh" }, "zh-CN", "zho", "CHS", "zh", "zh-CN" }; yield return new object[] { 0x7c04, new [] { "zh-cht", "zh-hant" }, "zh-HK", "zho", "CHT", "zh-Hant", "zh-HK" }; diff --git a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs index 37175600777b4..9584ce9f07625 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs @@ -40,8 +40,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "az", new [] { "az" }}; yield return new object[] { "az-Cyrl", new [] { "az-Cyrl" }}; yield return new object[] { "az-Cyrl-AZ", new [] { "az-Cyrl-AZ" }}; - yield return new object[] { "az-Latn", new [] { "az-Latn" }}; - yield return new object[] { "az-Latn-AZ", new [] { "az-Latn-AZ" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "az-Latn", new [] { "az-Latn" }}; + yield return new object[] { "az-Latn-AZ", new [] { "az-Latn-AZ" }}; + } yield return new object[] { "ba", new [] { "ba" }}; yield return new object[] { "ba-RU", new [] { "ba-RU" }}; yield return new object[] { "be", new [] { "be" }}; @@ -58,8 +61,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "bs", new [] { "bs" }}; yield return new object[] { "bs-Cyrl", new [] { "bs-Cyrl" }}; yield return new object[] { "bs-Cyrl-BA", new [] { "bs-Cyrl-BA" }}; - yield return new object[] { "bs-Latn", new [] { "bs-Latn" }}; - yield return new object[] { "bs-Latn-BA", new [] { "bs-Latn-BA" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "bs-Latn", new [] { "bs-Latn" }}; + yield return new object[] { "bs-Latn-BA", new [] { "bs-Latn-BA" }}; + } yield return new object[] { "ca", new [] { "ca" } }; yield return new object[] { "ca-ES", new [] { "ca-ES" } }; yield return new object[] { "co", new [] { "co" }}; @@ -154,8 +160,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "gu", new [] { "gu" } }; yield return new object[] { "gu-IN", new [] { "gu-IN" } }; yield return new object[] { "ha", new [] { "ha" }}; - yield return new object[] { "ha-Latn", new [] { "ha-Latn" }}; - yield return new object[] { "ha-Latn-NG", new [] { "ha-Latn-NG" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "ha-Latn", new [] { "ha-Latn" }}; + yield return new object[] { "ha-Latn-NG", new [] { "ha-Latn-NG" }}; + } yield return new object[] { "he", new [] { "he" } }; yield return new object[] { "he-IL", new [] { "he-IL" } }; yield return new object[] { "hi", new [] { "hi" } }; @@ -221,7 +230,10 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "ml", new [] { "ml" } }; yield return new object[] { "ml-IN", new [] { "ml-IN" } }; yield return new object[] { "mn", new [] { "mn" }}; - yield return new object[] { "mn-Cyrl", new [] { "mn-Cyrl" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "mn-Cyrl", new [] { "mn-Cyrl" }}; + } yield return new object[] { "mn-MN", new [] { "mn-MN" }}; yield return new object[] { "mn-Mong", new [] { "mn-Mong" }}; yield return new object[] { "mn-Mong-CN", new [] { "mn-Mong-CN" }}; @@ -243,7 +255,10 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "nl-NL", new [] { "nl-NL" } }; yield return new object[] { "nn", new [] { "nn" }}; yield return new object[] { "nn-NO", new [] { "nn-NO" }}; - yield return new object[] { "no", new [] { "no" } }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "no", new [] { "no" } }; + } yield return new object[] { "nso", new [] { "nso" }}; yield return new object[] { "nso-ZA", new [] { "nso-ZA" }}; yield return new object[] { "oc", new [] { "oc" }}; @@ -300,14 +315,20 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "sq", new [] { "sq" }}; yield return new object[] { "sq-AL", new [] { "sq-AL" }}; yield return new object[] { "sr", new [] { "sr" } }; - yield return new object[] { "sr-Cyrl", new [] { "sr-Cyrl" } }; - yield return new object[] { "sr-Cyrl-BA", new [] { "sr-Cyrl-BA" }}; - yield return new object[] { "sr-Cyrl-CS", new [] { "sr-Cyrl-CS" }}; - yield return new object[] { "sr-Cyrl-ME", new [] { "sr-Cyrl-ME" }}; - yield return new object[] { "sr-Cyrl-RS", new [] { "sr-Cyrl-RS" } }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "sr-Cyrl", new [] { "sr-Cyrl" } }; + yield return new object[] { "sr-Cyrl-BA", new [] { "sr-Cyrl-BA" }}; + yield return new object[] { "sr-Cyrl-CS", new [] { "sr-Cyrl-CS" }}; + yield return new object[] { "sr-Cyrl-ME", new [] { "sr-Cyrl-ME" }}; + yield return new object[] { "sr-Cyrl-RS", new [] { "sr-Cyrl-RS" } }; + } yield return new object[] { "sr-Latn", new [] { "sr-Latn" } }; yield return new object[] { "sr-Latn-BA", new [] { "sr-Latn-BA" }}; - yield return new object[] { "sr-Latn-CS", new [] { "sr-Latn-CS" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "sr-Latn-CS", new [] { "sr-Latn-CS" }}; + } yield return new object[] { "sr-Latn-ME", new [] { "sr-Latn-ME" }}; yield return new object[] { "sr-Latn-RS", new [] { "sr-Latn-RS" } }; yield return new object[] { "sv", new [] { "sv" } }; @@ -322,8 +343,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "te", new [] { "te" } }; yield return new object[] { "te-IN", new [] { "te-IN" } }; yield return new object[] { "tg", new [] { "tg" }}; - yield return new object[] { "tg-Cyrl", new [] { "tg-Cyrl" }}; - yield return new object[] { "tg-Cyrl-TJ", new [] { "tg-Cyrl-TJ" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "tg-Cyrl", new [] { "tg-Cyrl" }}; + yield return new object[] { "tg-Cyrl-TJ", new [] { "tg-Cyrl-TJ" }}; + } yield return new object[] { "th", new [] { "th" } }; yield return new object[] { "th-TH", new [] { "th-TH" } }; yield return new object[] { "tk", new [] { "tk" }}; @@ -335,8 +359,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "tt", new [] { "tt" }}; yield return new object[] { "tt-RU", new [] { "tt-RU" }}; yield return new object[] { "tzm", new [] { "tzm" }}; - yield return new object[] { "tzm-Latn", new [] { "tzm-Latn" }}; - yield return new object[] { "tzm-Latn-DZ", new [] { "tzm-Latn-DZ" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "tzm-Latn", new [] { "tzm-Latn" }}; + yield return new object[] { "tzm-Latn-DZ", new [] { "tzm-Latn-DZ" }}; + } yield return new object[] { "ug", new [] { "ug" }}; yield return new object[] { "ug-CN", new [] { "ug-CN" }}; yield return new object[] { "uk", new [] { "uk" } }; @@ -346,8 +373,11 @@ public static IEnumerable Ctor_String_TestData() yield return new object[] { "uz", new [] { "uz" }}; yield return new object[] { "uz-Cyrl", new [] { "uz-Cyrl" }}; yield return new object[] { "uz-Cyrl-UZ", new [] { "uz-Cyrl-UZ" }}; - yield return new object[] { "uz-Latn", new [] { "uz-Latn" }}; - yield return new object[] { "uz-Latn-UZ", new [] { "uz-Latn-UZ" }}; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "uz-Latn", new [] { "uz-Latn" }}; + yield return new object[] { "uz-Latn-UZ", new [] { "uz-Latn-UZ" }}; + } yield return new object[] { "vi", new [] { "vi" } }; yield return new object[] { "vi-VN", new [] { "vi-VN" } }; yield return new object[] { "wo", new [] { "wo" }}; @@ -396,7 +426,7 @@ public void Ctor_String(string name, string[] expectedNames) Assert.Equal(cultureName, culture.ToString(), ignoreCase: true); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public void Ctor_String_Invalid() { AssertExtensions.Throws("name", () => new CultureInfo(null)); // Name is null diff --git a/src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs b/src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs index 0e7873853ebd7..a1dc7c2c9c7a8 100644 --- a/src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs +++ b/src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs @@ -21,7 +21,10 @@ public static IEnumerable GetCultureInfoTestData() yield return new object[] { "ja-JP" }; yield return new object[] { "ar-SA" }; yield return new object[] { "xx-XX" }; - yield return new object[] { "de-AT-1901" }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "de-AT-1901" }; + } yield return new object[] { "zh-Hans" }; yield return new object[] { "zh-Hans-HK" }; yield return new object[] { "zh-Hans-MO" }; @@ -30,16 +33,22 @@ public static IEnumerable GetCultureInfoTestData() yield return new object[] { "zh-Hant-CN" }; yield return new object[] { "zh-Hant-SG" }; - if (PlatformDetection.IsIcuGlobalization) + if (PlatformDetection.IsIcuGlobalization || PlatformDetection.IsHybridGlobalizationOnOSX) { if (PlatformDetection.IsNotWindows) { yield return new object[] { "x\u0000X-Yy", "x" }; // Null byte - yield return new object[] { "zh-cmn", "zh-CMN" }; - yield return new object[] { "zh-CMN-HANS" }; - yield return new object[] { "zh-cmn-Hant", "zh-CMN-HANT" }; + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "zh-cmn", "zh-CMN" }; + yield return new object[] { "zh-CMN-HANS" }; + yield return new object[] { "zh-cmn-Hant", "zh-CMN-HANT" }; + } + } + if (!PlatformDetection.IsHybridGlobalizationOnOSX) + { + yield return new object[] { "sgn-BE-FR" }; } - yield return new object[] { "sgn-BE-FR" }; yield return new object[] { "zh-min-nan", "nan" }; yield return new object[] { "zh-gan", "gan" }; yield return new object[] { "zh-Hans-CN" }; @@ -98,7 +107,7 @@ public void GetCultureInfo(string name, string expected = null) [InlineData("foo_-bar")] [InlineData("foo/bar")] [InlineData("/")] - [InlineData("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234")] // > 85 characters + [InlineData("01234567890123456789012345678901234567890123456789012345678901234567890123456789012345")] // > 85 characters public void TestInvalidCultureNames(string name) { Assert.Throws(() => CultureInfo.GetCultureInfo(name)); diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedEraName.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedEraName.cs index 0efefdd7d6a69..8dd07f32a85bc 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedEraName.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetAbbreviatedEraName.cs @@ -208,7 +208,7 @@ public static IEnumerable GetAbbreviatedEraName_TestData() } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(GetAbbreviatedEraName_TestData))] public void GetAbbreviatedEraName_Invoke_ReturnsExpected(DateTimeFormatInfo format, int era, string expected) { diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs index e4c75e1bb7601..6182546199a92 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs @@ -49,7 +49,7 @@ public static IEnumerable GetEra_TestData() yield return new object[] { frFRFormat, "ap J-C", -1 }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(GetEra_TestData))] public void GetEra_Invoke_ReturnsExpected(DateTimeFormatInfo format, string eraName, int expected) { diff --git a/src/libraries/System.Globalization/tests/IcuTests.cs b/src/libraries/System.Globalization/tests/IcuTests.cs index 0990c710f6d63..4eacd461a1c93 100644 --- a/src/libraries/System.Globalization/tests/IcuTests.cs +++ b/src/libraries/System.Globalization/tests/IcuTests.cs @@ -9,10 +9,10 @@ namespace System.Globalization.Tests { public class IcuTests { - private static bool IsIcuCompatiblePlatform => PlatformDetection.IsNotWindows || + private static bool IsIcuCompatiblePlatform => !PlatformDetection.IsHybridGlobalizationOnOSX && (PlatformDetection.IsNotWindows || ((PlatformDetection.IsWindowsServer2019 || PlatformDetection.IsWindows10Version1903OrGreater) && // Server core doesn't have icu.dll on SysWOW64 - !(PlatformDetection.IsWindowsServerCore && PlatformDetection.IsX86Process)); + !(PlatformDetection.IsWindowsServerCore && PlatformDetection.IsX86Process))); [ConditionalFact(nameof(IsIcuCompatiblePlatform))] public static void IcuShouldBeUsedByDefault() diff --git a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs index 6fd30317d7f06..22acf0af2107e 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/RegionInfoTests.cs @@ -112,7 +112,7 @@ public void DisplayName(string name, string expected) public static IEnumerable NativeName_TestData() { // Android has its own ICU, which doesn't 100% map to UsingLimitedCultures - if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid) + if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid || PlatformDetection.IsHybridGlobalizationOnOSX) { yield return new object[] { "GB", "United Kingdom" }; yield return new object[] { "SE", "Sverige" }; @@ -137,7 +137,7 @@ public void NativeName(string name, string expected) public static IEnumerable EnglishName_TestData() { // Android has its own ICU, which doesn't 100% map to UsingLimitedCultures - if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid) + if (PlatformDetection.IsNotUsingLimitedCultures || PlatformDetection.IsAndroid || PlatformDetection.IsHybridGlobalizationOnOSX) { yield return new object[] { "en-US", new string[] { "United States" } }; yield return new object[] { "US", new string[] { "United States" } }; @@ -208,7 +208,7 @@ public static IEnumerable RegionInfo_TestData() "SAU", "SAU" }; yield return new object[] { 0x412, 134, "South Korean Won", "KRW", "Korean Won", PlatformDetection.IsNlsGlobalization ? "\uc6d0" : "\ub300\ud55c\ubbfc\uad6d\u0020\uc6d0", "KOR", "KOR" }; yield return new object[] { 0x40d, 117, "Israeli New Shekel", "ILS", "Israeli New Sheqel", - PlatformDetection.IsNlsGlobalization || PlatformDetection.ICUVersion.Major >= 58 ? "\u05e9\u05e7\u05dc\u0020\u05d7\u05d3\u05e9" : "\u05e9\u05f4\u05d7", "ISR", "ISR" }; + PlatformDetection.IsNlsGlobalization || PlatformDetection.ICUVersion.Major >= 58 || PlatformDetection.IsHybridGlobalizationOnOSX ? "\u05e9\u05e7\u05dc\u0020\u05d7\u05d3\u05e9" : "\u05e9\u05f4\u05d7", "ISR", "ISR" }; } [Theory] @@ -219,7 +219,7 @@ public void MiscTest(int lcid, int geoId, string currencyEnglishName, string cur Assert.Equal(geoId, ri.GeoId); // Android has its own ICU, which doesn't 100% map to UsingLimitedCultures - if (PlatformDetection.IsUsingLimitedCultures && !PlatformDetection.IsAndroid) + if (PlatformDetection.IsUsingLimitedCultures && !PlatformDetection.IsAndroid && !PlatformDetection.IsHybridGlobalizationOnOSX) { Assert.Equal(currencyShortName, ri.CurrencyEnglishName); Assert.Equal(currencyShortName, ri.CurrencyNativeName); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs index 12af791d392e2..97422b35bf96b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs @@ -120,11 +120,30 @@ private bool InitIcuCultureDataCore() realNameBuffer = string.Concat(realNameBuffer.AsSpan(0, index), ICU_COLLATION_KEYWORD, alternateSortName); } +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + { + _sWindowsName = GetLocaleNameNative(realNameBuffer); + if (_sWindowsName == null || _sWindowsName.Length == 0) + { + return false; + } + } + else + { + // Get the locale name from ICU + if (!GetLocaleName(realNameBuffer, out _sWindowsName)) + { + return false; + } + } +#else // Get the locale name from ICU if (!GetLocaleName(realNameBuffer, out _sWindowsName)) { return false; // fail } +#endif Debug.Assert(_sWindowsName != null); @@ -287,6 +306,12 @@ private unsafe string IcuGetTimeFormatString(bool shortFormat) internal static bool IcuIsEnsurePredefinedLocaleName(string name) { Debug.Assert(!GlobalizationMode.UseNls); +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + if (GlobalizationMode.Hybrid) + { + return Interop.Globalization.IsPredefinedLocaleNative(name); + } +#endif return Interop.Globalization.IsPredefinedLocale(name); } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs index 533e97b3127d3..6291881ba96e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Unix.cs @@ -7,12 +7,7 @@ namespace System.Globalization { internal sealed partial class CultureData { - private bool InitCultureDataCore() => -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - GlobalizationMode.Hybrid ? InitAppleCultureDataCore() : InitIcuCultureDataCore(); -#else - InitIcuCultureDataCore(); -#endif + private bool InitCultureDataCore() => InitIcuCultureDataCore(); // Unix doesn't support user overrides partial void InitUserOverride(bool useUserOverride); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.iOS.cs index cdbdd65a81426..557363864d6b0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.iOS.cs @@ -9,19 +9,6 @@ internal sealed partial class CultureData { private const int LOC_FULLNAME_CAPACITY = 157; // max size of locale name - /// - /// This method uses the sRealName field (which is initialized by the constructor before this is called) to - /// initialize the rest of the state of CultureData based on the underlying OS globalization library. - /// - private bool InitAppleCultureDataCore() - { - Debug.Assert(_sRealName != null); - Debug.Assert(!GlobalizationMode.Invariant); - string realNameBuffer = _sRealName; - - _sWindowsName = _sName = _sRealName = GetLocaleNameNative(realNameBuffer); - return true; - } internal static string GetLocaleNameNative(string localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index e8bc41ad3a8e0..cfa9dad35b656 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -400,4 +400,6 @@ PALEXPORT const char* GlobalizationNative_GetLocaleNameNative(const char* locale PALEXPORT const char* GlobalizationNative_GetLocaleTimeFormatNative(const char* localeName, int shortFormat); PALEXPORT int32_t GlobalizationNative_GetLocalesNative(UChar* locales, int32_t length); + +PALEXPORT int32_t GlobalizationNative_IsPredefinedLocaleNative(const char* localeName); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 3dd5183167e6d..59b7651739a4b 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -802,4 +802,24 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } +// GlobalizationNative_IsPredefinedLocaleNative returns TRUE if localeName exists in availableLocaleIdentifiers. +// Otherwise it returns FALSE; + +int32_t GlobalizationNative_IsPredefinedLocaleNative(const char* localeName) +{ + @autoreleasepool + { + NSString *localeIdentifier = [NSString stringWithFormat:@"%s", localeName]; + NSString *desiredLocaleIdentifier = [localeIdentifier stringByReplacingOccurrencesOfString:@"-" withString:@"_"]; + NSArray *availableLocales = [NSLocale availableLocaleIdentifiers]; + + if ([availableLocales containsObject:desiredLocaleIdentifier]) + { + return true; + } + + return false; + } +} + #endif From 64b9309dd778fa3736aa30454ceddaecbf0bacbf Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 24 Oct 2023 14:40:15 +0200 Subject: [PATCH 016/105] revert changes in IOS tests --- .../tests/Hybrid/System.Globalization.IOS.Tests.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj index 65ee93dfab09d..a230651d06e2b 100644 --- a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj +++ b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj @@ -77,6 +77,5 @@ - From 39785db4a7a6a32a4a816da6660b662a7fde4f32 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 24 Oct 2023 14:43:31 +0200 Subject: [PATCH 017/105] revert ios tests csproj changes --- .../tests/Hybrid/System.Globalization.IOS.Tests.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj index a230651d06e2b..bb38f00b88f9d 100644 --- a/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj +++ b/src/libraries/System.Globalization/tests/Hybrid/System.Globalization.IOS.Tests.csproj @@ -1,9 +1,7 @@ $(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst - true true - true true From 1caed2ee3d0b5a65672d04858b4559657cdf5484 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 24 Oct 2023 15:17:32 +0200 Subject: [PATCH 018/105] inlcude utypes.h --- .../System.Globalization.Native/pal_icushim_internal.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index dadd5dfe46798..4b7660b04feff 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -18,11 +18,7 @@ #if !defined(LOCAL_BUILD) #define U_DISABLE_RENAMING 1 #endif -#ifdef __OBJC__ -// This code will only be included when compiling Objective-C code -#import -#include - +#include // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. @@ -43,10 +39,9 @@ // #include // #include // #include -#include +//#include // #include // #include -#endif // __OBJC__ #endif From 7beec5cf6a8ced76552ee41a2eb5c87920fde318 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 24 Oct 2023 16:00:16 +0200 Subject: [PATCH 019/105] Adjust idna mapping tests --- .../tests/GetStringComparerTests.cs | 2 +- .../tests/IdnMapping/IdnMappingGetAsciiTests.cs | 2 +- .../tests/IdnMapping/IdnMappingUseStd3AsciiRulesTests.cs | 2 +- src/native/libs/System.Globalization.Native/entrypoints.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Globalization.Extensions/tests/GetStringComparerTests.cs b/src/libraries/System.Globalization.Extensions/tests/GetStringComparerTests.cs index 964f45d97452a..987e901a682c8 100644 --- a/src/libraries/System.Globalization.Extensions/tests/GetStringComparerTests.cs +++ b/src/libraries/System.Globalization.Extensions/tests/GetStringComparerTests.cs @@ -19,7 +19,7 @@ public void GetStringComparer_Invalid() AssertExtensions.Throws("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)] diff --git a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingGetAsciiTests.cs b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingGetAsciiTests.cs index 595b005c96d91..3ad3339754359 100644 --- a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingGetAsciiTests.cs +++ b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingGetAsciiTests.cs @@ -21,7 +21,7 @@ public static IEnumerable 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 }; } diff --git a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingUseStd3AsciiRulesTests.cs b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingUseStd3AsciiRulesTests.cs index 481865437c16c..2839086a0b2f8 100644 --- a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingUseStd3AsciiRulesTests.cs +++ b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/IdnMappingUseStd3AsciiRulesTests.cs @@ -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("unicode", () => idnStd3False.GetAscii(unicode)); diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 6dcb04be7d412..8181d48c5f46f 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -55,8 +55,8 @@ static const Entry s_globalizationNative[] = // #endif // DllImportEntry(GlobalizationNative_NormalizeString) // DllImportEntry(GlobalizationNative_StartsWith) -// DllImportEntry(GlobalizationNative_ToAscii) -// DllImportEntry(GlobalizationNative_ToUnicode) + DllImportEntry(GlobalizationNative_ToAscii) + DllImportEntry(GlobalizationNative_ToUnicode) // DllImportEntry(GlobalizationNative_WindowsIdToIanaId) #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) From f097dec1d4099633c5b7b0236495b39452672947 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 25 Oct 2023 10:52:33 +0200 Subject: [PATCH 020/105] Fix idna mapping tests --- .../tests/IdnMapping/Data/Factory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/Data/Factory.cs b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/Data/Factory.cs index 58a727143b2d9..05018f6ca7476 100644 --- a/src/libraries/System.Globalization.Extensions/tests/IdnMapping/Data/Factory.cs +++ b/src/libraries/System.Globalization.Extensions/tests/IdnMapping/Data/Factory.cs @@ -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"; @@ -61,7 +61,7 @@ private static IEnumerable ParseFile(Stream stream, Func= 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); @@ -88,7 +88,7 @@ public static IEnumerable 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) From 87f2011be9626f9f84de12af84c1c1161a027f04 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 25 Oct 2023 17:03:40 +0200 Subject: [PATCH 021/105] Fix System.Runtime.Tests,disable some of the tests --- .../TestUtilities/System/PlatformDetection.cs | 1 + .../Common/tests/Tests/System/StringTests.cs | 14 ++++++------ .../System.Runtime/tests/System/Attributes.cs | 2 +- .../tests/System/DateTimeTests.cs | 4 ++-- .../tests/System/StringComparerTests.cs | 4 ++-- .../tests/System/StringGetHashCodeTests.cs | 2 +- .../tests/System/StringTests.cs | 12 +++++----- .../System.Globalization.Native/entrypoints.c | 1 + .../System.Globalization.Native/pal_casing.m | 22 +++++++++++++++++++ 9 files changed, 43 insertions(+), 19 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 903db2f7210dd..31bdfcd54e5d7 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -374,6 +374,7 @@ public static string GetDistroVersionString() public static bool IsNotHybridGlobalizationOnOSX => !IsHybridGlobalizationOnOSX; public static bool IsIcuGlobalization => ICUVersion > new Version(0, 0, 0, 0); public static bool IsIcuGlobalizationAndNotHybridOnBrowser => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser; + public static bool IsIcuGlobalizationAndNotHybrid => IsIcuGlobalization && IsNotHybridGlobalizationOnBrowser && IsNotHybridGlobalizationOnOSX; public static bool IsNlsGlobalization => IsNotInvariantGlobalization && !(IsIcuGlobalization || IsHybridGlobalizationOnOSX); public static bool IsSubstAvailable diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 119e4b7d1af44..78fcd9e317f09 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1282,7 +1282,7 @@ public static void ContainsMatchDifferentSpans_StringComparison() Assert.True(span.Contains(slice, StringComparison.OrdinalIgnoreCase)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public static void ContainsNoMatch_StringComparison() { for (int length = 1; length < 150; length++) @@ -1724,7 +1724,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "a", StringComparison.OrdinalIgnoreCase, false }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(EndsWith_StringComparison_TestData))] public static void EndsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { @@ -3194,7 +3194,7 @@ public static void IndexOf_TurkishI_EnglishUSCulture() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybrid))] [ActiveIssue("https://github.com/dotnet/runtime/issues/60568", TestPlatforms.Android | TestPlatforms.LinuxBionic)] public static void IndexOf_HungarianDoubleCompression_HungarianCulture() { @@ -4919,7 +4919,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "hello", StringComparison.OrdinalIgnoreCase, false }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(StartsWith_StringComparison_TestData))] public static void StartsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { @@ -5341,7 +5341,7 @@ private static IEnumerable ToLower_Culture_TestData() } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybrid))] public static void Test_ToLower_Culture() { foreach (object[] testdata in ToLower_Culture_TestData()) @@ -5856,7 +5856,7 @@ public static IEnumerable ToUpper_Culture_TestData() yield return new object[] { "h\u0131 world", "H\u0131 WORLD", CultureInfo.InvariantCulture }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybrid))] [MemberData(nameof(ToUpper_Culture_TestData))] public static void Test_ToUpper_Culture(string actual, string expected, CultureInfo culture) { @@ -5955,7 +5955,7 @@ public static IEnumerable ToUpper_TurkishI_InvariantCulture_MemberData new KeyValuePair('\u0130', '\u0130'), new KeyValuePair('\u0131', '\u0131')); - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalizationAndNotHybrid))] [MemberData(nameof(ToUpper_TurkishI_InvariantCulture_MemberData))] public static void ToUpper_TurkishI_InvariantCulture(string s, string expected) { diff --git a/src/libraries/System.Runtime/tests/System/Attributes.cs b/src/libraries/System.Runtime/tests/System/Attributes.cs index bbf2705098083..708ba839b5c38 100644 --- a/src/libraries/System.Runtime/tests/System/Attributes.cs +++ b/src/libraries/System.Runtime/tests/System/Attributes.cs @@ -326,7 +326,7 @@ private static void GenericAttributesTestHelper(Func Parse_ValidInput_Succeeds_MemberData() } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(Parse_ValidInput_Succeeds_MemberData))] public static void Parse_ValidInput_Succeeds(string input, CultureInfo culture, DateTime? expected) { @@ -2462,7 +2462,7 @@ public static IEnumerable ToString_MatchesExpected_MemberData() yield return new object[] { new DateTime(2023, 04, 17, 10, 46, 12, DateTimeKind.Utc), "HH\u202dmm", null, "10\u202d46" }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(Parse_ValidInput_Succeeds_MemberData))] public static void Parse_Span_ValidInput_Succeeds(string input, CultureInfo culture, DateTime? expected) { diff --git a/src/libraries/System.Runtime/tests/System/StringComparerTests.cs b/src/libraries/System.Runtime/tests/System/StringComparerTests.cs index 3027c870855b5..15b4d5f826435 100644 --- a/src/libraries/System.Runtime/tests/System/StringComparerTests.cs +++ b/src/libraries/System.Runtime/tests/System/StringComparerTests.cs @@ -16,7 +16,7 @@ public void Create_InvalidArguments_Throws() AssertExtensions.Throws("culture", () => StringComparer.Create(null, ignoreCase: true)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public void Create_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase: true); @@ -117,7 +117,7 @@ public void CreateCultureOptions_InvalidArguments_Throws() Assert.Throws(() => StringComparer.Create(null, CompareOptions.None)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public void CreateCultureOptions_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); diff --git a/src/libraries/System.Runtime/tests/System/StringGetHashCodeTests.cs b/src/libraries/System.Runtime/tests/System/StringGetHashCodeTests.cs index 33820345f65bd..e42d0548ba5d9 100644 --- a/src/libraries/System.Runtime/tests/System/StringGetHashCodeTests.cs +++ b/src/libraries/System.Runtime/tests/System/StringGetHashCodeTests.cs @@ -61,7 +61,7 @@ public static IEnumerable GetHashCode_TestData() () => { return CultureInfo.CurrentCulture.CompareInfo.GetHashCode("abc", CompareOptions.OrdinalIgnoreCase); } }; - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(GetHashCodeOrdinalIgnoreCase_TestData))] public void GetHashCode_OrdinalIgnoreCase_ReturnsSameHashCodeAsUpperCaseOrdinal(string input) { diff --git a/src/libraries/System.Runtime/tests/System/StringTests.cs b/src/libraries/System.Runtime/tests/System/StringTests.cs index c5f876417d214..8c09798c0af8c 100644 --- a/src/libraries/System.Runtime/tests/System/StringTests.cs +++ b/src/libraries/System.Runtime/tests/System/StringTests.cs @@ -306,7 +306,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(Contains_String_StringComparison_TestData))] public static void Contains_String_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { @@ -775,7 +775,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "", "\0", "y", StringComparison.InvariantCulture, "" }; } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(Replace_StringComparison_TestData))] public void Replace_StringComparison_ReturnsExpected(string original, string oldValue, string newValue, StringComparison comparisonType, string expected) { @@ -841,7 +841,7 @@ public static IEnumerable Replace_StringComparisonCulture_TestData() } } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(Replace_StringComparisonCulture_TestData))] public void Replace_StringComparisonCulture_ReturnsExpected(string original, string oldValue, string newValue, bool ignoreCase, CultureInfo culture, string expected) { @@ -906,7 +906,7 @@ public static void GetHashCode_OfSpan_MatchesOfString() Assert.NotEqual("abc".GetHashCode(), string.GetHashCode("ABC".AsSpan())); // case differences } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public static void GetHashCode_CompareInfo() { // ordinal @@ -926,7 +926,7 @@ public static void GetHashCode_CompareInfo() Assert.Equal("aeiXXabc".GetHashCode(StringComparison.InvariantCultureIgnoreCase), CultureInfo.InvariantCulture.CompareInfo.GetHashCode("aeiXXabc", CompareOptions.IgnoreCase)); } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public static void GetHashCode_CompareInfo_OfSpan() { // ordinal @@ -948,7 +948,7 @@ public static void GetHashCode_CompareInfo_OfSpan() public static IEnumerable GetHashCode_StringComparison_Data => StringComparisons.Select(value => new object[] { value }); - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(GetHashCode_StringComparison_Data))] public static void GetHashCode_StringComparison(StringComparison comparisonType) { diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 8181d48c5f46f..df7e6c27dec7a 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -57,6 +57,7 @@ static const Entry s_globalizationNative[] = // DllImportEntry(GlobalizationNative_StartsWith) DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) + DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) // DllImportEntry(GlobalizationNative_WindowsIdToIanaId) #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index 31fd647347daf..876da67f04d81 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -6,6 +6,7 @@ #include "pal_errors.h" #import +#include #if !__has_feature(objc_arc) #error This file relies on ARC for memory management, but ARC is not enabled. @@ -149,4 +150,25 @@ int32_t GlobalizationNative_ChangeCaseInvariantNative(const uint16_t* lpSrc, int } } +void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget) +{ + @autoreleasepool + { + pageNumber <<= 8; + for (int i = 0; i < 256; i++) + { + // Unfortunately, to ensure one-to-one simple mapping we have to call u_toupper on every character. + // Using string casing ICU APIs cannot give such results even when using NULL locale to force root behavior. + pTarget[i] = (UChar) u_toupper((UChar32)(pageNumber + i)); + } + + if (pageNumber == 0x0100) + { + // Disable Turkish I behavior on Ordinal operations + pTarget[0x31] = (UChar)0x0131; // Turkish lowercase i + pTarget[0x7F] = (UChar)0x017F; // // 017F;LATIN SMALL LETTER LONG S + } + } +} + #endif From 182e06950f02957b0f34e6934d7a2adf756b5bab Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 30 Oct 2023 16:41:41 +0100 Subject: [PATCH 022/105] fix build on non Apple platforms --- src/mono/mono/mini/CMakeLists.txt | 21 +- .../CMakeLists.txt | 24 +- .../System.Globalization.Native/entrypoints.c | 76 ++-- .../pal_icushim_internal.h | 44 +-- .../pal_icushim_static.c | 23 +- .../System.Globalization.Native/pal_locale.h | 373 ------------------ 6 files changed, 101 insertions(+), 460 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 684fdcfbe2202..6ecf9e2888708 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -57,18 +57,23 @@ if(HAVE_SYS_ICU) endif() set(icu_shim_sources_base - #pal_calendarData.c - #pal_casing.c - #pal_collation.c pal_idna.c - #pal_locale.c - #pal_localeNumberData.c - #pal_localeStringData.c - #pal_normalization.c - #pal_timeZoneInfo.c entrypoints.c ${pal_icushim_sources_base}) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + set(NATIVEGLOBALIZATION_SOURCES + pal_calendarData.c + pal_casing.c + pal_collation.c + pal_locale.c + pal_localeNumberData.c + pal_localeStringData.c + pal_normalization.c + pal_timeZoneInfo.c + ) +endif() + addprefix(icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}") if (TARGET_DARWIN) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 9fa90b4950254..c42cd89869e75 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -57,15 +57,19 @@ endif() include(configure.cmake) set(NATIVEGLOBALIZATION_SOURCES - #pal_calendarData.c - #pal_casing.c - #pal_collation.c pal_idna.c - #pal_locale.c - #pal_localeNumberData.c - #pal_localeStringData.c - #pal_normalization.c ) +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + set(NATIVEGLOBALIZATION_SOURCES + pal_calendarData.c + pal_casing.c + pal_collation.c + pal_locale.c + pal_localeNumberData.c + pal_localeStringData.c + pal_normalization.c + ) +endif() #if (DEFINED CMAKE_ICU_DIR) # include_directories(${CMAKE_ICU_DIR}/include) @@ -110,9 +114,9 @@ if (CLR_CMAKE_TARGET_APPLE) endif() # time zone names are filtered out of icu data for the browser and associated functionality is disabled -#if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI) -# set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) -#endif() +if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + set(NATIVEGLOBALIZATION_SOURCES ${NATIVEGLOBALIZATION_SOURCES} pal_timeZoneInfo.c) +endif() if (MSVC) set_source_files_properties(${NATIVEGLOBALIZATION_SOURCES} PROPERTIES LANGUAGE CXX) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index df7e6c27dec7a..648a44e2e2361 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,46 +19,48 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -// DllImportEntry(GlobalizationNative_ChangeCase) -// DllImportEntry(GlobalizationNative_ChangeCaseInvariant) -// DllImportEntry(GlobalizationNative_ChangeCaseTurkish) -// DllImportEntry(GlobalizationNative_CloseSortHandle) -// DllImportEntry(GlobalizationNative_CompareString) -// DllImportEntry(GlobalizationNative_EndsWith) -// DllImportEntry(GlobalizationNative_EnumCalendarInfo) -// DllImportEntry(GlobalizationNative_GetCalendarInfo) -// DllImportEntry(GlobalizationNative_GetCalendars) -// DllImportEntry(GlobalizationNative_GetDefaultLocaleName) -// DllImportEntry(GlobalizationNative_GetICUVersion) -// DllImportEntry(GlobalizationNative_GetJapaneseEraStartDate) -// DllImportEntry(GlobalizationNative_GetLatestJapaneseEra) -// DllImportEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) -// DllImportEntry(GlobalizationNative_GetLocaleInfoInt) -// DllImportEntry(GlobalizationNative_GetLocaleInfoString) -// DllImportEntry(GlobalizationNative_GetLocaleName) -// DllImportEntry(GlobalizationNative_GetLocales) -// DllImportEntry(GlobalizationNative_GetLocaleTimeFormat) -// DllImportEntry(GlobalizationNative_GetSortHandle) -// DllImportEntry(GlobalizationNative_GetSortKey) -// DllImportEntry(GlobalizationNative_GetSortVersion) -// DllImportEntry(GlobalizationNative_GetTimeZoneDisplayName) -// DllImportEntry(GlobalizationNative_IanaIdToWindowsId) -// DllImportEntry(GlobalizationNative_IndexOf) -// DllImportEntry(GlobalizationNative_InitICUFunctions) -// DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -// DllImportEntry(GlobalizationNative_IsNormalized) -// DllImportEntry(GlobalizationNative_IsPredefinedLocale) -// DllImportEntry(GlobalizationNative_LastIndexOf) -// DllImportEntry(GlobalizationNative_LoadICU) -// #if defined(STATIC_ICU) -// DllImportEntry(GlobalizationNative_LoadICUData) -// #endif -// DllImportEntry(GlobalizationNative_NormalizeString) -// DllImportEntry(GlobalizationNative_StartsWith) +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) + DllImportEntry(GlobalizationNative_ChangeCase) + DllImportEntry(GlobalizationNative_ChangeCaseInvariant) + DllImportEntry(GlobalizationNative_ChangeCaseTurkish) + DllImportEntry(GlobalizationNative_CloseSortHandle) + DllImportEntry(GlobalizationNative_CompareString) + DllImportEntry(GlobalizationNative_EndsWith) + DllImportEntry(GlobalizationNative_EnumCalendarInfo) + DllImportEntry(GlobalizationNative_GetCalendarInfo) + DllImportEntry(GlobalizationNative_GetCalendars) + DllImportEntry(GlobalizationNative_GetDefaultLocaleName) + DllImportEntry(GlobalizationNative_GetICUVersion) + DllImportEntry(GlobalizationNative_GetJapaneseEraStartDate) + DllImportEntry(GlobalizationNative_GetLatestJapaneseEra) + DllImportEntry(GlobalizationNative_GetLocaleInfoGroupingSizes) + DllImportEntry(GlobalizationNative_GetLocaleInfoInt) + DllImportEntry(GlobalizationNative_GetLocaleInfoString) + DllImportEntry(GlobalizationNative_GetLocaleName) + DllImportEntry(GlobalizationNative_GetLocales) + DllImportEntry(GlobalizationNative_GetLocaleTimeFormat) + DllImportEntry(GlobalizationNative_GetSortHandle) + DllImportEntry(GlobalizationNative_GetSortKey) + DllImportEntry(GlobalizationNative_GetSortVersion) + DllImportEntry(GlobalizationNative_GetTimeZoneDisplayName) + DllImportEntry(GlobalizationNative_IanaIdToWindowsId) + DllImportEntry(GlobalizationNative_IndexOf) + DllImportEntry(GlobalizationNative_InitICUFunctions) + DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) + DllImportEntry(GlobalizationNative_IsNormalized) + DllImportEntry(GlobalizationNative_IsPredefinedLocale) + DllImportEntry(GlobalizationNative_LastIndexOf) + DllImportEntry(GlobalizationNative_LoadICU) +#if defined(STATIC_ICU) + DllImportEntry(GlobalizationNative_LoadICUData) +#endif + DllImportEntry(GlobalizationNative_NormalizeString) + DllImportEntry(GlobalizationNative_StartsWith) + DllImportEntry(GlobalizationNative_WindowsIdToIanaId) +#endif DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -// DllImportEntry(GlobalizationNative_WindowsIdToIanaId) #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 4b7660b04feff..942a9d1fa4d17 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -18,31 +18,31 @@ #if !defined(LOCAL_BUILD) #define U_DISABLE_RENAMING 1 #endif -#include // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -// #include -//#include -// #include -// #include - +#include +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#endif #endif #elif defined(TARGET_WINDOWS) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 6d6cd9d7cdc97..73477696b2280 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -10,7 +10,9 @@ #include #include #include -// #include +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#include +#endif #if defined(TARGET_UNIX) #include @@ -18,7 +20,7 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif - +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) static int32_t isLoaded = 0; static int32_t isDataSet = 0; @@ -26,16 +28,16 @@ static void log_shim_error(const char* format, ...) { va_list args; - //va_start(args, format); - //vfprintf(stderr, format, args); + va_start(args, format); + vfprintf(stderr, format, args); fputc('\n', stderr); - //va_end(args); + va_end(args); } static void log_icu_error(const char* name, UErrorCode status) { - // const char * statusText = u_errorName(status); - // log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText); + const char * statusText = u_errorName(status); + log_shim_error("ICU call %s failed with error #%d '%s'.", name, status, statusText); } #if defined(ICU_TRACING) @@ -83,7 +85,7 @@ static int32_t load_icu_data(const void* pData) { UErrorCode status = 0; - //udata_setCommonData(pData, &status); + udata_setCommonData(pData, &status); if (U_FAILURE(status)) { @@ -217,7 +219,7 @@ int32_t GlobalizationNative_LoadICU(void) UVersionInfo version; // Request the CLDR version to perform basic ICU initialization and find out // whether it worked. - //ulocdata_getCLDRVersion(version, &status); + ulocdata_getCLDRVersion(version, &status); if (U_FAILURE(status)) { @@ -243,7 +245,8 @@ int32_t GlobalizationNative_GetICUVersion(void) return 0; UVersionInfo versionInfo; - // u_getVersion(versionInfo); + u_getVersion(versionInfo); return (versionInfo[0] << 24) + (versionInfo[1] << 16) + (versionInfo[2] << 8) + versionInfo[3]; } +#endif // !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 77ce4a196429b..121046b91b09b 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -7,379 +7,6 @@ #include "pal_icushim_internal.h" #include -/* ### Data tables **************************************************/ - -/** - * Table of language codes, both 2- and 3-letter, with preference - * given to 2-letter codes where possible. Includes 3-letter codes - * that lack a 2-letter equivalent. - * - * This list must be in sorted order. This list is returned directly - * to the user by some API. - * - * This list must be kept in sync with LANGUAGES_3, with corresponding - * entries matched. - * - * This table should be terminated with a NULL entry, followed by a - * second list, and another NULL entry. The first list is visible to - * user code when this array is returned by API. The second list - * contains codes we support, but do not expose through user API. - * - * Notes - * - * Tables updated per http://lcweb.loc.gov/standards/iso639-2/ to - * include the revisions up to 2001/7/27 *CWB* - * - * The 3 character codes are the terminology codes like RFC 3066. - * - * "in" "iw" "ji" "jw" & "sh" have been withdrawn but are still in the - * table but now at the end of the table because 3 character codes are - * duplicates. This avoids bad searches going from 3 to 2 character - * codes. - * - * The range qaa-qtz is reserved for local use - */ -/* Subsequent hand addition of selected languages */ -static const char * const LANGUAGES[] = { - "aa", "ab", "ace", "ach", "ada", "ady", "ae", "aeb", - "af", "afh", "agq", "ain", "ak", "akk", "akz", "ale", - "aln", "alt", "am", "an", "ang", "anp", "ar", "arc", - "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "as", - "asa", "ase", "ast", "av", "avk", "awa", "ay", "az", - "ba", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", - "be", "bej", "bem", "bew", "bez", "bfd", "bfq", "bg", - "bgn", "bho", "bi", "bik", "bin", "bjn", "bkm", "bla", - "bm", "bn", "bo", "bpy", "bqi", "br", "bra", "brh", - "brx", "bs", "bss", "bua", "bug", "bum", "byn", "byv", - "ca", "cad", "car", "cay", "cch", "ccp", "ce", "ceb", "cgg", - "ch", "chb", "chg", "chk", "chm", "chn", "cho", "chp", - "chr", "chy", "ckb", "co", "cop", "cps", "cr", "crh", - "cs", "csb", "cu", "cv", "cy", - "da", "dak", "dar", "dav", "de", "del", "den", "dgr", - "din", "dje", "doi", "dsb", "dtp", "dua", "dum", "dv", - "dyo", "dyu", "dz", "dzg", - "ebu", "ee", "efi", "egl", "egy", "eka", "el", "elx", - "en", "enm", "eo", "es", "esu", "et", "eu", "ewo", - "ext", - "fa", "fan", "fat", "ff", "fi", "fil", "fit", "fj", - "fo", "fon", "fr", "frc", "frm", "fro", "frp", "frr", - "frs", "fur", "fy", - "ga", "gaa", "gag", "gan", "gay", "gba", "gbz", "gd", - "gez", "gil", "gl", "glk", "gmh", "gn", "goh", "gom", - "gon", "gor", "got", "grb", "grc", "gsw", "gu", "guc", - "gur", "guz", "gv", "gwi", - "ha", "hai", "hak", "haw", "he", "hi", "hif", "hil", - "hit", "hmn", "ho", "hr", "hsb", "hsn", "ht", "hu", - "hup", "hy", "hz", - "ia", "iba", "ibb", "id", "ie", "ig", "ii", "ik", - "ilo", "inh", "io", "is", "it", "iu", "izh", - "ja", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut", - "jv", - "ka", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd", - "kbl", "kcg", "kde", "kea", "ken", "kfo", "kg", "kgp", - "kha", "kho", "khq", "khw", "ki", "kiu", "kj", "kk", - "kkj", "kl", "kln", "km", "kmb", "kn", "ko", "koi", - "kok", "kos", "kpe", "kr", "krc", "kri", "krj", "krl", - "kru", "ks", "ksb", "ksf", "ksh", "ku", "kum", "kut", - "kv", "kw", "ky", - "la", "lad", "lag", "lah", "lam", "lb", "lez", "lfn", - "lg", "li", "lij", "liv", "lkt", "lmo", "ln", "lo", - "lol", "loz", "lrc", "lt", "ltg", "lu", "lua", "lui", - "lun", "luo", "lus", "luy", "lv", "lzh", "lzz", - "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", - "mdf", "mdh", "mdr", "men", "mer", "mfe", "mg", "mga", - "mgh", "mgo", "mh", "mi", "mic", "min", "mis", "mk", - "ml", "mn", "mnc", "mni", "mo", - "moh", "mos", "mr", "mrj", - "ms", "mt", "mua", "mul", "mus", "mwl", "mwr", "mwv", - "my", "mye", "myv", "mzn", - "na", "nan", "nap", "naq", "nb", "nd", "nds", "ne", - "new", "ng", "nia", "niu", "njo", "nl", "nmg", "nn", - "nnh", "no", "nog", "non", "nov", "nqo", "nr", "nso", - "nus", "nv", "nwc", "ny", "nym", "nyn", "nyo", "nzi", - "oc", "oj", "om", "or", "os", "osa", "ota", - "pa", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", - "pdt", "peo", "pfl", "phn", "pi", "pl", "pms", "pnt", - "pon", "prg", "pro", "ps", "pt", - "qu", "quc", "qug", - "raj", "rap", "rar", "rgn", "rif", "rm", "rn", "ro", - "rof", "rom", "rtm", "ru", "rue", "rug", "rup", - "rw", "rwk", - "sa", "sad", "sah", "sam", "saq", "sas", "sat", "saz", - "sba", "sbp", "sc", "scn", "sco", "sd", "sdc", "sdh", - "se", "see", "seh", "sei", "sel", "ses", "sg", "sga", - "sgs", "shi", "shn", "shu", "si", "sid", "sk", - "sl", "sli", "sly", "sm", "sma", "smj", "smn", "sms", - "sn", "snk", "so", "sog", "sq", "sr", "srn", "srr", - "ss", "ssy", "st", "stq", "su", "suk", "sus", "sux", - "sv", "sw", "swb", "swc", "syc", "syr", "szl", - "ta", "tcy", "te", "tem", "teo", "ter", "tet", "tg", - "th", "ti", "tig", "tiv", "tk", "tkl", "tkr", "tl", - "tlh", "tli", "tly", "tmh", "tn", "to", "tog", "tpi", - "tr", "tru", "trv", "ts", "tsd", "tsi", "tt", "ttt", - "tum", "tvl", "tw", "twq", "ty", "tyv", "tzm", - "udm", "ug", "uga", "uk", "umb", "und", "ur", "uz", - "vai", "ve", "vec", "vep", "vi", "vls", "vmf", "vo", - "vot", "vro", "vun", - "wa", "wae", "wal", "war", "was", "wbp", "wo", "wuu", - "xal", "xh", "xmf", "xog", - "yao", "yap", "yav", "ybb", "yi", "yo", "yrl", "yue", - "za", "zap", "zbl", "zea", "zen", "zgh", "zh", "zu", - "zun", "zxx", "zza", -NULL, - "in", "iw", "ji", "jw", "sh", /* obsolete language codes */ -NULL -}; - -/** - * Table of 3-letter language codes. - * - * This is a lookup table used to convert 3-letter language codes to - * their 2-letter equivalent, where possible. It must be kept in sync - * with LANGUAGES. For all valid i, LANGUAGES[i] must refer to the - * same language as LANGUAGES_3[i]. The commented-out lines are - * copied from LANGUAGES to make eyeballing this baby easier. - * - * Where a 3-letter language code has no 2-letter equivalent, the - * 3-letter code occupies both LANGUAGES[i] and LANGUAGES_3[i]. - * - * This table should be terminated with a NULL entry, followed by a - * second list, and another NULL entry. The two lists correspond to - * the two lists in LANGUAGES. - */ -/* Subsequent hand addition of selected languages */ -static const char * const LANGUAGES_3[] = { - "aar", "abk", "ace", "ach", "ada", "ady", "ave", "aeb", - "afr", "afh", "agq", "ain", "aka", "akk", "akz", "ale", - "aln", "alt", "amh", "arg", "ang", "anp", "ara", "arc", - "arn", "aro", "arp", "arq", "ars", "arw", "ary", "arz", "asm", - "asa", "ase", "ast", "ava", "avk", "awa", "aym", "aze", - "bak", "bal", "ban", "bar", "bas", "bax", "bbc", "bbj", - "bel", "bej", "bem", "bew", "bez", "bfd", "bfq", "bul", - "bgn", "bho", "bis", "bik", "bin", "bjn", "bkm", "bla", - "bam", "ben", "bod", "bpy", "bqi", "bre", "bra", "brh", - "brx", "bos", "bss", "bua", "bug", "bum", "byn", "byv", - "cat", "cad", "car", "cay", "cch", "ccp", "che", "ceb", "cgg", - "cha", "chb", "chg", "chk", "chm", "chn", "cho", "chp", - "chr", "chy", "ckb", "cos", "cop", "cps", "cre", "crh", - "ces", "csb", "chu", "chv", "cym", - "dan", "dak", "dar", "dav", "deu", "del", "den", "dgr", - "din", "dje", "doi", "dsb", "dtp", "dua", "dum", "div", - "dyo", "dyu", "dzo", "dzg", - "ebu", "ewe", "efi", "egl", "egy", "eka", "ell", "elx", - "eng", "enm", "epo", "spa", "esu", "est", "eus", "ewo", - "ext", - "fas", "fan", "fat", "ful", "fin", "fil", "fit", "fij", - "fao", "fon", "fra", "frc", "frm", "fro", "frp", "frr", - "frs", "fur", "fry", - "gle", "gaa", "gag", "gan", "gay", "gba", "gbz", "gla", - "gez", "gil", "glg", "glk", "gmh", "grn", "goh", "gom", - "gon", "gor", "got", "grb", "grc", "gsw", "guj", "guc", - "gur", "guz", "glv", "gwi", - "hau", "hai", "hak", "haw", "heb", "hin", "hif", "hil", - "hit", "hmn", "hmo", "hrv", "hsb", "hsn", "hat", "hun", - "hup", "hye", "her", - "ina", "iba", "ibb", "ind", "ile", "ibo", "iii", "ipk", - "ilo", "inh", "ido", "isl", "ita", "iku", "izh", - "jpn", "jam", "jbo", "jgo", "jmc", "jpr", "jrb", "jut", - "jav", - "kat", "kaa", "kab", "kac", "kaj", "kam", "kaw", "kbd", - "kbl", "kcg", "kde", "kea", "ken", "kfo", "kon", "kgp", - "kha", "kho", "khq", "khw", "kik", "kiu", "kua", "kaz", - "kkj", "kal", "kln", "khm", "kmb", "kan", "kor", "koi", - "kok", "kos", "kpe", "kau", "krc", "kri", "krj", "krl", - "kru", "kas", "ksb", "ksf", "ksh", "kur", "kum", "kut", - "kom", "cor", "kir", - "lat", "lad", "lag", "lah", "lam", "ltz", "lez", "lfn", - "lug", "lim", "lij", "liv", "lkt", "lmo", "lin", "lao", - "lol", "loz", "lrc", "lit", "ltg", "lub", "lua", "lui", - "lun", "luo", "lus", "luy", "lav", "lzh", "lzz", - "mad", "maf", "mag", "mai", "mak", "man", "mas", "mde", - "mdf", "mdh", "mdr", "men", "mer", "mfe", "mlg", "mga", - "mgh", "mgo", "mah", "mri", "mic", "min", "mis", "mkd", - "mal", "mon", "mnc", "mni", "mol", - "moh", "mos", "mar", "mrj", - "msa", "mlt", "mua", "mul", "mus", "mwl", "mwr", "mwv", - "mya", "mye", "myv", "mzn", - "nau", "nan", "nap", "naq", "nob", "nde", "nds", "nep", - "new", "ndo", "nia", "niu", "njo", "nld", "nmg", "nno", - "nnh", "nor", "nog", "non", "nov", "nqo", "nbl", "nso", - "nus", "nav", "nwc", "nya", "nym", "nyn", "nyo", "nzi", - "oci", "oji", "orm", "ori", "oss", "osa", "ota", - "pan", "pag", "pal", "pam", "pap", "pau", "pcd", "pcm", "pdc", - "pdt", "peo", "pfl", "phn", "pli", "pol", "pms", "pnt", - "pon", "prg", "pro", "pus", "por", - "que", "quc", "qug", - "raj", "rap", "rar", "rgn", "rif", "roh", "run", "ron", - "rof", "rom", "rtm", "rus", "rue", "rug", "rup", - "kin", "rwk", - "san", "sad", "sah", "sam", "saq", "sas", "sat", "saz", - "sba", "sbp", "srd", "scn", "sco", "snd", "sdc", "sdh", - "sme", "see", "seh", "sei", "sel", "ses", "sag", "sga", - "sgs", "shi", "shn", "shu", "sin", "sid", "slk", - "slv", "sli", "sly", "smo", "sma", "smj", "smn", "sms", - "sna", "snk", "som", "sog", "sqi", "srp", "srn", "srr", - "ssw", "ssy", "sot", "stq", "sun", "suk", "sus", "sux", - "swe", "swa", "swb", "swc", "syc", "syr", "szl", - "tam", "tcy", "tel", "tem", "teo", "ter", "tet", "tgk", - "tha", "tir", "tig", "tiv", "tuk", "tkl", "tkr", "tgl", - "tlh", "tli", "tly", "tmh", "tsn", "ton", "tog", "tpi", - "tur", "tru", "trv", "tso", "tsd", "tsi", "tat", "ttt", - "tum", "tvl", "twi", "twq", "tah", "tyv", "tzm", - "udm", "uig", "uga", "ukr", "umb", "und", "urd", "uzb", - "vai", "ven", "vec", "vep", "vie", "vls", "vmf", "vol", - "vot", "vro", "vun", - "wln", "wae", "wal", "war", "was", "wbp", "wol", "wuu", - "xal", "xho", "xmf", "xog", - "yao", "yap", "yav", "ybb", "yid", "yor", "yrl", "yue", - "zha", "zap", "zbl", "zea", "zen", "zgh", "zho", "zul", - "zun", "zxx", "zza", -NULL, -/* "in", "iw", "ji", "jw", "sh", */ - "ind", "heb", "yid", "jaw", "srp", -NULL -}; - -/** - * Table of 2-letter country codes. - * - * This list must be in sorted order. This list is returned directly - * to the user by some API. - * - * This list must be kept in sync with COUNTRIES_3, with corresponding - * entries matched. - * - * This table should be terminated with a NULL entry, followed by a - * second list, and another NULL entry. The first list is visible to - * user code when this array is returned by API. The second list - * contains codes we support, but do not expose through user API. - * - * Notes: - * - * ZR(ZAR) is now CD(COD) and FX(FXX) is PS(PSE) as per - * http://www.evertype.com/standards/iso3166/iso3166-1-en.html added - * new codes keeping the old ones for compatibility updated to include - * 1999/12/03 revisions *CWB* - * - * RO(ROM) is now RO(ROU) according to - * http://www.iso.org/iso/en/prods-services/iso3166ma/03updates-on-iso-3166/nlv3e-rou.html - */ -static const char * const COUNTRIES[] = { - "AD", "AE", "AF", "AG", "AI", "AL", "AM", - "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", - "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", - "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", - "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", - "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", - "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", - "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", - "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", - "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", - "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", - "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", - "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS", - "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", - "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", - "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", - "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", - "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", - "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", - "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", - "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", - "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", - "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", - "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", - "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", - "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", - "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", - "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", - "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", - "WS", "YE", "YT", "ZA", "ZM", "ZW", -NULL, - "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR", /* obsolete country codes */ -NULL -}; - -/** - * Table of 3-letter country codes. - * - * This is a lookup table used to convert 3-letter country codes to - * their 2-letter equivalent. It must be kept in sync with COUNTRIES. - * For all valid i, COUNTRIES[i] must refer to the same country as - * COUNTRIES_3[i]. The commented-out lines are copied from COUNTRIES - * to make eyeballing this baby easier. - * - * This table should be terminated with a NULL entry, followed by a - * second list, and another NULL entry. The two lists correspond to - * the two lists in COUNTRIES. - */ -static const char * const COUNTRIES_3[] = { -/* "AD", "AE", "AF", "AG", "AI", "AL", "AM", */ - "AND", "ARE", "AFG", "ATG", "AIA", "ALB", "ARM", -/* "AO", "AQ", "AR", "AS", "AT", "AU", "AW", "AX", "AZ", */ - "AGO", "ATA", "ARG", "ASM", "AUT", "AUS", "ABW", "ALA", "AZE", -/* "BA", "BB", "BD", "BE", "BF", "BG", "BH", "BI", */ - "BIH", "BRB", "BGD", "BEL", "BFA", "BGR", "BHR", "BDI", -/* "BJ", "BL", "BM", "BN", "BO", "BQ", "BR", "BS", "BT", "BV", */ - "BEN", "BLM", "BMU", "BRN", "BOL", "BES", "BRA", "BHS", "BTN", "BVT", -/* "BW", "BY", "BZ", "CA", "CC", "CD", "CF", "CG", */ - "BWA", "BLR", "BLZ", "CAN", "CCK", "COD", "CAF", "COG", -/* "CH", "CI", "CK", "CL", "CM", "CN", "CO", "CR", */ - "CHE", "CIV", "COK", "CHL", "CMR", "CHN", "COL", "CRI", -/* "CU", "CV", "CW", "CX", "CY", "CZ", "DE", "DJ", "DK", */ - "CUB", "CPV", "CUW", "CXR", "CYP", "CZE", "DEU", "DJI", "DNK", -/* "DM", "DO", "DZ", "EC", "EE", "EG", "EH", "ER", */ - "DMA", "DOM", "DZA", "ECU", "EST", "EGY", "ESH", "ERI", -/* "ES", "ET", "FI", "FJ", "FK", "FM", "FO", "FR", */ - "ESP", "ETH", "FIN", "FJI", "FLK", "FSM", "FRO", "FRA", -/* "GA", "GB", "GD", "GE", "GF", "GG", "GH", "GI", "GL", */ - "GAB", "GBR", "GRD", "GEO", "GUF", "GGY", "GHA", "GIB", "GRL", -/* "GM", "GN", "GP", "GQ", "GR", "GS", "GT", "GU", */ - "GMB", "GIN", "GLP", "GNQ", "GRC", "SGS", "GTM", "GUM", -/* "GW", "GY", "HK", "HM", "HN", "HR", "HT", "HU", */ - "GNB", "GUY", "HKG", "HMD", "HND", "HRV", "HTI", "HUN", -/* "ID", "IE", "IL", "IM", "IN", "IO", "IQ", "IR", "IS" */ - "IDN", "IRL", "ISR", "IMN", "IND", "IOT", "IRQ", "IRN", "ISL", -/* "IT", "JE", "JM", "JO", "JP", "KE", "KG", "KH", "KI", */ - "ITA", "JEY", "JAM", "JOR", "JPN", "KEN", "KGZ", "KHM", "KIR", -/* "KM", "KN", "KP", "KR", "KW", "KY", "KZ", "LA", */ - "COM", "KNA", "PRK", "KOR", "KWT", "CYM", "KAZ", "LAO", -/* "LB", "LC", "LI", "LK", "LR", "LS", "LT", "LU", */ - "LBN", "LCA", "LIE", "LKA", "LBR", "LSO", "LTU", "LUX", -/* "LV", "LY", "MA", "MC", "MD", "ME", "MF", "MG", "MH", "MK", */ - "LVA", "LBY", "MAR", "MCO", "MDA", "MNE", "MAF", "MDG", "MHL", "MKD", -/* "ML", "MM", "MN", "MO", "MP", "MQ", "MR", "MS", */ - "MLI", "MMR", "MNG", "MAC", "MNP", "MTQ", "MRT", "MSR", -/* "MT", "MU", "MV", "MW", "MX", "MY", "MZ", "NA", */ - "MLT", "MUS", "MDV", "MWI", "MEX", "MYS", "MOZ", "NAM", -/* "NC", "NE", "NF", "NG", "NI", "NL", "NO", "NP", */ - "NCL", "NER", "NFK", "NGA", "NIC", "NLD", "NOR", "NPL", -/* "NR", "NU", "NZ", "OM", "PA", "PE", "PF", "PG", */ - "NRU", "NIU", "NZL", "OMN", "PAN", "PER", "PYF", "PNG", -/* "PH", "PK", "PL", "PM", "PN", "PR", "PS", "PT", */ - "PHL", "PAK", "POL", "SPM", "PCN", "PRI", "PSE", "PRT", -/* "PW", "PY", "QA", "RE", "RO", "RS", "RU", "RW", "SA", */ - "PLW", "PRY", "QAT", "REU", "ROU", "SRB", "RUS", "RWA", "SAU", -/* "SB", "SC", "SD", "SE", "SG", "SH", "SI", "SJ", */ - "SLB", "SYC", "SDN", "SWE", "SGP", "SHN", "SVN", "SJM", -/* "SK", "SL", "SM", "SN", "SO", "SR", "SS", "ST", "SV", */ - "SVK", "SLE", "SMR", "SEN", "SOM", "SUR", "SSD", "STP", "SLV", -/* "SX", "SY", "SZ", "TC", "TD", "TF", "TG", "TH", "TJ", */ - "SXM", "SYR", "SWZ", "TCA", "TCD", "ATF", "TGO", "THA", "TJK", -/* "TK", "TL", "TM", "TN", "TO", "TR", "TT", "TV", */ - "TKL", "TLS", "TKM", "TUN", "TON", "TUR", "TTO", "TUV", -/* "TW", "TZ", "UA", "UG", "UM", "US", "UY", "UZ", */ - "TWN", "TZA", "UKR", "UGA", "UMI", "USA", "URY", "UZB", -/* "VA", "VC", "VE", "VG", "VI", "VN", "VU", "WF", */ - "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", -/* "WS", "YE", "YT", "ZA", "ZM", "ZW", */ - "WSM", "YEM", "MYT", "ZAF", "ZMB", "ZWE", -NULL, -/* "AN", "BU", "CS", "FX", "RO", "SU", "TP", "YD", "YU", "ZR" */ - "ANT", "BUR", "SCG", "FXX", "ROM", "SUN", "TMP", "YMD", "YUG", "ZAR", -NULL -}; - PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); From 662d5ea07afcbfad4762a834c9bc6d7a284b9181 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 30 Oct 2023 17:38:32 +0100 Subject: [PATCH 023/105] Fix non Apple platform builds --- src/mono/mono/mini/CMakeLists.txt | 6 +++++- .../libs/System.Globalization.Native/CMakeLists.txt | 9 +++++---- .../System.Globalization.Native/pal_icushim_internal.h | 3 ++- .../System.Globalization.Native/pal_icushim_static.c | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 6ecf9e2888708..217a07e08d545 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -431,7 +431,11 @@ if(NOT DISABLE_SHARED_LIBS) # to avoid a conflict we rename the import library with the .import.lib suffix set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib") endif() - target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS}) + if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${Z_LIBS}) + else() + target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) + endif() if(ICU_LDFLAGS) set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index c42cd89869e75..539be6d44691c 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -25,9 +25,10 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") endif() - find_path(UCURR_H "unicode/ucurr.h") + find_path(UCURR_H "unicode/ucurr.h" PATHS ${ICU_HOMEBREW_INC_PATH}) if(UCURR_H STREQUAL UCURR_H-NOTFOUND) message(FATAL_ERROR "Cannot find ucurr.h, try installing libicu-dev (or the appropriate package for your platform)") return() @@ -71,9 +72,9 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE ) endif() -#if (DEFINED CMAKE_ICU_DIR) -# include_directories(${CMAKE_ICU_DIR}/include) -#endif() +if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR) + include_directories(${CMAKE_ICU_DIR}/include) +endif() if ((CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND NOT DEFINED CMAKE_ICU_DIR) link_libraries(icucore) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 942a9d1fa4d17..a157bc2155617 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -23,6 +23,7 @@ // available before the function pointers are declared below. #include #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) + #include #include #include @@ -34,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -42,6 +42,7 @@ #include #include #include + #endif #endif diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 73477696b2280..c0aacd4407659 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -10,6 +10,7 @@ #include #include #include + #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include #endif From a3db930ef7046f842a2cbb8c6e43a1b8d53fa6c7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 1 Nov 2023 16:14:14 +0100 Subject: [PATCH 024/105] Fix merge conflicts --- .../Common/src/Interop/Interop.Locale.iOS.cs | 7 ------- .../System.Globalization/tests/IcuTests.cs | 2 +- .../System/Globalization/CultureData.Icu.cs | 1 - .../System/Globalization/CultureInfo.Unix.cs | 17 +-------------- .../System.Globalization.Native/entrypoints.c | 1 - .../System.Globalization.Native/pal_casing.m | 21 ------------------- .../System.Globalization.Native/pal_common.c | 1 + 7 files changed, 3 insertions(+), 47 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs index 03c82232ebbb7..3062de8918dc3 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.iOS.cs @@ -13,13 +13,6 @@ internal static partial class Globalization [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoStringNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial string GetLocaleInfoStringNative(string localeName, uint localeStringData); - [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleNameNative", StringMarshalling = StringMarshalling.Utf8)] - internal static unsafe partial string GetDefaultLocaleNameNative(); - - [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocaleNative", StringMarshalling = StringMarshalling.Utf8)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static partial bool IsPredefinedLocaleNative(string localeName); - [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoIntNative", StringMarshalling = StringMarshalling.Utf8)] internal static partial int GetLocaleInfoIntNative(string localeName, uint localeNumberData); diff --git a/src/libraries/System.Globalization/tests/IcuTests.cs b/src/libraries/System.Globalization/tests/IcuTests.cs index 1c9998c5d3ff7..05b0e950d7432 100644 --- a/src/libraries/System.Globalization/tests/IcuTests.cs +++ b/src/libraries/System.Globalization/tests/IcuTests.cs @@ -12,7 +12,7 @@ public class IcuTests private static bool IsIcuCompatiblePlatform => !PlatformDetection.IsHybridGlobalizationOnOSX && PlatformDetection.IsNotWindows || ((PlatformDetection.IsWindowsServer2019 || PlatformDetection.IsWindows10Version1903OrGreater) && // Server core doesn't have icu.dll on SysWOW64 - !(PlatformDetection.IsWindowsServerCore && PlatformDetection.IsX86Process))); + !(PlatformDetection.IsWindowsServerCore && PlatformDetection.IsX86Process)); [ConditionalFact(nameof(IsIcuCompatiblePlatform))] public static void IcuShouldBeUsedByDefault() diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs index 483c7ec4be7c6..add21d8ce3f4d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.Icu.cs @@ -138,7 +138,6 @@ private bool InitIcuCultureDataCore() return false; } } -#endif Debug.Assert(_sWindowsName != null); diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs index 361c218da2077..a35b88c220609 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs @@ -13,22 +13,7 @@ internal static CultureInfo GetUserDefaultCulture() return CultureInfo.InvariantCulture; CultureInfo cultureInfo; - string? localeName; - bool result = false; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - if (GlobalizationMode.Hybrid) - { - localeName = Interop.Globalization.GetDefaultLocaleNameNative(); - result = localeName != null; - } - else - { - result = CultureData.GetDefaultLocaleName(out localeName); - } -#else - result = CultureData.GetDefaultLocaleName(out localeName); -#endif - if (result) + if (CultureData.GetDefaultLocaleName(out string? localeName)) { Debug.Assert(localeName != null); cultureInfo = GetCultureByName(localeName); diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 648a44e2e2361..81c6c483883f6 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -46,7 +46,6 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_IanaIdToWindowsId) DllImportEntry(GlobalizationNative_IndexOf) DllImportEntry(GlobalizationNative_InitICUFunctions) - DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) DllImportEntry(GlobalizationNative_IsNormalized) DllImportEntry(GlobalizationNative_IsPredefinedLocale) DllImportEntry(GlobalizationNative_LastIndexOf) diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index 876da67f04d81..9ec193b071bc6 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -150,25 +150,4 @@ int32_t GlobalizationNative_ChangeCaseInvariantNative(const uint16_t* lpSrc, int } } -void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget) -{ - @autoreleasepool - { - pageNumber <<= 8; - for (int i = 0; i < 256; i++) - { - // Unfortunately, to ensure one-to-one simple mapping we have to call u_toupper on every character. - // Using string casing ICU APIs cannot give such results even when using NULL locale to force root behavior. - pTarget[i] = (UChar) u_toupper((UChar32)(pageNumber + i)); - } - - if (pageNumber == 0x0100) - { - // Disable Turkish I behavior on Ordinal operations - pTarget[0x31] = (UChar)0x0131; // Turkish lowercase i - pTarget[0x7F] = (UChar)0x017F; // // 017F;LATIN SMALL LETTER LONG S - } - } -} - #endif diff --git a/src/native/libs/System.Globalization.Native/pal_common.c b/src/native/libs/System.Globalization.Native/pal_common.c index 5904a1c3bdbe2..704fb3fc68580 100644 --- a/src/native/libs/System.Globalization.Native/pal_common.c +++ b/src/native/libs/System.Globalization.Native/pal_common.c @@ -1,6 +1,7 @@ #include #include "pal_icushim_internal.h" #include "pal_casing.h" +#include void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget) { From 58601033db51b0527bf864dfc37c8d3c13ae2dad Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 2 Nov 2023 14:51:00 +0100 Subject: [PATCH 025/105] Fix failed tests after merge --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 2 +- .../tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index a33f7a09f2df2..a80bcc85a7c6f 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -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 { diff --git a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs index eacdfb0455a67..6e09c2f9e5eaa 100644 --- a/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs +++ b/src/libraries/System.Globalization/tests/DateTimeFormatInfo/DateTimeFormatInfoTests.cs @@ -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); From 16b384706bd404f5701d3331b01fd97dc4c90e83 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 2 Nov 2023 15:35:38 +0100 Subject: [PATCH 026/105] Include pal files for non Apple platforms --- src/mono/mono/mini/CMakeLists.txt | 5 +++-- src/native/libs/System.Globalization.Native/CMakeLists.txt | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 65adbf7e84ccc..a0956e218e559 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -62,8 +62,8 @@ if(HAVE_SYS_ICU) entrypoints.c ${pal_icushim_sources_base}) -if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) - set(NATIVEGLOBALIZATION_SOURCES +if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) + set(icu_shim_sources_base pal_calendarData.c pal_casing.c pal_collation.c @@ -72,6 +72,7 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE pal_localeStringData.c pal_normalization.c pal_timeZoneInfo.c + ${icu_shim_sources_base} ) endif() diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 275a41a0eefd2..05320b1ad176d 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -61,7 +61,7 @@ set(NATIVEGLOBALIZATION_SOURCES pal_idna.c pal_common.c ) -if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) +if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(NATIVEGLOBALIZATION_SOURCES pal_calendarData.c pal_casing.c @@ -70,6 +70,7 @@ if (NOT CLR_CMAKE_TARGET_BROWSER AND NOT CLR_CMAKE_TARGET_WASI AND NOT CLR_CMAKE pal_localeNumberData.c pal_localeStringData.c pal_normalization.c + ${NATIVEGLOBALIZATION_SOURCES} ) endif() From 710ce29f0f385d46f4b813099efd931c05d23674 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 08:36:20 +0100 Subject: [PATCH 027/105] fix nativeaot build failure --- eng/testing/tests.ioslike.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index 5d41f23a62287..8f788e03b055e 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -77,7 +77,7 @@ Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" /> - + Date: Mon, 6 Nov 2023 09:08:15 +0100 Subject: [PATCH 028/105] Fix -licucore related failures --- src/mono/mono/mini/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/pal_common.c | 2 ++ .../libs/System.Globalization.Native/pal_icushim_internal.h | 3 +++ src/native/libs/System.Globalization.Native/pal_idna.h | 3 +++ src/native/libs/System.Globalization.Native/pal_locale.h | 2 ++ 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 62cb35ca3b7c2..315a71705f878 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -101,7 +101,7 @@ endif() endif() if(ICU_LIBDIR) set(ICU_LDFLAGS "-L${ICU_LIBDIR}") - else() + if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(ICU_LDFLAGS "-licucore") endif() diff --git a/src/native/libs/System.Globalization.Native/pal_common.c b/src/native/libs/System.Globalization.Native/pal_common.c index 704fb3fc68580..6141b66699871 100644 --- a/src/native/libs/System.Globalization.Native/pal_common.c +++ b/src/native/libs/System.Globalization.Native/pal_common.c @@ -1,7 +1,9 @@ #include #include "pal_icushim_internal.h" #include "pal_casing.h" +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include +#endif void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget) { diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index a157bc2155617..6a2f19d299911 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,7 +21,9 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include +#endif #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include @@ -40,6 +42,7 @@ #include #include #include +#include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 797bdb85f6d53..cd4e61bc10a65 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,8 +7,11 @@ #include "pal_locale.h" #include "pal_compiler.h" #include "pal_icushim_internal.h" + +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #include +#endif PALEXPORT int32_t GlobalizationNative_ToAscii(uint32_t flags, const UChar* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 121046b91b09b..ec2ff293658c1 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -5,7 +5,9 @@ #include "pal_compiler.h" #include "pal_icushim_internal.h" +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include +#endif PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); From 49ef3ab56437a95a2132fe6497c234acaf997ce4 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 09:18:41 +0100 Subject: [PATCH 029/105] Fix CMake if block --- src/mono/mono/mini/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 315a71705f878..7ee8621bdbc14 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -101,6 +101,7 @@ endif() endif() if(ICU_LIBDIR) set(ICU_LDFLAGS "-L${ICU_LIBDIR}") + endif() if(CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) set(ICU_LDFLAGS "-licucore") endif() From 3bbe6d875d00ba8b7b094ad87f18dc3b2aa75efd Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 11:33:53 +0100 Subject: [PATCH 030/105] Remove "pal_icushim_internal.h" from headers --- .../libs/System.Globalization.Native/entrypoints.c | 3 ++- .../libs/System.Globalization.Native/pal_casing.h | 1 - .../pal_errors_internal.h | 4 +++- .../pal_icushim_internal.h | 6 +++--- .../libs/System.Globalization.Native/pal_idna.h | 1 - .../libs/System.Globalization.Native/pal_locale.h | 12 ++++++++---- .../pal_locale_internal.h | 4 +++- .../System.Globalization.Native/pal_normalization.h | 1 - 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 81c6c483883f6..e40c3fd4a10d9 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,8 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +// #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#ifndef __APPLE__ DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 75c3386ca9709..e39d38ecb1c11 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,6 @@ #include "pal_locale.h" #include "pal_compiler.h" -#include "pal_icushim_internal.h" PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index 1680335834736..4ee385fd4c90a 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,7 +5,9 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" - +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#include +#endif /* Converts a UErrorCode to a ResultCode. */ diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 6a2f19d299911..956c630065057 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,9 +21,9 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#include -#endif +// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +// #include +// #endif #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index cd4e61bc10a65..29818576d6900 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -6,7 +6,6 @@ #include "pal_locale.h" #include "pal_compiler.h" -#include "pal_icushim_internal.h" #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index ec2ff293658c1..62350aa3e7601 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -4,10 +4,11 @@ #pragma once #include "pal_compiler.h" -#include "pal_icushim_internal.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#include -#endif +// #include "pal_icushim_internal.h" +// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +// #include +// #endif +#ifndef __APPLE__ PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); @@ -20,8 +21,11 @@ PALEXPORT int32_t GlobalizationNative_IsPredefinedLocale(const UChar* localeName PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength); +#endif #ifdef __APPLE__ +#include + PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); PALEXPORT const char* GlobalizationNative_GetLocaleNameNative(const char* localeName); diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index c754554bbfdd5..7c80adc7d051d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,7 +4,9 @@ #pragma once #include "pal_icushim_internal.h" - +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#include +#endif /* Function: UErrorCodeToBool diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 57f6fe508d5a8..198d3f9d518f0 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -6,7 +6,6 @@ #include "pal_locale.h" #include "pal_compiler.h" -#include "pal_icushim_internal.h" /* * These values should be kept in sync with System.Text.NormalizationForm From 380efe4a79416270b50c0be2f55dcf2151a9b0b0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 13:52:24 +0100 Subject: [PATCH 031/105] fix osx failures --- src/native/libs/System.Globalization.Native/entrypoints.c | 5 ++--- src/native/libs/System.Globalization.Native/pal_locale.h | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index e40c3fd4a10d9..297d0a7bb13cc 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,8 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -// #if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) -#ifndef __APPLE__ +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) @@ -61,7 +60,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !defined(TARGET_OSX) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) DllImportEntry(GlobalizationNative_CompareStringNative) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 62350aa3e7601..80923884bb9d3 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,8 +8,7 @@ // #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // #include // #endif -#ifndef __APPLE__ - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); @@ -23,7 +22,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(TARGET_OSX) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); From 429d777147482b513684e34a08555c105ef95019 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 14:18:43 +0100 Subject: [PATCH 032/105] Fix OSX failures --- src/mono/mono/mini/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/CMakeLists.txt | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.h | 5 +++-- src/native/libs/System.Globalization.Native/pal_casing.h | 6 +++--- src/native/libs/System.Globalization.Native/pal_collation.h | 5 +++-- .../libs/System.Globalization.Native/pal_localeNumberData.h | 6 +++--- .../libs/System.Globalization.Native/pal_localeStringData.h | 6 +++--- .../libs/System.Globalization.Native/pal_normalization.h | 5 +++-- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 6 +++--- 9 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 7ee8621bdbc14..7d5f03ebfa2bf 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -78,7 +78,7 @@ endif() addprefix(icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}") - if (TARGET_DARWIN) + if (TARGET_DARWIN AND NOT CLR_CMAKE_TARGET_OSX) set(icu_shim_darwin_sources_base pal_locale.m pal_collation.m diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 05320b1ad176d..1aeac67c4aab4 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -22,7 +22,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-unknown-warning-option) # The mobile configurations in particular bring their own ICU, so skip - if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) + if ((NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) OR (CLR_CMAKE_TARGET_MACCATALYST AND CLR_CMAKE_TARGET_OSX)) if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") @@ -74,7 +74,7 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM ) endif() -if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR) +if ((CLR_CMAKE_TARGET_MACCATALYST AND CLR_CMAKE_TARGET_OSX) OR (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR)) include_directories(${CMAKE_ICU_DIR}/include) endif() diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index ab725f7f65df1..eac5026d72012 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,6 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, @@ -101,8 +102,8 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay); - -#ifdef __APPLE__ +#endif +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index e39d38ecb1c11..4b2f53cfc04f2 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,7 @@ #include "pal_locale.h" #include "pal_compiler.h" - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, @@ -21,10 +21,10 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper); - +#endif PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index a8b44ba164f4a..35c9ea4bd3756 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); @@ -65,8 +65,9 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options); +#endif -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index a68f1e32e334a..ef022a6213d35 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); @@ -43,8 +43,8 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize); - -#ifdef __APPLE__ +#endif +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index a6961c39761bf..b4447f27c4603 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,14 +43,14 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName); - -#ifdef __APPLE__ +#endif +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 198d3f9d518f0..345ec9053ab54 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); @@ -27,8 +27,9 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength); +#endif -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 99653b939196e..c4f5940bc222d 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,12 +20,12 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); - -#ifdef __APPLE__ +#endif +#if defined(__APPLE__) && !defined(TARGET_OSX) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif From 1d1021eaa73d746dd1e92f535565b0d517ce76ce Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 6 Nov 2023 16:09:48 +0100 Subject: [PATCH 033/105] Fix osx build failures --- src/mono/CMakeLists.txt | 1 - src/mono/mono/mini/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/CMakeLists.txt | 4 ++-- src/native/libs/System.Globalization.Native/entrypoints.c | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_casing.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_collation.h | 4 ++-- .../libs/System.Globalization.Native/pal_icushim_internal.h | 6 +----- src/native/libs/System.Globalization.Native/pal_locale.h | 4 ++-- .../libs/System.Globalization.Native/pal_localeNumberData.h | 4 ++-- .../libs/System.Globalization.Native/pal_localeStringData.h | 4 ++-- .../libs/System.Globalization.Native/pal_normalization.h | 4 ++-- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 4 ++-- 13 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 9ef5f96eafc03..4f937c888cd32 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -749,7 +749,6 @@ elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) - #set(ICU_LIBS icuuc icui18n icudata) elseif(HOST_ANDROID) set(ICU_FLAGS "-DPALEXPORT=\"\" -DHAVE_UDAT_STANDALONE_SHORTER_WEEKDAYS -DHAVE_SET_MAX_VARIABLE -DTARGET_UNIX -DTARGET_ANDROID -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option") set(HAVE_SYS_ICU 1) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 7d5f03ebfa2bf..7ee8621bdbc14 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -78,7 +78,7 @@ endif() addprefix(icu_shim_sources "${ICU_SHIM_PATH}" "${icu_shim_sources_base}") - if (TARGET_DARWIN AND NOT CLR_CMAKE_TARGET_OSX) + if (TARGET_DARWIN) set(icu_shim_darwin_sources_base pal_locale.m pal_collation.m diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 1aeac67c4aab4..05320b1ad176d 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -22,7 +22,7 @@ if(CLR_CMAKE_TARGET_UNIX OR CLR_CMAKE_TARGET_WASI) add_compile_options(-Wno-unknown-warning-option) # The mobile configurations in particular bring their own ICU, so skip - if ((NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) OR (CLR_CMAKE_TARGET_MACCATALYST AND CLR_CMAKE_TARGET_OSX)) + if (NOT CLR_CMAKE_TARGET_ANDROID AND NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT DEFINED CMAKE_ICU_DIR) if (CLR_CMAKE_TARGET_OSX) execute_process(COMMAND brew --prefix OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE) set(ICU_HOMEBREW_INC_PATH "${brew_prefix}/opt/icu4c/include") @@ -74,7 +74,7 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM ) endif() -if ((CLR_CMAKE_TARGET_MACCATALYST AND CLR_CMAKE_TARGET_OSX) OR (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR)) +if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR) include_directories(${CMAKE_ICU_DIR}/include) endif() diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 297d0a7bb13cc..3a7cfa2f2535f 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) @@ -60,7 +60,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) DllImportEntry(GlobalizationNative_CompareStringNative) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index eac5026d72012..122024a1b3971 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, @@ -103,7 +103,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startMonth, int32_t* startDay); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 4b2f53cfc04f2..60e06b908f443 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, @@ -24,7 +24,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, #endif PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 35c9ea4bd3756..c167c44119c41 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); @@ -67,7 +67,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, int32_t options); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 956c630065057..3488dc9376933 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,11 +21,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -// #include -// #endif -#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) - +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 80923884bb9d3..e878af7b94352 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,7 +8,7 @@ // #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // #include // #endif -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); @@ -22,7 +22,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index ef022a6213d35..31de9200388e8 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); @@ -44,7 +44,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo int32_t* primaryGroupSize, int32_t* secondaryGroupSize); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index b4447f27c4603..af45cd9d3266f 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,14 +43,14 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 345ec9053ab54..fa11ee06f40dc 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); @@ -29,7 +29,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwDstLength); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index c4f5940bc222d..f4c6b441ef213 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,12 +20,12 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); #endif -#if defined(__APPLE__) && !defined(TARGET_OSX) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif From 6ecdeae98a12dbb7adb7735e3c120cf3d23ea7e2 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 10:03:47 +0100 Subject: [PATCH 034/105] Fix maccatalyst x64 failure --- src/native/libs/System.Globalization.Native/entrypoints.c | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.h | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 4 ++-- .../libs/System.Globalization.Native/pal_collation.h | 4 ++-- .../libs/System.Globalization.Native/pal_collation.m | 2 +- src/native/libs/System.Globalization.Native/pal_common.c | 2 +- .../libs/System.Globalization.Native/pal_errors_internal.h | 2 +- .../System.Globalization.Native/pal_icushim_internal.h | 7 ++++--- .../libs/System.Globalization.Native/pal_icushim_static.c | 4 ++-- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_locale.m | 4 ++-- .../System.Globalization.Native/pal_localeNumberData.h | 4 ++-- .../System.Globalization.Native/pal_localeStringData.h | 4 ++-- .../libs/System.Globalization.Native/pal_locale_internal.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 4 ++-- .../libs/System.Globalization.Native/pal_normalization.m | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 4 ++-- .../libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 20 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 3a7cfa2f2535f..facf3bc2ae98f 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) @@ -60,7 +60,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) DllImportEntry(GlobalizationNative_CompareStringNative) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 122024a1b3971..4cb6309d7d15b 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, @@ -103,7 +103,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startMonth, int32_t* startDay); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index f401a03e4afc0..5abaa8e542d22 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 60e06b908f443..8b0f26862ed47 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, @@ -24,7 +24,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, #endif PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index c167c44119c41..aca576fa748d7 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); @@ -67,7 +67,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, int32_t options); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 0c7872725af2a..ec7cb4bf7578f 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_common.c b/src/native/libs/System.Globalization.Native/pal_common.c index 6141b66699871..ddb50352cb497 100644 --- a/src/native/libs/System.Globalization.Native/pal_common.c +++ b/src/native/libs/System.Globalization.Native/pal_common.c @@ -1,7 +1,7 @@ #include #include "pal_icushim_internal.h" #include "pal_casing.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index 4ee385fd4c90a..679a337692ede 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,7 +5,7 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 3488dc9376933..05279aa48d138 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,7 +21,8 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) + +#if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT)) #include #include #include @@ -342,13 +343,13 @@ FOR_ALL_ICU_FUNCTIONS #define ucal_getWindowsTimeZoneID_ptr ucal_getWindowsTimeZoneID #define ucal_getTimeZoneIDForWindowsID_ptr ucal_getTimeZoneIDForWindowsID -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path); const char* GlobalizationNative_GetICUDataPathFallback(void); #endif #endif // !defined(STATIC_ICU) -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) /** * Append a code point to a string, overwriting 1 or 2 code units. * The offset points to the current end of the string contents diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index c0aacd4407659..9484981801182 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -11,7 +11,7 @@ #include #include -#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include #endif @@ -21,7 +21,7 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif -#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) static int32_t isLoaded = 0; static int32_t isDataSet = 0; diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 29818576d6900..ea23e3bab7734 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index e878af7b94352..6eb81acee2a84 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,7 +8,7 @@ // #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) // #include // #endif -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); @@ -22,7 +22,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index fce8f03a4fc70..997f62b40ccd1 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { @@ -756,7 +756,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) { @autoreleasepool diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 31de9200388e8..736712f9d23ad 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); @@ -44,7 +44,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo int32_t* primaryGroupSize, int32_t* secondaryGroupSize); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index af45cd9d3266f..e4a860eab545a 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,14 +43,14 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 7c80adc7d051d..5510416b393e9 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,7 +4,7 @@ #pragma once #include "pal_icushim_internal.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index fa11ee06f40dc..e0d2b04e938d7 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); @@ -29,7 +29,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwDstLength); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 62c3ecde53c9d..34cbe9ed320e4 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index f4c6b441ef213..f19d651e1d26e 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,12 +20,12 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 1cd51dc6704ff..28f923c0d6c63 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) /* Gets the localized display name that is currently in effect for the specified time zone. From 814cadc9bb4d5ed261a212bf1663da2d6c0d1029 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 11:47:31 +0100 Subject: [PATCH 035/105] Fix native crash when running tests on osx --- src/mono/mono/mini/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 7ee8621bdbc14..76133553a0730 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -64,6 +64,7 @@ if(HAVE_SYS_ICU) if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(icu_shim_sources_base + ${icu_shim_sources_base} pal_calendarData.c pal_casing.c pal_collation.c @@ -72,7 +73,6 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM pal_localeStringData.c pal_normalization.c pal_timeZoneInfo.c - ${icu_shim_sources_base} ) endif() diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 05320b1ad176d..16f121707de21 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -63,6 +63,7 @@ set(NATIVEGLOBALIZATION_SOURCES ) if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS) set(NATIVEGLOBALIZATION_SOURCES + ${NATIVEGLOBALIZATION_SOURCES} pal_calendarData.c pal_casing.c pal_collation.c @@ -70,7 +71,6 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM pal_localeNumberData.c pal_localeStringData.c pal_normalization.c - ${NATIVEGLOBALIZATION_SOURCES} ) endif() From 7702cf7f89f920114a5fa126962ffddbc9909f04 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 14:38:18 +0100 Subject: [PATCH 036/105] Fix maccatalyst failure --- src/native/libs/System.Globalization.Native/entrypoints.c | 3 ++- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- .../libs/System.Globalization.Native/pal_collation.h | 2 +- .../System.Globalization.Native/pal_icushim_internal.h | 3 ++- src/native/libs/System.Globalization.Native/pal_locale.h | 7 ++----- .../System.Globalization.Native/pal_localeNumberData.h | 2 +- .../System.Globalization.Native/pal_localeStringData.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- 10 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index facf3bc2ae98f..ed6ad0ee18720 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,8 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +// #if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 4cb6309d7d15b..7992569da9cd2 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 8b0f26862ed47..bf5526fdf8a81 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index aca576fa748d7..445d074389fe9 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 05279aa48d138..b245052d31c3b 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -22,7 +22,8 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT)) +// #if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 6eb81acee2a84..ae4b991302678 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -4,11 +4,8 @@ #pragma once #include "pal_compiler.h" -// #include "pal_icushim_internal.h" -// #if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -// #include -// #endif -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) + +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 736712f9d23ad..4369f641157b7 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index e4a860eab545a..b44a340f3fee3 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index e0d2b04e938d7..ad5b2c467cbbb 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index f19d651e1d26e..b6cbacbaf20c0 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(TARGET_OSX) && defined(__APPLE__) && !defined(TARGET_MACCAT)) +#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); From b0c1a511d2c2bef3f8ff2f1a792a71d01f696bca Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 16:29:07 +0100 Subject: [PATCH 037/105] Fix build on iOSLike platforms --- .../System.Globalization.Native/entrypoints.c | 12 ++--- .../pal_calendarData.h | 2 +- .../pal_calendarData.m | 2 +- .../System.Globalization.Native/pal_casing.h | 3 +- .../System.Globalization.Native/pal_casing.m | 2 +- .../pal_collation.h | 2 +- .../pal_collation.m | 2 +- .../pal_icushim_internal.h | 3 +- .../System.Globalization.Native/pal_idna.h | 2 +- .../System.Globalization.Native/pal_locale.h | 2 +- .../System.Globalization.Native/pal_locale.m | 48 +++++++++---------- .../pal_localeNumberData.h | 2 +- .../pal_localeStringData.h | 2 +- .../pal_normalization.h | 2 +- .../pal_normalization.m | 2 +- .../pal_timeZoneInfo.h | 2 +- .../pal_timeZoneInfo.m | 2 +- 17 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index ed6ad0ee18720..098fc60671e64 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,8 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -// #if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST)) -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) @@ -57,11 +56,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_NormalizeString) DllImportEntry(GlobalizationNative_StartsWith) DllImportEntry(GlobalizationNative_WindowsIdToIanaId) -#endif - DllImportEntry(GlobalizationNative_ToAscii) - DllImportEntry(GlobalizationNative_ToUnicode) - DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#else DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) DllImportEntry(GlobalizationNative_CompareStringNative) @@ -84,6 +79,9 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_StartsWithNative) DllImportEntry(GlobalizationNative_GetDefaultLocaleNameNative) #endif + DllImportEntry(GlobalizationNative_ToAscii) + DllImportEntry(GlobalizationNative_ToUnicode) + DllImportEntry(GlobalizationNative_InitOrdinalCasingPage) }; EXTERN_C const void* GlobalizationResolveDllImport(const char* name); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 7992569da9cd2..fb6ba99823c07 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -103,7 +103,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startMonth, int32_t* startDay); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 5abaa8e542d22..70df7f7419782 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index bf5526fdf8a81..684919ca0d8a4 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -24,7 +24,8 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, #endif PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +// #if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index 9ec193b071bc6..cbb406245f287 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) /** * Is this code unit a lead surrogate (U+d800..U+dbff)? diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 445d074389fe9..094dfdc8d4023 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -67,7 +67,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, int32_t options); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index ec7cb4bf7578f..e3b01ff7e191d 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index b245052d31c3b..d6fbe96f17190 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -22,8 +22,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -// #if !defined(__APPLE__) || (defined(TARGET_OSX) && !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST)) -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index ea23e3bab7734..7c797ce69a70b 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index ae4b991302678..5dfe9da8d37f8 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -19,7 +19,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 997f62b40ccd1..f0f86d39485e5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { @@ -754,29 +754,6 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } -#endif - -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) -{ - @autoreleasepool - { - NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; - NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; - - return strdup([dataPath UTF8String]); - } -} - -const char* GlobalizationNative_GetICUDataPathFallback(void) -{ - @autoreleasepool - { - NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; - return strdup([dataPath UTF8String]); - } -} - const char* GlobalizationNative_GetDefaultLocaleNameNative(void) { @autoreleasepool @@ -821,4 +798,27 @@ int32_t GlobalizationNative_IsPredefinedLocaleNative(const char* localeName) return false; } } + +#endif + +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) +{ + @autoreleasepool + { + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; + + return strdup([dataPath UTF8String]); + } +} + +const char* GlobalizationNative_GetICUDataPathFallback(void) +{ + @autoreleasepool + { + NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; + return strdup([dataPath UTF8String]); + } +} #endif diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 4369f641157b7..b5a66bccbd7c8 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -44,7 +44,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo int32_t* primaryGroupSize, int32_t* secondaryGroupSize); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index b44a340f3fee3..4e41032424130 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -50,7 +50,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeNam int32_t valueLength, const UChar* uiLocaleName); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index ad5b2c467cbbb..abe3459dd11b8 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -29,7 +29,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwDstLength); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 34cbe9ed320e4..4cd16010a2698 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index b6cbacbaf20c0..e930623079509 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -25,7 +25,7 @@ PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 28f923c0d6c63..31859ffbc9821 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) /* Gets the localized display name that is currently in effect for the specified time zone. From d9d1136ad46300366a461b1a41dfd1d4edd9dfe8 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 17:35:36 +0100 Subject: [PATCH 038/105] use TARGET_OS_MAC --- src/native/libs/System.Globalization.Native/entrypoints.c | 2 +- src/native/libs/System.Globalization.Native/pal_calendarData.h | 2 +- src/native/libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 2 +- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- .../libs/System.Globalization.Native/pal_localeNumberData.h | 2 +- .../libs/System.Globalization.Native/pal_localeStringData.h | 2 +- src/native/libs/System.Globalization.Native/pal_normalization.h | 2 +- src/native/libs/System.Globalization.Native/pal_normalization.m | 2 +- src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 098fc60671e64..75e733bce04d3 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index fb6ba99823c07..51581c56ee2ca 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -103,7 +103,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startMonth, int32_t* startDay); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 70df7f7419782..aeddef0cb2052 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 684919ca0d8a4..fc04df20a58b6 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -25,7 +25,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); // #if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 094dfdc8d4023..4fab46011ee48 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -67,7 +67,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, int32_t options); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index e3b01ff7e191d..621507d35b93b 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index d6fbe96f17190..e2349dbe4d71a 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -22,7 +22,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 7c797ce69a70b..70095eb62738a 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 5dfe9da8d37f8..5a1566a5f5a9d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -19,7 +19,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index f0f86d39485e5..f3b27bacd465d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index b5a66bccbd7c8..67ccc617e4853 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -44,7 +44,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo int32_t* primaryGroupSize, int32_t* secondaryGroupSize); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 4e41032424130..58ff3bec2d27b 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -50,7 +50,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeNam int32_t valueLength, const UChar* uiLocaleName); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index abe3459dd11b8..26cfdaf9b2f04 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -29,7 +29,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwDstLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 4cd16010a2698..72447b8ee271e 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index e930623079509..ab3ab4e9761dd 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -25,7 +25,7 @@ PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 31859ffbc9821..a32108e2c4ad1 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) /* Gets the localized display name that is currently in effect for the specified time zone. From fc9d47278424ef833d3b50d47d2fd02f6dff625a Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 7 Nov 2023 17:56:48 +0100 Subject: [PATCH 039/105] Fix osx build --- src/native/libs/System.Globalization.Native/entrypoints.c | 2 +- src/native/libs/System.Globalization.Native/pal_calendarData.h | 2 +- src/native/libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 2 +- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- .../libs/System.Globalization.Native/pal_localeNumberData.h | 2 +- .../libs/System.Globalization.Native/pal_localeStringData.h | 2 +- src/native/libs/System.Globalization.Native/pal_normalization.h | 2 +- src/native/libs/System.Globalization.Native/pal_normalization.m | 2 +- src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 75e733bce04d3..dcf1814dd8305 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 51581c56ee2ca..a25418f5d0b4e 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -103,7 +103,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startMonth, int32_t* startDay); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index aeddef0cb2052..14df59ffa040a 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index fc04df20a58b6..44e7cd3631fc6 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -25,7 +25,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); // #if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 4fab46011ee48..4478cad0a3b32 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -67,7 +67,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, int32_t options); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 621507d35b93b..288f2fcdaed51 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index e2349dbe4d71a..f577acf501512 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -22,7 +22,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 70095eb62738a..15151c096260b 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 5a1566a5f5a9d..5f22df161e4e1 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -19,7 +19,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int32_t valueLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index f3b27bacd465d..6585595a91095 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 67ccc617e4853..146df6b2e1067 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -44,7 +44,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo int32_t* primaryGroupSize, int32_t* secondaryGroupSize); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 58ff3bec2d27b..e9783bd5a4c94 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -50,7 +50,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeNam int32_t valueLength, const UChar* uiLocaleName); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 26cfdaf9b2f04..02175046f6981 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -29,7 +29,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwDstLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 72447b8ee271e..3cf38849a39f3 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index ab3ab4e9761dd..8d4d5d32d61cf 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -25,7 +25,7 @@ PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index a32108e2c4ad1..34e2c4880499c 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MAC)) +#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) /* Gets the localized display name that is currently in effect for the specified time zone. From 7e7bf744a101fd5b690a37e3ad1e6c3fd0329c7f Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 08:45:53 +0100 Subject: [PATCH 040/105] include TargetConditionals header --- src/native/libs/System.Globalization.Native/entrypoints.c | 4 +++- .../libs/System.Globalization.Native/pal_icushim_internal.h | 4 +++- src/native/libs/System.Globalization.Native/pal_locale.h | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index dcf1814dd8305..a5c7e3666a20e 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -16,7 +16,9 @@ typedef uint16_t UChar; #include "pal_idna.h" #include "pal_normalization.h" #include "pal_timeZoneInfo.h" - +#if defined(__APPLE__) +#include +#endif static const Entry s_globalizationNative[] = { #if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index f577acf501512..532650c805a62 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,7 +21,9 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. - +#if defined(__APPLE__) +#include +#endif #if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 5f22df161e4e1..a5ad26ba6f3a5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -4,6 +4,9 @@ #pragma once #include "pal_compiler.h" +#if defined(__APPLE__) +#include +#endif #if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); From d165171add88f1abe5581dbb0d146406ffbae5e4 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 09:15:49 +0100 Subject: [PATCH 041/105] check only using TARGET_OS_IPHONE --- .../libs/System.Globalization.Native/entrypoints.c | 2 +- .../System.Globalization.Native/pal_calendarData.h | 5 ++--- .../System.Globalization.Native/pal_calendarData.m | 2 +- .../libs/System.Globalization.Native/pal_casing.h | 11 +++++------ .../libs/System.Globalization.Native/pal_casing.m | 2 +- .../libs/System.Globalization.Native/pal_collation.h | 6 ++---- .../libs/System.Globalization.Native/pal_collation.m | 2 +- .../pal_icushim_internal.h | 2 +- .../libs/System.Globalization.Native/pal_idna.h | 2 +- .../libs/System.Globalization.Native/pal_locale.h | 6 ++---- .../libs/System.Globalization.Native/pal_locale.m | 2 +- .../pal_localeNumberData.h | 5 ++--- .../pal_localeStringData.h | 5 ++--- .../System.Globalization.Native/pal_normalization.h | 6 ++---- .../System.Globalization.Native/pal_normalization.m | 2 +- .../System.Globalization.Native/pal_timeZoneInfo.h | 5 ++--- .../System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 17 files changed, 28 insertions(+), 39 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index a5c7e3666a20e..1119efbc046b2 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -21,7 +21,7 @@ typedef uint16_t UChar; #endif static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index a25418f5d0b4e..d0b08e118e114 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, @@ -102,8 +102,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay); -#endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, CalendarId calendarId, CalendarDataType dataType); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 14df59ffa040a..0dacf313664df 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 44e7cd3631fc6..66e983de31c69 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -3,7 +3,10 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) + +PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); + +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, @@ -21,11 +24,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper); -#endif -PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); - -// #if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT int32_t GlobalizationNative_ChangeCaseNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpSrc, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index cbb406245f287..f44ec2cdf0b74 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_MACCATALYST)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) /** * Is this code unit a lead surrogate (U+d800..U+dbff)? diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 4478cad0a3b32..ad0a7c933d3e1 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); @@ -65,9 +65,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options); -#endif - -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT int32_t GlobalizationNative_CompareStringNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* lpTarget, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 288f2fcdaed51..dc6a50647d868 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 532650c805a62..0dc9ea5ef3cb4 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -24,7 +24,7 @@ #if defined(__APPLE__) #include #endif -#if !defined(__APPLE__) || (defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 15151c096260b..769205a817820 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index a5ad26ba6f3a5..4a90befeebb29 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,7 +8,7 @@ #include #endif -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); @@ -20,9 +20,7 @@ PALEXPORT int32_t GlobalizationNative_IsPredefinedLocale(const UChar* localeName PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength); -#endif - -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else #include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 6585595a91095..4cc87c9ac1eb4 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 146df6b2e1067..584b2b9cf3217 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); @@ -43,8 +43,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize); -#endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index e9783bd5a4c94..9866e46e99a74 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,14 +43,13 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName); -#endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 02175046f6981..52865549c1c38 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); @@ -27,9 +27,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength); -#endif - -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT int32_t GlobalizationNative_IsNormalizedNative(NormalizationForm normalizationForm, const uint16_t* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 3cf38849a39f3..8f921494b870e 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 8d4d5d32d61cf..27d7c39837964 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,12 +20,11 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); -#endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#else PALEXPORT int32_t GlobalizationNative_GetTimeZoneDisplayNameNative(const uint16_t* localeName, int32_t lNameLength, const uint16_t* timeZoneId, int32_t timeZoneIdLength, TimeZoneDisplayNameType type, uint16_t* result, int32_t resultLength); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 34e2c4880499c..8ceaec059badf 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(TARGET_OS_OSX) && !defined(TARGET_OS_IPHONE)) +#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) /* Gets the localized display name that is currently in effect for the specified time zone. From 7049e31e17e6c422132348ac554c5d17f804fee8 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 09:38:10 +0100 Subject: [PATCH 042/105] Fix osx build --- src/native/libs/System.Globalization.Native/entrypoints.c | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- .../libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_casing.m | 2 +- src/native/libs/System.Globalization.Native/pal_collation.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- .../libs/System.Globalization.Native/pal_localeNumberData.h | 2 +- .../libs/System.Globalization.Native/pal_localeStringData.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.m | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 17 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 1119efbc046b2..78f9ee468a015 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -16,12 +16,12 @@ typedef uint16_t UChar; #include "pal_idna.h" #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#if defined(__APPLE__) +#if __APPLE__ #include #endif static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index d0b08e118e114..8254d759a133c 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 0dacf313664df..6c82fb560c58b 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 66e983de31c69..f5b12f0aacec0 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,7 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index f44ec2cdf0b74..d9c400ad32099 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE /** * Is this code unit a lead surrogate (U+d800..U+dbff)? diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index ad0a7c933d3e1..6e6d53d4f0347 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index dc6a50647d868..50c4b2444e676 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 0dc9ea5ef3cb4..9e9859c54dfb4 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,10 +21,10 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if defined(__APPLE__) +#if __APPLE__ #include #endif -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 769205a817820..61d4ceb8535c2 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 4a90befeebb29..0a8141370f019 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,7 +8,7 @@ #include #endif -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 4cc87c9ac1eb4..6112925c5fd33 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 584b2b9cf3217..691ffd3ca3566 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 9866e46e99a74..6f66046b314f9 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 52865549c1c38..6b856cb904b75 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 8f921494b870e..758ff2470edde 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 27d7c39837964..325d1c42fdcdd 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 8ceaec059badf..e2fb86a43b348 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if defined(__APPLE__) && !(defined(__APPLE__) && !defined(TARGET_OS_IPHONE)) +#if TARGET_OS_IPHONE /* Gets the localized display name that is currently in effect for the specified time zone. From 6debeb5b7aad320d260b7a10955fa1b8ad7e7d2f Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 09:58:22 +0100 Subject: [PATCH 043/105] fix build failure --- src/native/libs/System.Globalization.Native/entrypoints.c | 4 ++-- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.h | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 2 +- .../libs/System.Globalization.Native/pal_localeNumberData.h | 2 +- .../libs/System.Globalization.Native/pal_localeStringData.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 78f9ee468a015..6b6c3c359c916 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -16,12 +16,12 @@ typedef uint16_t UChar; #include "pal_idna.h" #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#if __APPLE__ +#if defined(__APPLE__) #include #endif static const Entry s_globalizationNative[] = { -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 8254d759a133c..7d95e5544881e 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index f5b12f0aacec0..bc51b99e286f4 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,7 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 6e6d53d4f0347..9cc17fd9ec7f3 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 9e9859c54dfb4..08dd847d6fb7c 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,10 +21,10 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if __APPLE__ +#if defined(__APPLE__) #include #endif -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 61d4ceb8535c2..95b02f2940ce9 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if TARGET_OS_IPHONE +#if defined(__APPLE__) && TARGET_OS_IPHONE #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 0a8141370f019..a1151bcf1089f 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -8,7 +8,7 @@ #include #endif -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 691ffd3ca3566..2b08efb51001e 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 6f66046b314f9..8a5b530a789d3 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 6b856cb904b75..297d13e71234f 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 325d1c42fdcdd..4bb9ace3457d7 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !__APPLE__ || (__APPLE__ && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); From 68b8b886bb7d56ad0536b61693ce2f68252f02b0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 11:59:56 +0100 Subject: [PATCH 044/105] Fix osx build --- src/mono/CMakeLists.txt | 2 +- src/native/libs/System.Globalization.Native/entrypoints.c | 5 +---- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- .../libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_casing.m | 2 +- src/native/libs/System.Globalization.Native/pal_collation.h | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 3 ++- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 5 +---- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- .../libs/System.Globalization.Native/pal_localeNumberData.h | 2 +- .../libs/System.Globalization.Native/pal_localeStringData.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.m | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- 18 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 4f937c888cd32..27b7f0e55a53d 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -746,7 +746,7 @@ elseif(HOST_BROWSER) set(STATIC_ICU 1) set(ICU_LIBS "icucore") elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) - set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") + set(ICU_FLAGS "-DTARGET_UNIX -DTARGET_IOS -DTARGET_TVOS -DTARGET_MACCATALYST -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) elseif(HOST_ANDROID) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 6b6c3c359c916..08315097c38c5 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -16,12 +16,9 @@ typedef uint16_t UChar; #include "pal_idna.h" #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#if defined(__APPLE__) -#include -#endif static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 7d95e5544881e..486f047dc2c79 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,7 +78,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 6c82fb560c58b..feebc91e1a4fa 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /* Function: diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index bc51b99e286f4..cf006b4387faa 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,7 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index d9c400ad32099..d880256c76e52 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /** * Is this code unit a lead surrogate (U+d800..U+dbff)? diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 9cc17fd9ec7f3..e20ced7d2b436 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,7 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 50c4b2444e676..f0a8b192324d2 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // Enum that corresponds to C# CompareOptions typedef enum diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 08dd847d6fb7c..e24dafac97ac6 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -24,7 +24,8 @@ #if defined(__APPLE__) #include #endif -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +// #if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index 95b02f2940ce9..f4d23935318ac 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && TARGET_OS_IPHONE +#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index a1151bcf1089f..2ab7457dcbf8b 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -4,11 +4,8 @@ #pragma once #include "pal_compiler.h" -#if defined(__APPLE__) -#include -#endif -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 6112925c5fd33..3e01b10249c0a 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 2b08efb51001e..2fef6b294673c 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 8a5b530a789d3..6b3a49f08673b 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 297d13e71234f..44b937e35075c 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 758ff2470edde..ac3a2fd5cb521 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 4bb9ace3457d7..1bf1fe98f9936 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index e2fb86a43b348..f0ce04d8d9b1e 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_OS_IPHONE +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /* Gets the localized display name that is currently in effect for the specified time zone. From 7b640e0b698c4a48240d7d643f261610f2cd2af3 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 13:54:22 +0100 Subject: [PATCH 045/105] Fix browser build failure --- src/native/libs/System.Globalization.Native/CMakeLists.txt | 2 ++ src/native/libs/System.Globalization.Native/entrypoints.c | 3 ++- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- .../libs/System.Globalization.Native/pal_calendarData.m | 1 - src/native/libs/System.Globalization.Native/pal_casing.m | 1 - src/native/libs/System.Globalization.Native/pal_collation.h | 4 ++-- src/native/libs/System.Globalization.Native/pal_collation.m | 1 - src/native/libs/System.Globalization.Native/pal_common.c | 2 +- .../libs/System.Globalization.Native/pal_errors_internal.h | 2 +- .../libs/System.Globalization.Native/pal_icushim_internal.h | 4 ---- src/native/libs/System.Globalization.Native/pal_locale.m | 1 - .../libs/System.Globalization.Native/pal_locale_internal.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.m | 1 - 13 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 16f121707de21..5e9ccb1e8991b 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -76,6 +76,8 @@ endif() if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND DEFINED CMAKE_ICU_DIR) include_directories(${CMAKE_ICU_DIR}/include) + link_libraries(${CMAKE_ICU_DIR}/lib/libicuuc.a ${CMAKE_ICU_DIR}/lib/libicui18n.a ${CMAKE_ICU_DIR}/lib/libicudata.a) + link_libraries(stdc++) endif() if ((CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) AND NOT DEFINED CMAKE_ICU_DIR) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 08315097c38c5..31dcc306ce0fe 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -16,6 +16,7 @@ typedef uint16_t UChar; #include "pal_idna.h" #include "pal_normalization.h" #include "pal_timeZoneInfo.h" + static const Entry s_globalizationNative[] = { #if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) @@ -59,6 +60,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_ChangeCaseInvariantNative) DllImportEntry(GlobalizationNative_ChangeCaseNative) DllImportEntry(GlobalizationNative_CompareStringNative) + DllImportEntry(GlobalizationNative_GetDefaultLocaleNameNative) DllImportEntry(GlobalizationNative_EndsWithNative) DllImportEntry(GlobalizationNative_GetCalendarInfoNative) DllImportEntry(GlobalizationNative_GetCalendarsNative) @@ -76,7 +78,6 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_IsNormalizedNative) DllImportEntry(GlobalizationNative_NormalizeStringNative) DllImportEntry(GlobalizationNative_StartsWithNative) - DllImportEntry(GlobalizationNative_GetDefaultLocaleNameNative) #endif DllImportEntry(GlobalizationNative_ToAscii) DllImportEntry(GlobalizationNative_ToUnicode) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 486f047dc2c79..3abd02446b317 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -78,8 +78,8 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index feebc91e1a4fa..8cfa15000fc69 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -11,7 +11,6 @@ #endif #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - /* Function: GetCalendarIdentifier diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index d880256c76e52..d9c0e9fbc5737 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -13,7 +13,6 @@ #endif #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - /** * Is this code unit a lead surrogate (U+d800..U+dbff)? * @param c 16-bit code unit diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index e20ced7d2b436..4e7bc6d4245fe 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -12,6 +12,7 @@ typedef struct _Range { int32_t location; int32_t length; } Range; + #if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); @@ -97,6 +98,5 @@ PALEXPORT int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t cwSuffixLength, const uint16_t* lpSource, int32_t cwSourceLength, - int32_t options); - + int32_t options); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index f0a8b192324d2..1c1c9a24f06f6 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -12,7 +12,6 @@ #endif #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - // Enum that corresponds to C# CompareOptions typedef enum { diff --git a/src/native/libs/System.Globalization.Native/pal_common.c b/src/native/libs/System.Globalization.Native/pal_common.c index ddb50352cb497..6141b66699871 100644 --- a/src/native/libs/System.Globalization.Native/pal_common.c +++ b/src/native/libs/System.Globalization.Native/pal_common.c @@ -1,7 +1,7 @@ #include #include "pal_icushim_internal.h" #include "pal_casing.h" -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index 679a337692ede..4ee385fd4c90a 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,7 +5,7 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index e24dafac97ac6..9fecbad0f7747 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,10 +21,6 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if defined(__APPLE__) -#include -#endif -// #if !defined(__APPLE__) || (defined(__APPLE__) && !TARGET_OS_IPHONE) #if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 3e01b10249c0a..c018e965f0fec 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -37,7 +37,6 @@ } #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { @autoreleasepool diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 5510416b393e9..7c80adc7d051d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,7 +4,7 @@ #pragma once #include "pal_icushim_internal.h" -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index f0ce04d8d9b1e..017f982ebb2c9 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -12,7 +12,6 @@ #endif #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - /* Gets the localized display name that is currently in effect for the specified time zone. */ From 7330fdf65b5e583cebd0ac73d46dc9f7e0707eb9 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 8 Nov 2023 14:31:15 +0100 Subject: [PATCH 046/105] run iOS.DEVICE.Aot.Tests also on hybrid mode --- .../FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj b/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj index 802828ab2e14d..3ae358ae7c815 100644 --- a/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj +++ b/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj @@ -9,6 +9,7 @@ 42 true true + true true From 760de2aabef2590cbcafe751757b2f221315f2b6 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 9 Nov 2023 09:22:43 +0100 Subject: [PATCH 047/105] Fix native aot build --- .../pal_icushim_internal.h | 4 +- .../pal_icushim_static.c | 4 +- .../System.Globalization.Native/pal_locale.m | 40 +++++++++---------- src/tests/build.proj | 7 ++-- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 9fecbad0f7747..ab92bc3f5ba81 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -342,13 +342,13 @@ FOR_ALL_ICU_FUNCTIONS #define ucal_getWindowsTimeZoneID_ptr ucal_getWindowsTimeZoneID #define ucal_getTimeZoneIDForWindowsID_ptr ucal_getTimeZoneIDForWindowsID -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path); const char* GlobalizationNative_GetICUDataPathFallback(void); #endif #endif // !defined(STATIC_ICU) -#if defined(TARGET_MACCAT) || defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) /** * Append a code point to a string, overwriting 1 or 2 code units. * The offset points to the current end of the string contents diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index 9484981801182..c0aacd4407659 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -11,7 +11,7 @@ #include #include -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) #include #endif @@ -21,7 +21,7 @@ #define strcasecmp _stricmp #define strncasecmp _strnicmp #endif -#if !defined(TARGET_MACCAT) && !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#if !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) static int32_t isLoaded = 0; static int32_t isDataSet = 0; diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index c018e965f0fec..dc384ab39ffc8 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -48,6 +48,26 @@ } } +const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) +{ + @autoreleasepool + { + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; + + return strdup([dataPath UTF8String]); + } +} + +const char* GlobalizationNative_GetICUDataPathFallback(void) +{ + @autoreleasepool + { + NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; + return strdup([dataPath UTF8String]); + } +} + /** * Useful constant for the maximum size of the whole locale ID * (including the terminating NULL and all keywords). @@ -800,24 +820,4 @@ int32_t GlobalizationNative_IsPredefinedLocaleNative(const char* localeName) #endif -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) -{ - @autoreleasepool - { - NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; - NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; - - return strdup([dataPath UTF8String]); - } -} -const char* GlobalizationNative_GetICUDataPathFallback(void) -{ - @autoreleasepool - { - NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; - return strdup([dataPath UTF8String]); - } -} -#endif diff --git a/src/tests/build.proj b/src/tests/build.proj index 9622cdf945d21..490593d81af9f 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -309,7 +309,8 @@ - + + @(TestDlls->'%(Filename)') @@ -435,10 +436,10 @@ <_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" /> - + $(MicrosoftNetCoreAppRuntimePackDir)runtimes/$(TargetOS)-$(TargetArchitecture)/native/libicui18n.a" /> --> From 1cf723cf89d4b82da1294db63ebbcecbce63dab0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 9 Nov 2023 11:08:19 +0100 Subject: [PATCH 048/105] fix nativeaot build --- eng/testing/tests.ioslike.targets | 4 ++-- .../Templates/CMakeLists-librarymode.txt.template | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index 8f788e03b055e..aba83bddfb467 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -77,7 +77,7 @@ Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" /> - + diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template index 4ac9ad76006f1..edb0989f2bdf7 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template @@ -69,6 +69,7 @@ target_link_libraries( "-lz" "-lc++" "-liconv" + "-licucore" %NativeLibrariesToLink% %APP_LINK_LIBRARIES% ) From b381ef03807fb672de13a38a062fcab0527c3d08 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 9 Nov 2023 13:17:11 +0100 Subject: [PATCH 049/105] fix bowser build --- eng/testing/tests.ioslike.targets | 4 ++-- .../Templates/CMakeLists-librarymode.txt.template | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index aba83bddfb467..8f788e03b055e 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -77,7 +77,7 @@ Include="@(AppleAssembliesToBundle)" TargetDir="extraFiles\%(AppleAssembliesToBundle.RecursiveDir)" /> - + diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template index edb0989f2bdf7..4ac9ad76006f1 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template @@ -69,7 +69,6 @@ target_link_libraries( "-lz" "-lc++" "-liconv" - "-licucore" %NativeLibrariesToLink% %APP_LINK_LIBRARIES% ) From 2e29b1d502d3ebb2ffcc332f89fc73941808bd82 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 13 Nov 2023 14:05:36 +0100 Subject: [PATCH 050/105] Fix nativeaot build --- .../Microsoft.NETCore.Native.Unix.targets | 9 +++++---- src/mono/sample/iOS-NativeAOT/Makefile | 2 +- src/mono/sample/iOS-NativeAOT/Program.csproj | 1 + src/tasks/AppleAppBuilder/Templates/main-console.m | 3 +++ src/tasks/AppleAppBuilder/Templates/main-simple.m | 3 +++ src/tests/FunctionalTests/Directory.Build.props | 1 + 6 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index fe49cab873abf..95bdf656b6991 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -75,9 +75,9 @@ The .NET Foundation licenses this file to you under the MIT license. - - - + + + @@ -92,7 +92,8 @@ The .NET Foundation licenses this file to you under the MIT license. - + + diff --git a/src/mono/sample/iOS-NativeAOT/Makefile b/src/mono/sample/iOS-NativeAOT/Makefile index c50f01c05a913..0e203be2ddcb1 100644 --- a/src/mono/sample/iOS-NativeAOT/Makefile +++ b/src/mono/sample/iOS-NativeAOT/Makefile @@ -9,7 +9,7 @@ DEPLOY_AND_RUN?=false STRIP_DEBUG_SYMBOLS?=false USE_RUNTIME_PACKS?=false STATS?=false -HYBRID_GLOBALIZATION?=false +HYBRID_GLOBALIZATION?=true REPO_DIR=$(realpath $(TOP)) TASKS_DIR=$(REPO_DIR)/src/tasks diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index ceaa61bfcdc95..6017daf8565f1 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -4,6 +4,7 @@ bin $(MSBuildThisFileDirectory)/obj/ $(NetCoreAppCurrent) + true iossimulator true $(TargetOS)-$(TargetArchitecture) diff --git a/src/tasks/AppleAppBuilder/Templates/main-console.m b/src/tasks/AppleAppBuilder/Templates/main-console.m index 5bad15ff67de1..880881d71c79c 100644 --- a/src/tasks/AppleAppBuilder/Templates/main-console.m +++ b/src/tasks/AppleAppBuilder/Templates/main-console.m @@ -74,6 +74,9 @@ - (void)viewDidLoad { #else #if INVARIANT_GLOBALIZATION setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); +#endif +#if HYBRID_GLOBALIZATION + setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); #endif char **managed_argv; int managed_argc = get_managed_args (&managed_argv); diff --git a/src/tasks/AppleAppBuilder/Templates/main-simple.m b/src/tasks/AppleAppBuilder/Templates/main-simple.m index 36bf576d51397..50e6bb60d4734 100644 --- a/src/tasks/AppleAppBuilder/Templates/main-simple.m +++ b/src/tasks/AppleAppBuilder/Templates/main-simple.m @@ -56,6 +56,9 @@ - (void)viewDidLoad { #else #if INVARIANT_GLOBALIZATION setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); +#endif +#if HYBRID_GLOBALIZATION + setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); #endif char **managed_argv; int managed_argc = get_managed_args (&managed_argv); diff --git a/src/tests/FunctionalTests/Directory.Build.props b/src/tests/FunctionalTests/Directory.Build.props index d8316f8a0a1b2..5c74e90007145 100644 --- a/src/tests/FunctionalTests/Directory.Build.props +++ b/src/tests/FunctionalTests/Directory.Build.props @@ -38,6 +38,7 @@ false false true + true false false false From 1171ce0f9cc11cec0c0be44d82627ce1c701eff1 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 13 Nov 2023 15:17:20 +0100 Subject: [PATCH 051/105] add target definitions --- src/coreclr/nativeaot/CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index 65c69a5db901b..ceffe65886930 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -22,6 +22,16 @@ if(CLR_CMAKE_HOST_UNIX) add_definitions(-DFEATURE_OBJCMARSHAL) endif(CLR_CMAKE_TARGET_APPLE) + if(CLR_CMAKE_TARGET_MACCATALYST) + add_definitions(-DTARGET_MACCATALYST) + endif() + if(CLR_CMAKE_TARGET_IOS) + add_definitions(-DTARGET_IOS) + endif() + if(CLR_CMAKE_TARGET_TVOS) + add_definitions(-DTARGET_TVOS) + endif() + if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386) # Allow 16 byte compare-exchange add_compile_options(-mcx16) From b8c697ba190a3d2b559ef8ea5b2e039fbcb02619 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 14 Nov 2023 13:16:11 +0100 Subject: [PATCH 052/105] Fix native aot build --- src/native/libs/System.Globalization.Native/entrypoints.c | 2 +- .../libs/System.Globalization.Native/pal_calendarData.h | 2 +- .../libs/System.Globalization.Native/pal_calendarData.m | 2 +- src/native/libs/System.Globalization.Native/pal_casing.h | 2 +- src/native/libs/System.Globalization.Native/pal_casing.m | 2 +- .../libs/System.Globalization.Native/pal_collation.h | 2 +- .../libs/System.Globalization.Native/pal_collation.m | 2 +- .../System.Globalization.Native/pal_errors_internal.h | 2 +- .../System.Globalization.Native/pal_icushim_internal.h | 2 +- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.h | 2 +- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- .../System.Globalization.Native/pal_localeNumberData.h | 2 +- .../System.Globalization.Native/pal_localeStringData.h | 2 +- .../System.Globalization.Native/pal_locale_internal.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.h | 2 +- .../libs/System.Globalization.Native/pal_normalization.m | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.h | 2 +- .../libs/System.Globalization.Native/pal_timeZoneInfo.m | 2 +- src/native/libs/build-native.sh | 8 ++++---- 20 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 31dcc306ce0fe..0ec4e08e40b75 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 3abd02446b317..7398faccb46c3 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -79,7 +79,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 8cfa15000fc69..43efdf46ae768 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS /* Function: GetCalendarIdentifier diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index cf006b4387faa..9dd6b910e2ffe 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,7 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index d9c0e9fbc5737..44aab70de044e 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS /** * Is this code unit a lead surrogate (U+d800..U+dbff)? * @param c 16-bit code unit diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 4e7bc6d4245fe..6f64372420bc9 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -13,7 +13,7 @@ typedef struct _Range { int32_t length; } Range; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 1c1c9a24f06f6..cee8c42069ab5 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS // Enum that corresponds to C# CompareOptions typedef enum { diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index 4ee385fd4c90a..b1ee9cc36c183 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,7 +5,7 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(CLR_CMAKE_TARGET_IOS) || defined(CLR_CMAKE_TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index ab92bc3f5ba81..8ffe1e95e98eb 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,7 +21,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index f4d23935318ac..b99b438d8a2ef 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) +#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 2ab7457dcbf8b..c6e5556778ef5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -5,7 +5,7 @@ #include "pal_compiler.h" -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index dc384ab39ffc8..e39f7818e0537 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { @autoreleasepool diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 2fef6b294673c..60b26dd2f2577 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index 6b3a49f08673b..d606b96ec8328 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 7c80adc7d051d..1aacdc5706495 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,7 +4,7 @@ #pragma once #include "pal_icushim_internal.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(CLR_CMAKE_TARGET_IOS) || defined(CLR_CMAKE_TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index 44b937e35075c..f6cf1a013c8a0 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index ac3a2fd5cb521..406a607a6d851 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 1bf1fe98f9936..0ef6a0c64f88c 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 017f982ebb2c9..03eac0c21aa96 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS /* Gets the localized display name that is currently in effect for the specified time zone. */ diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 4d712eb0eed3a..1163e1e7c35eb 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -105,7 +105,7 @@ elif [[ "$__TargetOS" == linux-bionic && -z "$ROOTFS_DIR" ]]; then elif [[ "$__TargetOS" == iossimulator ]]; then # set default iOS simulator deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DTARGET_IOS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == x86 ]]; then @@ -119,7 +119,7 @@ elif [[ "$__TargetOS" == iossimulator ]]; then elif [[ "$__TargetOS" == ios ]]; then # set default iOS device deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DTARGET_IOS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm ]]; then @@ -131,7 +131,7 @@ elif [[ "$__TargetOS" == ios ]]; then elif [[ "$__TargetOS" == tvossimulator ]]; then # set default tvOS simulator deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DTARGET_TVOS=1 -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm64 ]]; then @@ -143,7 +143,7 @@ elif [[ "$__TargetOS" == tvossimulator ]]; then elif [[ "$__TargetOS" == tvos ]]; then # set default tvOS device deployment target # keep in sync with the root Directory.Build.props - __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DTARGET_TVOS=1 -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else From 37681f20be8d54b378b8a070b42a13b394a6e48e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 14 Nov 2023 15:24:43 +0100 Subject: [PATCH 053/105] set hybridglobalization for functional tests --- src/tests/FunctionalTests/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/FunctionalTests/Directory.Build.props b/src/tests/FunctionalTests/Directory.Build.props index 5c74e90007145..871509c70fbc3 100644 --- a/src/tests/FunctionalTests/Directory.Build.props +++ b/src/tests/FunctionalTests/Directory.Build.props @@ -5,6 +5,7 @@ true true true + true From e7111bd9d92d0213aceb4cf8a18ea4b39a04b0bd Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 14 Nov 2023 16:25:00 +0100 Subject: [PATCH 054/105] Try without checking hybrid mode --- .../src/System/Globalization/CompareInfo.Icu.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 7a4fb0289c464..3fd406faedfdf 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -24,7 +24,10 @@ private void IcuInitSortHandle(string interopCultureName) _isAsciiEqualityOrdinal = GetIsAsciiEqualityOrdinal(interopCultureName); if (!GlobalizationMode.Invariant) { -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + return; +#endif +#if TARGET_BROWSER if (GlobalizationMode.Hybrid) return; #endif From 8c5d9f085da7d3455f1f0d02197537506cfe6167 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 14 Nov 2023 16:50:18 +0100 Subject: [PATCH 055/105] change IcuInitSortHandle --- .../src/System/Globalization/CompareInfo.Icu.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 3fd406faedfdf..3952ea11aff64 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -24,14 +24,15 @@ private void IcuInitSortHandle(string interopCultureName) _isAsciiEqualityOrdinal = GetIsAsciiEqualityOrdinal(interopCultureName); if (!GlobalizationMode.Invariant) { -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - return; -#endif #if TARGET_BROWSER if (GlobalizationMode.Hybrid) return; #endif +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + return; +#else _sortHandle = SortHandleCache.GetCachedSortHandle(interopCultureName); +#endif } } From a6fe664c0810fd08b370921327f0c3d00e6cc519 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 07:04:04 +0100 Subject: [PATCH 056/105] Set hybrid without checking target --- .../src/System/Globalization/GlobalizationMode.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs index a81023eedccc2..60c2bec69dcd3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -13,9 +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 || TARGET_BROWSER internal static bool Hybrid { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Hybrid", "DOTNET_SYSTEM_GLOBALIZATION_HYBRID"); -#endif +// #endif internal static bool PredefinedCulturesOnly { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.PredefinedCulturesOnly", "DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY", GlobalizationMode.Invariant); } @@ -23,9 +23,9 @@ private static partial class Settings // This allows for the whole Settings nested class to be trimmed when Invariant=true, and allows for the Settings // static cctor (on Unix) to be preserved when Invariant=false. internal static bool Invariant => Settings.Invariant; -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER +// #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER internal static bool Hybrid => Settings.Hybrid; -#endif +// #endif internal static bool PredefinedCulturesOnly => Settings.PredefinedCulturesOnly; private static bool TryGetAppLocalIcuSwitchValue([NotNullWhen(true)] out string? value) => From d8658ce8b4a06be6eedaac8f162cb38d4e64424a Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 07:39:31 +0100 Subject: [PATCH 057/105] fix nativeaot build --- .../src/ILLink/ILLink.Substitutions.Shared.xml | 2 ++ .../FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj | 1 + 2 files changed, 3 insertions(+) diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml index 9765f3ab4f662..c5ac0e92903ca 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml @@ -10,10 +10,12 @@ to be trimmed when Invariant=true, and allows for the Settings static cctor (on Unix) to be preserved when Invariant=false. --> + + diff --git a/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj b/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj index 0e2f71fe06b3d..b9c00798452d6 100644 --- a/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj +++ b/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj @@ -9,6 +9,7 @@ false 42 true + true true true From 45428ef908ea3cc5ce76981e7cb2b6c90cb5c6ac Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 08:34:02 +0100 Subject: [PATCH 058/105] add hybrid only for osx in ILLink --- .../src/ILLink/ILLink.Substitutions.OSX.xml | 7 +++++++ .../src/ILLink/ILLink.Substitutions.Shared.xml | 4 ++-- .../src/System/Globalization/CompareInfo.Icu.cs | 8 ++------ .../src/System/Globalization/GlobalizationMode.cs | 8 ++++---- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml index 3b747687397c0..b8eb76c1730ca 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml @@ -3,5 +3,12 @@ + + + + + + + diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml index c5ac0e92903ca..e5b67355dd847 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml @@ -10,12 +10,12 @@ to be trimmed when Invariant=true, and allows for the Settings static cctor (on Unix) to be preserved when Invariant=false. --> - + - + diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 3952ea11aff64..45c10c33afbba 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -24,15 +24,11 @@ private void IcuInitSortHandle(string interopCultureName) _isAsciiEqualityOrdinal = GetIsAsciiEqualityOrdinal(interopCultureName); if (!GlobalizationMode.Invariant) { -#if TARGET_BROWSER - if (GlobalizationMode.Hybrid) +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER + if (GlobalizationMode.Hybrid) return; #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - return; -#else _sortHandle = SortHandleCache.GetCachedSortHandle(interopCultureName); -#endif } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs index 60c2bec69dcd3..a81023eedccc2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -13,9 +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 || TARGET_BROWSER internal static bool Hybrid { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.Hybrid", "DOTNET_SYSTEM_GLOBALIZATION_HYBRID"); -// #endif +#endif internal static bool PredefinedCulturesOnly { get; } = AppContextConfigHelper.GetBooleanConfig("System.Globalization.PredefinedCulturesOnly", "DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY", GlobalizationMode.Invariant); } @@ -23,9 +23,9 @@ private static partial class Settings // This allows for the whole Settings nested class to be trimmed when Invariant=true, and allows for the Settings // static cctor (on Unix) to be preserved when Invariant=false. internal static bool Invariant => Settings.Invariant; -// #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER internal static bool Hybrid => Settings.Hybrid; -// #endif +#endif internal static bool PredefinedCulturesOnly => Settings.PredefinedCulturesOnly; private static bool TryGetAppLocalIcuSwitchValue([NotNullWhen(true)] out string? value) => From cf153d9f5392fd73ebf77cb193e49e8f744c809b Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 09:33:17 +0100 Subject: [PATCH 059/105] Fix osx-x64 linker failure --- .../src/ILLink/ILLink.Substitutions.OSX.xml | 7 ------- .../src/ILLink/ILLink.Substitutions.iOS.xml | 10 ++++++++++ .../src/System.Private.CoreLib.Shared.projitems | 1 + 3 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.iOS.xml diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml index b8eb76c1730ca..3b747687397c0 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.OSX.xml @@ -3,12 +3,5 @@ - - - - - - - diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.iOS.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.iOS.xml new file mode 100644 index 0000000000000..c000dde2dca0b --- /dev/null +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.iOS.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems index 5e65109ddbb37..15d6d25e08ea3 100644 --- a/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems +++ b/src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems @@ -63,6 +63,7 @@ + From 90026f01c041dcf603ee81cbf382d696f5409cb5 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 11:35:31 +0100 Subject: [PATCH 060/105] Cleanup code --- src/coreclr/nativeaot/CMakeLists.txt | 10 ---------- .../src/ILLink/ILLink.Substitutions.Shared.xml | 2 -- .../src/System/Globalization/CompareInfo.Icu.cs | 2 +- .../libs/System.Globalization.Native/entrypoints.c | 2 +- .../System.Globalization.Native/pal_calendarData.h | 2 +- .../System.Globalization.Native/pal_calendarData.m | 2 +- .../libs/System.Globalization.Native/pal_casing.h | 2 +- .../libs/System.Globalization.Native/pal_casing.m | 2 +- .../libs/System.Globalization.Native/pal_collation.h | 2 +- .../libs/System.Globalization.Native/pal_collation.m | 2 +- .../System.Globalization.Native/pal_errors_internal.h | 2 +- .../System.Globalization.Native/pal_icushim_internal.h | 2 +- src/native/libs/System.Globalization.Native/pal_idna.h | 2 +- .../libs/System.Globalization.Native/pal_locale.h | 2 +- .../libs/System.Globalization.Native/pal_locale.m | 2 +- .../System.Globalization.Native/pal_localeNumberData.h | 2 +- .../System.Globalization.Native/pal_localeStringData.h | 2 +- .../System.Globalization.Native/pal_locale_internal.h | 2 +- .../System.Globalization.Native/pal_normalization.h | 2 +- .../System.Globalization.Native/pal_normalization.m | 2 +- .../System.Globalization.Native/pal_timeZoneInfo.h | 2 +- .../System.Globalization.Native/pal_timeZoneInfo.m | 2 +- src/native/libs/build-native.sh | 8 ++++---- .../iOS/Device/AOT/iOS.Device.Aot.Test.csproj | 1 - .../tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj | 1 - 25 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt index ceffe65886930..65c69a5db901b 100644 --- a/src/coreclr/nativeaot/CMakeLists.txt +++ b/src/coreclr/nativeaot/CMakeLists.txt @@ -22,16 +22,6 @@ if(CLR_CMAKE_HOST_UNIX) add_definitions(-DFEATURE_OBJCMARSHAL) endif(CLR_CMAKE_TARGET_APPLE) - if(CLR_CMAKE_TARGET_MACCATALYST) - add_definitions(-DTARGET_MACCATALYST) - endif() - if(CLR_CMAKE_TARGET_IOS) - add_definitions(-DTARGET_IOS) - endif() - if(CLR_CMAKE_TARGET_TVOS) - add_definitions(-DTARGET_TVOS) - endif() - if(CLR_CMAKE_TARGET_ARCH_AMD64 OR CLR_CMAKE_TARGET_ARCH_I386) # Allow 16 byte compare-exchange add_compile_options(-mcx16) diff --git a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml index e5b67355dd847..9765f3ab4f662 100644 --- a/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml +++ b/src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Substitutions.Shared.xml @@ -10,12 +10,10 @@ to be trimmed when Invariant=true, and allows for the Settings static cctor (on Unix) to be preserved when Invariant=false. --> - - diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs index 45c10c33afbba..7a4fb0289c464 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.Icu.cs @@ -25,7 +25,7 @@ private void IcuInitSortHandle(string interopCultureName) if (!GlobalizationMode.Invariant) { #if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || TARGET_BROWSER - if (GlobalizationMode.Hybrid) + if (GlobalizationMode.Hybrid) return; #endif _sortHandle = SortHandleCache.GetCachedSortHandle(interopCultureName); diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 0ec4e08e40b75..31dcc306ce0fe 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,7 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.h b/src/native/libs/System.Globalization.Native/pal_calendarData.h index 7398faccb46c3..3abd02446b317 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -79,7 +79,7 @@ typedef enum // the function pointer definition for the callback used in EnumCalendarInfo typedef void (PAL_CALLBACK_CALLTYPE *EnumCalendarInfoCallback)(const UChar*, const void*); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity); diff --git a/src/native/libs/System.Globalization.Native/pal_calendarData.m b/src/native/libs/System.Globalization.Native/pal_calendarData.m index 43efdf46ae768..8cfa15000fc69 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.m +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.m @@ -10,7 +10,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /* Function: GetCalendarIdentifier diff --git a/src/native/libs/System.Globalization.Native/pal_casing.h b/src/native/libs/System.Globalization.Native/pal_casing.h index 9dd6b910e2ffe..cf006b4387faa 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,7 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index 44aab70de044e..d9c0e9fbc5737 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -12,7 +12,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /** * Is this code unit a lead surrogate (U+d800..U+dbff)? * @param c 16-bit code unit diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 6f64372420bc9..4e7bc6d4245fe 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -13,7 +13,7 @@ typedef struct _Range { int32_t length; } Range; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT ResultCode GlobalizationNative_GetSortHandle(const char* lpLocaleName, SortHandle** ppSortHandle); PALEXPORT void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle); diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index cee8c42069ab5..1c1c9a24f06f6 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS // Enum that corresponds to C# CompareOptions typedef enum { diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index b1ee9cc36c183..4ee385fd4c90a 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,7 +5,7 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(CLR_CMAKE_TARGET_IOS) || defined(CLR_CMAKE_TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 8ffe1e95e98eb..ab92bc3f5ba81 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,7 +21,7 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index b99b438d8a2ef..f4d23935318ac 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,7 +7,7 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS) +#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) #include #include #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index c6e5556778ef5..2ab7457dcbf8b 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -5,7 +5,7 @@ #include "pal_compiler.h" -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocales(UChar *value, int32_t valueLength); PALEXPORT int32_t GlobalizationNative_GetLocaleName(const UChar* localeName, UChar* value, int32_t valueLength); diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index e39f7818e0537..dc384ab39ffc8 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -36,7 +36,7 @@ return strdup([localeName UTF8String]); } -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS const char* GlobalizationNative_GetLocaleNameNative(const char* localeName) { @autoreleasepool diff --git a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h index 60b26dd2f2577..2fef6b294673c 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,7 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); diff --git a/src/native/libs/System.Globalization.Native/pal_localeStringData.h b/src/native/libs/System.Globalization.Native/pal_localeStringData.h index d606b96ec8328..6b3a49f08673b 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,7 +43,7 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 1aacdc5706495..7c80adc7d051d 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,7 +4,7 @@ #pragma once #include "pal_icushim_internal.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) || defined(CLR_CMAKE_TARGET_IOS) || defined(CLR_CMAKE_TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) #include #endif /* diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.h b/src/native/libs/System.Globalization.Native/pal_normalization.h index f6cf1a013c8a0..44b937e35075c 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,7 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); diff --git a/src/native/libs/System.Globalization.Native/pal_normalization.m b/src/native/libs/System.Globalization.Native/pal_normalization.m index 406a607a6d851..ac3a2fd5cb521 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.m +++ b/src/native/libs/System.Globalization.Native/pal_normalization.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS static NSString* GetNormalizedStringForForm(NormalizationForm normalizationForm, NSString* sourceString) { switch (normalizationForm) diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 0ef6a0c64f88c..1bf1fe98f9936 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,7 +20,7 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS)) +#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_WindowsIdToIanaId(const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength); PALEXPORT int32_t GlobalizationNative_IanaIdToWindowsId(const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength); PALEXPORT ResultCode GlobalizationNative_GetTimeZoneDisplayName(const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength); diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m index 03eac0c21aa96..017f982ebb2c9 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.m @@ -11,7 +11,7 @@ #error This file relies on ARC for memory management, but ARC is not enabled. #endif -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS || CLR_CMAKE_TARGET_IOS || CLR_CMAKE_TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS /* Gets the localized display name that is currently in effect for the specified time zone. */ diff --git a/src/native/libs/build-native.sh b/src/native/libs/build-native.sh index 1163e1e7c35eb..4d712eb0eed3a 100755 --- a/src/native/libs/build-native.sh +++ b/src/native/libs/build-native.sh @@ -105,7 +105,7 @@ elif [[ "$__TargetOS" == linux-bionic && -z "$ROOTFS_DIR" ]]; then elif [[ "$__TargetOS" == iossimulator ]]; then # set default iOS simulator deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DTARGET_IOS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphonesimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == x86 ]]; then @@ -119,7 +119,7 @@ elif [[ "$__TargetOS" == iossimulator ]]; then elif [[ "$__TargetOS" == ios ]]; then # set default iOS device deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DTARGET_IOS=1 -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm ]]; then @@ -131,7 +131,7 @@ elif [[ "$__TargetOS" == ios ]]; then elif [[ "$__TargetOS" == tvossimulator ]]; then # set default tvOS simulator deployment target # keep in sync with SetOSTargetMinVersions in the root Directory.Build.props - __CMakeArgs="-DTARGET_TVOS=1 -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvsimulator -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == x64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"x86_64\" $__CMakeArgs" elif [[ "$__TargetArch" == arm64 ]]; then @@ -143,7 +143,7 @@ elif [[ "$__TargetOS" == tvossimulator ]]; then elif [[ "$__TargetOS" == tvos ]]; then # set default tvOS device deployment target # keep in sync with the root Directory.Build.props - __CMakeArgs="-DTARGET_TVOS=1 -DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" + __CMakeArgs="-DCMAKE_SYSTEM_NAME=tvOS -DCMAKE_OSX_SYSROOT=appletvos -DCMAKE_OSX_DEPLOYMENT_TARGET=11.0 $__CMakeArgs" if [[ "$__TargetArch" == arm64 ]]; then __CMakeArgs="-DCMAKE_OSX_ARCHITECTURES=\"arm64\" $__CMakeArgs" else diff --git a/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj b/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj index 3ae358ae7c815..802828ab2e14d 100644 --- a/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj +++ b/src/tests/FunctionalTests/iOS/Device/AOT/iOS.Device.Aot.Test.csproj @@ -9,7 +9,6 @@ 42 true true - true true diff --git a/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj b/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj index b9c00798452d6..0e2f71fe06b3d 100644 --- a/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj +++ b/src/tests/FunctionalTests/tvOS/Device/AOT/tvOS.Device.Aot.Test.csproj @@ -9,7 +9,6 @@ false 42 true - true true true From 696ff661f9f372d78cee987ab151828ed684b862 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 14:17:50 +0100 Subject: [PATCH 061/105] Clean up and fix runtime-extra-platform failure --- src/mono/mono.proj | 9 ---- src/mono/sample/iOS/Makefile | 2 +- .../System.Globalization.Native/pal_casing.m | 1 - .../pal_collation.m | 1 - .../pal_icushim_internal.h | 2 +- .../pal_icushim_static.c | 3 +- .../System.Globalization.Native/pal_locale.m | 42 +++++++++---------- src/native/libs/build-native.proj | 2 +- src/tasks/AppleAppBuilder/Templates/runtime.m | 7 +--- src/tests/build.proj | 5 --- 10 files changed, 27 insertions(+), 47 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 5999a6a729140..d549e8b7f8c2e 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -469,11 +469,6 @@ <_MonoCMakeVersionMin Condition="'$(TargetsiOS)' == 'true'">$(iOSVersionMin) <_MonoCMakeVersionMin Condition="'$(TargetstvOS)' == 'true'">$(tvOSVersionMin) - <_MonoCMakeArgs Include="-DCMAKE_SYSTEM_NAME=$(_MonoCMakeSystemName)"/> <_MonoCMakeArgs Include="-DCMAKE_OSX_DEPLOYMENT_TARGET=$(_MonoCMakeVersionMin)" /> @@ -489,10 +484,6 @@ <_MonoCMakeArgs Include="-DENABLE_ICALL_EXPORT=1"/> - diff --git a/src/mono/sample/iOS/Makefile b/src/mono/sample/iOS/Makefile index e3c8320dcd96e..a7579772a7977 100644 --- a/src/mono/sample/iOS/Makefile +++ b/src/mono/sample/iOS/Makefile @@ -6,7 +6,7 @@ TARGET?=iossimulator DEPLOY_AND_RUN?=true APP_SANDBOX?=false STRIP_DEBUG_SYMBOLS?=false # only used when measuring SOD via build-appbundle make target -HYBRID_GLOBALIZATION?=false +HYBRID_GLOBALIZATION?=true #If DIAGNOSTIC_PORTS is enabled, @(RuntimeComponents) must also include 'diagnostics_tracing'. #If @(RuntimeComponents) includes 'diagnostics_tracing', DIAGNOSTIC_PORTS is optional. diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index d9c0e9fbc5737..642cd831f109c 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -148,5 +148,4 @@ int32_t GlobalizationNative_ChangeCaseInvariantNative(const uint16_t* lpSrc, int return Success; } } - #endif diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 1c1c9a24f06f6..ad9a81f902769 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -293,5 +293,4 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l return result == NSOrderedSame ? 1 : 0; } } - #endif diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index ab92bc3f5ba81..ee1dd5e8db017 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -348,7 +348,7 @@ const char* GlobalizationNative_GetICUDataPathFallback(void); #endif #endif // !defined(STATIC_ICU) -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) +#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) /** * Append a code point to a string, overwriting 1 or 2 code units. * The offset points to the current end of the string contents diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_static.c b/src/native/libs/System.Globalization.Native/pal_icushim_static.c index c0aacd4407659..052fe9285726b 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_static.c +++ b/src/native/libs/System.Globalization.Native/pal_icushim_static.c @@ -250,4 +250,5 @@ int32_t GlobalizationNative_GetICUVersion(void) return (versionInfo[0] << 24) + (versionInfo[1] << 16) + (versionInfo[2] << 8) + versionInfo[3]; } -#endif // !defined(TARGET_MACCATALYST) && !defined(TARGET_IOS) && !defined(TARGET_TVOS) +#endif + diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index dc384ab39ffc8..8c5df3f7f0d5c 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -48,26 +48,6 @@ } } -const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) -{ - @autoreleasepool - { - NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; - NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; - - return strdup([dataPath UTF8String]); - } -} - -const char* GlobalizationNative_GetICUDataPathFallback(void) -{ - @autoreleasepool - { - NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; - return strdup([dataPath UTF8String]); - } -} - /** * Useful constant for the maximum size of the whole locale ID * (including the terminating NULL and all keywords). @@ -773,6 +753,26 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } +const char* GlobalizationNative_GetICUDataPathRelativeToAppBundleRoot(const char* path) +{ + @autoreleasepool + { + NSString *bundlePath = [[NSBundle mainBundle] bundlePath]; + NSString *dataPath = [bundlePath stringByAppendingPathComponent: [NSString stringWithFormat:@"%s", path]]; + + return strdup([dataPath UTF8String]); + } +} + +const char* GlobalizationNative_GetICUDataPathFallback(void) +{ + @autoreleasepool + { + NSString *dataPath = [[NSBundle mainBundle] pathForResource:@"icudt" ofType:@"dat"]; + return strdup([dataPath UTF8String]); + } +} + const char* GlobalizationNative_GetDefaultLocaleNameNative(void) { @autoreleasepool @@ -817,7 +817,5 @@ int32_t GlobalizationNative_IsPredefinedLocaleNative(const char* localeName) return false; } } - #endif - diff --git a/src/native/libs/build-native.proj b/src/native/libs/build-native.proj index ca92818606800..bbf272365a899 100644 --- a/src/native/libs/build-native.proj +++ b/src/native/libs/build-native.proj @@ -55,7 +55,7 @@ - <_IcuArtifacts Condition="'$(_IcuDir)' != ''" + <_IcuArtifacts Condition="'$(_IcuDir)' != '' and '$(TargetsAppleMobile)' != 'true'" Include="$(_IcuDir)/lib/libicuuc.a; $(_IcuDir)/lib/libicui18n.a; $(_IcuDir)/lib/libicudata.a; diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index bef72a61e0b0b..925e8175fc73d 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -290,13 +290,10 @@ static bool is_pinvoke_override_library (const char* libraryName) char icu_dat_path [1024]; int res; -#if defined(HYBRID_GLOBALIZATION) - //res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt_hybrid.dat"); - res = 1; -#else +#if !defined(HYBRID_GLOBALIZATION) res = snprintf (icu_dat_path, sizeof (icu_dat_path) - 1, "%s/%s", bundle, "icudt.dat"); -#endif assert (res > 0); +#endif // TODO: set TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS and NATIVE_DLL_SEARCH_DIRECTORIES const char *appctx_keys [] = { diff --git a/src/tests/build.proj b/src/tests/build.proj index 490593d81af9f..f543dbe85bd81 100644 --- a/src/tests/build.proj +++ b/src/tests/build.proj @@ -310,7 +310,6 @@ - @(TestDlls->'%(Filename)') @@ -436,10 +435,6 @@ <_LinkerFlagsToDrop Include="@(NativeFramework->'-framework %(Identity)')" /> - From 5354f28953b9ccf54cf0dda06ad8edfdcfc649ac Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 14:49:40 +0100 Subject: [PATCH 062/105] enable hybrid mode in nativeaot runtime tests --- src/tests/nativeaot/Directory.Build.props | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tests/nativeaot/Directory.Build.props b/src/tests/nativeaot/Directory.Build.props index 7c8005b8de473..fe607120cea7f 100644 --- a/src/tests/nativeaot/Directory.Build.props +++ b/src/tests/nativeaot/Directory.Build.props @@ -9,5 +9,8 @@ true + + true + From f446fcd723d3d687472025ce9c3cfbc410ef1afb Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 17:09:46 +0100 Subject: [PATCH 063/105] Fix nativeaot and iossimulator failure --- .../Templates/CMakeLists-librarymode.txt.template | 1 + src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template index 4ac9ad76006f1..edb0989f2bdf7 100644 --- a/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template +++ b/src/tasks/AppleAppBuilder/Templates/CMakeLists-librarymode.txt.template @@ -69,6 +69,7 @@ target_link_libraries( "-lz" "-lc++" "-liconv" + "-licucore" %NativeLibrariesToLink% %APP_LINK_LIBRARIES% ) diff --git a/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj b/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj index 5601b0480c7ff..6774087bab73b 100644 --- a/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj +++ b/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj @@ -3,6 +3,7 @@ Exe 0 true + true From bd736663f59ad2894268b3434244edde95f2ff1f Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 15 Nov 2023 23:25:20 +0100 Subject: [PATCH 064/105] include in LibraryBuilder template -licucore --- src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template | 1 + src/tests/nativeaot/Directory.Build.props | 3 --- src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj | 2 +- src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj | 2 +- src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj | 2 +- 5 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template b/src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template index defe196388114..51c00ad72a916 100644 --- a/src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template +++ b/src/tasks/LibraryBuilder/Templates/CMakeLists.txt.template @@ -46,6 +46,7 @@ elseif(TARGETS_APPLE_MOBILE) "-framework UIKit" "-lz" "-lc++" + "-licucore" "-liconv" ) add_definitions(-DHOST_APPLE_MOBILE=1) diff --git a/src/tests/nativeaot/Directory.Build.props b/src/tests/nativeaot/Directory.Build.props index fe607120cea7f..7c8005b8de473 100644 --- a/src/tests/nativeaot/Directory.Build.props +++ b/src/tests/nativeaot/Directory.Build.props @@ -9,8 +9,5 @@ true - - true - diff --git a/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj b/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj index 6774087bab73b..585b020a8d142 100644 --- a/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj +++ b/src/tests/nativeaot/SmokeTests/Determinism/Determinism.csproj @@ -3,7 +3,7 @@ Exe 0 true - true + true diff --git a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj index 04ec10484f88d..6d54fe45d4124 100644 --- a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj +++ b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj @@ -3,7 +3,7 @@ Exe 0 true - + true true $(NoWarn);IL3050 diff --git a/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj b/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj index d61a6236b1f07..c5285ab923844 100644 --- a/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj +++ b/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj @@ -3,7 +3,7 @@ Exe 0 true - + true true $(NoWarn);IL3050;IL3054 From 914a7aac04e89fa9a3cbdcf425123df4c49d0ed7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 16 Nov 2023 07:32:20 +0100 Subject: [PATCH 065/105] check if hybrid mode is set --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 95bdf656b6991..8b67ee660ac90 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -75,9 +75,9 @@ The .NET Foundation licenses this file to you under the MIT license. - + @@ -93,7 +93,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + From ba92af7bbdda2a1fe074cf3f01586636db658249 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 16 Nov 2023 15:18:26 +0100 Subject: [PATCH 066/105] include licucore when LibraryMode --- src/mono/msbuild/apple/build/AppleBuild.targets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index 6629acfa5bcf8..df0bf82e95bd5 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -73,6 +73,7 @@ <_CommonLinkerArgs Include="-lz" /> <_CommonLinkerArgs Include="-lc++" /> <_CommonLinkerArgs Include="-liconv" /> + <_CommonLinkerArgs Include="-licucore" /> <_CommonLinkerArgs Include="-framework Foundation" /> <_CommonLinkerArgs Include="-framework Security" /> <_CommonLinkerArgs Include="-framework UIKit" /> From eff8512b671d9b0a12fcda1a8e98ffccfc4ed7a3 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 20 Nov 2023 15:24:12 +0100 Subject: [PATCH 067/105] Fix nativeaot runtime tests build failure --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 6 +++--- .../NameObjectCollectionBase.KeysTests.cs | 4 ++-- src/tests/Directory.Build.props | 1 + src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj | 2 +- src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 8b67ee660ac90..95bdf656b6991 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -75,9 +75,9 @@ The .NET Foundation licenses this file to you under the MIT license. - + @@ -93,7 +93,7 @@ The .NET Foundation licenses this file to you under the MIT license. - + diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs index f1edcf9aad34a..301b181a69400 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs @@ -16,7 +16,7 @@ public void Keys_PreservesInstance(int count) Assert.Same(nameObjectCollection.Keys, nameObjectCollection.Keys); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [InlineData(0)] [InlineData(10)] public void Keys_GetEnumerator(int count) @@ -145,7 +145,7 @@ private static void Keys_CopyTo_Helper(MyNameObjectCollection nameObjectCollecti Assert.Equal(previousCount, keysArray.Length); } - [Theory] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [InlineData(0)] [InlineData(10)] public void Keys_CopyTo_Invalid(int count) diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 485ef96914b0a..55f5fbff427da 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,6 +223,7 @@ <_IsApplePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_IsiOSLikePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_SymbolPrefix Condition="'$(_IsApplePlatform)' == 'true'">_ + true diff --git a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj index 6d54fe45d4124..04ec10484f88d 100644 --- a/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj +++ b/src/tests/nativeaot/SmokeTests/Reflection/Reflection.csproj @@ -3,7 +3,7 @@ Exe 0 true - true + true $(NoWarn);IL3050 diff --git a/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj b/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj index c5285ab923844..d61a6236b1f07 100644 --- a/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj +++ b/src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj @@ -3,7 +3,7 @@ Exe 0 true - true + true $(NoWarn);IL3050;IL3054 From 5c53525342bc65dc986cec37c1c95cdd2f31d19c Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 21 Nov 2023 18:38:33 +0100 Subject: [PATCH 068/105] Implement GetSortKeyNative function --- .../src/Interop/Interop.Collation.iOS.cs | 4 + .../src/System/Globalization/CompareInfo.cs | 26 +++- .../System/Globalization/CompareInfo.iOS.cs | 138 ++++++++++++++++++ .../System.Globalization.Native/entrypoints.c | 1 + .../pal_collation.h | 8 + .../pal_collation.m | 35 +++++ 6 files changed, 207 insertions(+), 5 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Collation.iOS.cs b/src/libraries/Common/src/Interop/Interop.Collation.iOS.cs index 70e907efa68a1..b806dccee0bc8 100644 --- a/src/libraries/Common/src/Interop/Interop.Collation.iOS.cs +++ b/src/libraries/Common/src/Interop/Interop.Collation.iOS.cs @@ -29,5 +29,9 @@ internal static partial class Globalization [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWithNative", StringMarshalling = StringMarshalling.Utf16)] [MethodImpl(MethodImplOptions.NoInlining)] internal static unsafe partial int StartsWithNative(string localeName, int lNameLen, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options); + + [LibraryImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortKeyNative", StringMarshalling = StringMarshalling.Utf16)] + internal static unsafe partial int GetSortKeyNative(string localeName, int lNameLen, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options); + } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index 1d7a313d14add..bffcacd5f09d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -1450,7 +1450,11 @@ public SortKey GetSortKey(string source) private SortKey CreateSortKeyCore(string source, CompareOptions options) => GlobalizationMode.UseNls ? NlsCreateSortKey(source, options) : -#if TARGET_BROWSER || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + GlobalizationMode.Hybrid ? + CreateSortKeyNative(source, options) : +#endif +#if TARGET_BROWSER GlobalizationMode.Hybrid ? throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : #endif @@ -1493,7 +1497,11 @@ public int GetSortKey(ReadOnlySpan source, Span destination, Compare private int GetSortKeyCore(ReadOnlySpan source, Span destination, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetSortKey(source, destination, options) : -#if TARGET_BROWSER || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + GlobalizationMode.Hybrid ? + GetSortKeyNative(source, destination, options) : +#endif +#if TARGET_BROWSER GlobalizationMode.Hybrid ? throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : #endif @@ -1530,9 +1538,13 @@ public int GetSortKeyLength(ReadOnlySpan source, CompareOptions options = private int GetSortKeyLengthCore(ReadOnlySpan source, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetSortKeyLength(source, options) : -#if TARGET_BROWSER || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS GlobalizationMode.Hybrid ? - throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : + GetSortKeyLengthNative(source, options) : +#endif +#if TARGET_BROWSER + GlobalizationMode.Hybrid ? + throw new PlatformNotSupportedException(GetPNSEText("SortKey")) : #endif IcuGetSortKeyLength(source, options); @@ -1607,7 +1619,11 @@ public int GetHashCode(ReadOnlySpan source, CompareOptions options) private unsafe int GetHashCodeOfStringCore(ReadOnlySpan source, CompareOptions options) => GlobalizationMode.UseNls ? NlsGetHashCodeOfString(source, options) : -#if TARGET_BROWSER || TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS +#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS + GlobalizationMode.Hybrid ? + GetHashCodeOfStringNative(source, options) : +#endif +#if TARGET_BROWSER GlobalizationMode.Hybrid ? throw new PlatformNotSupportedException(GetPNSEText("HashCode")) : #endif diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs index 45ffb5ad31ec0..f90c540435e7e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs @@ -84,5 +84,143 @@ private static void AssertComparisonSupported(CompareOptions options) private static string GetPNSE(CompareOptions options) => SR.Format(SR.PlatformNotSupported_HybridGlobalizationWithCompareOptions, options); + + private unsafe SortKey CreateSortKeyNative(string source, CompareOptions options) + { + ArgumentNullException.ThrowIfNull(source); + + Debug.Assert(!GlobalizationMode.Invariant); + Debug.Assert(!GlobalizationMode.UseNls); + + if ((options & ValidCompareMaskOffFlags) != 0) + { + throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); + } + + byte[] keyData; + fixed (char* pSource = source) + { + int sortKeyLength = Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, null, 0, options); + keyData = new byte[sortKeyLength]; + + fixed (byte* pSortKey = keyData) + { + if (Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, pSortKey, sortKeyLength, options) != sortKeyLength) + { + throw new ArgumentException(SR.Arg_ExternalException); + } + } + } + + return new SortKey(this, source, options, keyData); + } + + private unsafe int GetSortKeyNative(ReadOnlySpan source, Span destination, CompareOptions options) + { + Debug.Assert(!GlobalizationMode.Invariant); + Debug.Assert(!GlobalizationMode.UseNls); + Debug.Assert((options & ValidCompareMaskOffFlags) == 0); + + // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. + + int actualSortKeyLength; + + fixed (char* pSource = &MemoryMarshal.GetReference(source)) + fixed (byte* pDest = &MemoryMarshal.GetReference(destination)) + { + actualSortKeyLength = Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, pDest, destination.Length, options); + } + + // The check below also handles errors due to negative values / overflow being returned. + + if ((uint)actualSortKeyLength > (uint)destination.Length) + { + if (actualSortKeyLength > destination.Length) + { + ThrowHelper.ThrowArgumentException_DestinationTooShort(); + } + else + { + throw new ArgumentException(SR.Arg_ExternalException); + } + } + + return actualSortKeyLength; + } + + private unsafe int GetSortKeyLengthNative(ReadOnlySpan source, CompareOptions options) + { + Debug.Assert(!GlobalizationMode.Invariant); + Debug.Assert(!GlobalizationMode.UseNls); + Debug.Assert((options & ValidCompareMaskOffFlags) == 0); + + // It's ok to pass nullptr (for empty buffers) to ICU's sort key routines. + + fixed (char* pSource = &MemoryMarshal.GetReference(source)) + { + return Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, null, 0, options); + } + } + + private unsafe int GetHashCodeOfStringNative(ReadOnlySpan source, CompareOptions options) + { + Debug.Assert(!GlobalizationMode.Invariant); + Debug.Assert(!GlobalizationMode.UseNls); + Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); + + // according to ICU User Guide the performance of ucol_getSortKey is worse when it is called with null output buffer + // the solution is to try to fill the sort key in a temporary buffer of size equal 4 x string length + // (The ArrayPool used to have a limit on the length of buffers it would cache; this code was avoiding + // exceeding that limit to avoid a per-operation allocation, and the performance implications here + // were not re-evaluated when the limit was lifted.) + int sortKeyLength = (source.Length > 1024 * 1024 / 4) ? 0 : 4 * source.Length; + + byte[]? borrowedArray = null; + Span sortKey = sortKeyLength <= 1024 + ? stackalloc byte[1024] + : (borrowedArray = ArrayPool.Shared.Rent(sortKeyLength)); + + fixed (char* pSource = &MemoryMarshal.GetNonNullPinnableReference(source)) + { + fixed (byte* pSortKey = &MemoryMarshal.GetReference(sortKey)) + { + System.Diagnostics.Debug.Write("Interop.Globalization.GetSortKeyNative before sortKeyLength is " + sortKeyLength + " for string length " + source.Length + " and sortKey.Length " + sortKey.Length + " and options " + options); + sortKeyLength = Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, pSortKey, sortKey.Length, options); + System.Diagnostics.Debug.Write("Interop.Globalization.GetSortKeyNative after sortKeyLength is " + sortKeyLength + " for string length " + source.Length + " and sortKey.Length " + sortKey.Length + " and options " + options); + + } + + if (sortKeyLength > sortKey.Length) // slow path for big strings + { + if (borrowedArray != null) + { + ArrayPool.Shared.Return(borrowedArray); + } + + sortKey = (borrowedArray = ArrayPool.Shared.Rent(sortKeyLength)); + + fixed (byte* pSortKey = &MemoryMarshal.GetReference(sortKey)) + { + sortKeyLength = Interop.Globalization.GetSortKeyNative(m_name, m_name.Length, pSource, source.Length, pSortKey, sortKey.Length, options); + System.Diagnostics.Debug.Write("Interop.Globalization.GetSortKeyNative sortKeyLength is " + sortKeyLength + " for string length " + source.Length); + } + } + } + + if (sortKeyLength == 0 || sortKeyLength > sortKey.Length) // internal error (0) or a bug (2nd call failed) in ucol_getSortKey + { + System.Diagnostics.Debug.Write("Interop.Globalization.GetSortKeyNative returned an invalid value."); + throw new ArgumentException(SR.Arg_ExternalException); + } + + int hash = Marvin.ComputeHash32(sortKey.Slice(0, sortKeyLength), Marvin.DefaultSeed); + + if (borrowedArray != null) + { + ArrayPool.Shared.Return(borrowedArray); + } + + return hash; + } } } diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index 31dcc306ce0fe..cb3b845b8861a 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -73,6 +73,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_GetLocaleNameNative) DllImportEntry(GlobalizationNative_GetLocalesNative) DllImportEntry(GlobalizationNative_GetLocaleTimeFormatNative) + DllImportEntry(GlobalizationNative_GetSortKeyNative) DllImportEntry(GlobalizationNative_GetTimeZoneDisplayNameNative) DllImportEntry(GlobalizationNative_IndexOfNative) DllImportEntry(GlobalizationNative_IsNormalizedNative) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.h b/src/native/libs/System.Globalization.Native/pal_collation.h index 4e7bc6d4245fe..1a3a7d68dd76d 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -99,4 +99,12 @@ PALEXPORT int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, const uint16_t* lpSource, int32_t cwSourceLength, int32_t options); + +PALEXPORT int32_t GlobalizationNative_GetSortKeyNative(const uint16_t* localeName, + int32_t lNameLength, + const UChar* lpStr, + int32_t cwStrLength, + uint8_t* sortKey, + int32_t cbSortKeyLength, + int32_t options); #endif diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index ad9a81f902769..2ab02b6ab3b01 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -293,4 +293,39 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l return result == NSOrderedSame ? 1 : 0; } } + +int32_t GlobalizationNative_GetSortKeyNative( + const uint16_t* localeName, + int32_t lNameLength, + const uint16_t* lpStr, + int32_t cwStrLength, + uint8_t* sortKey, + int32_t cbSortKeyLength, + int32_t options) +{ + @autoreleasepool { + NSLocale *locale = GetCurrentLocale(localeName, lNameLength); + //NSStringCompareOptions options = ConvertFromCompareOptionsToNSStringCompareOptions(comparisonOptions); + NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; + + // Performing string transformation using the specified locale + NSString *transformedString = [sourceString uppercaseStringWithLocale:locale]; + // Convert the NSString to UTF-8 encoded NSData + NSData *utf8Data = [transformedString dataUsingEncoding:NSUTF8StringEncoding]; + + // Get a pointer to the data bytes + const uint8_t *utf8Bytes = (const uint8_t *)[utf8Data bytes]; + + // Determine the length of the data in bytes + NSUInteger length = [utf8Data length]; + + // Create a uint8_t buffer to hold the UTF-8 bytes + sortKey = (uint8_t *)malloc(length * sizeof(uint8_t)); + + // Copy the bytes from utf8Bytes to buffer + memcpy(sortKey, utf8Bytes, length * sizeof(uint8_t)); + + return length; + } +} #endif From 6d5ecde64658a5410b6e11a6a9406c6691ccaef4 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 23 Nov 2023 10:45:18 +0100 Subject: [PATCH 069/105] Update SortKey implementation for hybrid mode --- .../tests/CaseInsensitiveComparerTests.cs | 2 +- .../CaseInsensitiveHashCodeProviderTests.cs | 15 +++-- .../src/System/Data/DataTable.cs | 2 +- .../pal_collation.m | 55 ++++++++++++------- 4 files changed, 45 insertions(+), 29 deletions(-) diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs index 7974d075166b4..ecc42d3e2da34 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs @@ -64,7 +64,7 @@ public void Ctor_CultureInfo_Compare(object a, object b, int expected) } } - [Fact] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)] public void Ctor_CultureInfo_Compare_TurkishI() { diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs index 64d65337f536a..cf3889a557708 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs @@ -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() { @@ -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")) diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 428393d70ea17..e055c0bf54186 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -78,7 +78,7 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ private CultureInfo _culture; private bool _cultureUserSet; private CompareInfo? _compareInfo; - private CompareOptions _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; + private CompareOptions _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth;//CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; private IFormatProvider? _formatProvider; private StringComparer? _hashCodeProvider; private bool _caseSensitive; diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 2ab02b6ab3b01..ae01a8c0a0c41 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -297,35 +297,48 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l int32_t GlobalizationNative_GetSortKeyNative( const uint16_t* localeName, int32_t lNameLength, - const uint16_t* lpStr, + const UChar* lpStr, int32_t cwStrLength, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) { @autoreleasepool { - NSLocale *locale = GetCurrentLocale(localeName, lNameLength); - //NSStringCompareOptions options = ConvertFromCompareOptionsToNSStringCompareOptions(comparisonOptions); NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; + NSString *sourceStringCleaned = RemoveWeightlessCharacters(sourceString); + + NSLocale *locale = GetCurrentLocale(localeName, lNameLength); + NSStringCompareOptions comparisonOptions = options == 0 ? 0 : ConvertFromCompareOptionsToNSStringCompareOptions(options); + + // Generate a sort key for the original string based on the locale + NSString *transformedString = [sourceStringCleaned stringByFoldingWithOptions:comparisonOptions locale:locale]; + + // Convert the string to UTF-8 representation + const char *utf8Bytes = [transformedString UTF8String]; + if (utf8Bytes != NULL) { + NSUInteger utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + //sortKey = (uint8_t *)malloc(utf8Length); + memcpy(sortKey, utf8Bytes, utf8Length); + return utf8Length; + } + else + { + // Convert the string to UTF-16 representation + NSData *utf16Data = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; + + if (utf16Data != nil) { + const uint16_t *utf16Bytes = (const uint16_t *)[utf16Data bytes]; + NSUInteger utf16Length = [utf16Data length] / sizeof(uint16_t); + + if (sortKey != NULL) { + // Convert UTF-16 to UTF-8 manually (in this example, using memcpy) + memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) + return utf16Length * 2; + } + } + } - // Performing string transformation using the specified locale - NSString *transformedString = [sourceString uppercaseStringWithLocale:locale]; - // Convert the NSString to UTF-8 encoded NSData - NSData *utf8Data = [transformedString dataUsingEncoding:NSUTF8StringEncoding]; - - // Get a pointer to the data bytes - const uint8_t *utf8Bytes = (const uint8_t *)[utf8Data bytes]; - - // Determine the length of the data in bytes - NSUInteger length = [utf8Data length]; - - // Create a uint8_t buffer to hold the UTF-8 bytes - sortKey = (uint8_t *)malloc(length * sizeof(uint8_t)); - - // Copy the bytes from utf8Bytes to buffer - memcpy(sortKey, utf8Bytes, length * sizeof(uint8_t)); - - return length; + return 0; } } #endif From 8e2dd91ab89b80829325822d33fa3447c74245a9 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 23 Nov 2023 17:25:33 +0100 Subject: [PATCH 070/105] Fix IgnoreKanaType related test failures --- src/libraries/Common/src/System/Data/Common/AdapterUtil.cs | 2 +- .../Microsoft/VisualBasic/CompilerServices/LikeOperator.vb | 3 +-- .../Microsoft/VisualBasic/CompilerServices/StringType.vb | 5 ++--- .../VisualBasic/CompilerServices/Utils.LateBinder.vb | 2 +- .../src/Microsoft/VisualBasic/Strings.vb | 2 +- .../System.Data.Common/src/System/Data/BaseCollection.cs | 2 +- .../System.Data.Common/src/System/Data/DataTable.cs | 2 +- .../System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs | 2 +- .../src/System/Xml/Xsl/Runtime/XsltFunctions.cs | 2 +- .../CompareInfo/CompareInfoTests.cs | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 6 ++++++ 11 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs b/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs index 3675641903c36..eaae70578bb7e 100644 --- a/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs @@ -25,7 +25,7 @@ internal static partial class ADP private static Task? _falseTask; internal static Task FalseTask => _falseTask ??= Task.FromResult(false); - internal const CompareOptions DefaultCompareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + internal const CompareOptions DefaultCompareOptions = CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; internal const int DefaultConnectionTimeout = DbConnectionStringDefaults.ConnectTimeout; static partial void TraceException(string trace, Exception e); diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb index a51a0ac612c9c..1e8f7b8ea6775 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb @@ -279,8 +279,7 @@ Namespace Microsoft.VisualBasic.CompilerServices Else Comparer = GetCultureInfo().CompareInfo Options = CompareOptions.IgnoreCase Or - CompareOptions.IgnoreWidth Or - CompareOptions.IgnoreKanaType + CompareOptions.IgnoreWidth Dim LocaleSpecificLigatureTable As Byte() = New Byte(LigatureExpansions.Length - 1) {} diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb index aef9196e73304..ec2ec7da3f165 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb @@ -418,8 +418,7 @@ Namespace Microsoft.VisualBasic.CompilerServices ci = GetCultureInfo().CompareInfo Options = CompareOptions.IgnoreCase Or _ CompareOptions.IgnoreWidth Or _ - CompareOptions.IgnoreNonSpace Or _ - CompareOptions.IgnoreKanaType + CompareOptions.IgnoreNonSpace Do While PatternIndex < PatternEndIndex p = Pattern.Chars(PatternIndex) @@ -658,7 +657,7 @@ Namespace Microsoft.VisualBasic.CompilerServices If CompareOption = CompareMethod.Binary Then Options = CompareOptions.Ordinal Else - Options = CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreNonSpace Or CompareOptions.IgnoreKanaType + Options = CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreNonSpace End If 'Count = Source.LastIndexOf(TruncatedPattern) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb index d2c97225bf881..afa6cf2b68b56 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb @@ -41,7 +41,7 @@ Namespace Microsoft.VisualBasic.CompilerServices Friend Const chGenericManglingChar As Char = "`"c - Friend Const OptionCompareTextFlags As CompareOptions = (CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreKanaType) + Friend Const OptionCompareTextFlags As CompareOptions = (CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth) Private Const ResourceMsgDefault As String = "Message text unavailable. Resource file 'Microsoft.VisualBasic resources' not found." Private Const VBDefaultErrorID As String = "ID95" diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb index 1357ed3395966..4aa37ba5c46c5 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb @@ -81,7 +81,7 @@ Namespace Global.Microsoft.VisualBasic Private Const CODEPAGE_SIMPLIFIED_CHINESE As Integer = 936 Private Const CODEPAGE_TRADITIONAL_CHINESE As Integer = 950 Private Const STANDARD_COMPARE_FLAGS As CompareOptions = - CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreKanaType + CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Private Const NAMEDFORMAT_FIXED As String = "fixed" Private Const NAMEDFORMAT_YES_NO As String = "yes/no" diff --git a/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs b/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs index 1b02adb894baf..25fbb5438f0ae 100644 --- a/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs @@ -42,7 +42,7 @@ internal static int NamesEqual(string? s1, string? s2, bool fCaseSensitive, Cult } // Case, kana and width -Insensitive compare - if (locale.CompareInfo.Compare(s1, s2, CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0) + if (locale.CompareInfo.Compare(s1, s2, CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth) == 0) { return string.Compare(s1, s2, false, locale) == 0 ? 1 : -1; } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index e055c0bf54186..5e797dc7daee4 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -1063,7 +1063,7 @@ internal bool SetCaseSensitiveValue(bool isCaseSensitive, bool userSet, bool res } else { - _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; + _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth; } if (resetIndexes) { diff --git a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs index 6f8526a62222d..7e1e148995198 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs @@ -895,7 +895,7 @@ internal static InvalidOperationException QuotePrefixNotSet(string method) internal const string SetProperties = nameof(SetProperties); internal const string UnquoteIdentifier = nameof(UnquoteIdentifier); - internal const CompareOptions compareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + internal const CompareOptions compareOptions = CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; internal const int DefaultCommandTimeout = 30; internal const int DefaultConnectionTimeout = DbConnectionStringDefaults.ConnectTimeout; diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs index 7d8613a4d7d3c..ffea54bd78250 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs @@ -394,7 +394,7 @@ public static double MSStringCompare(string s1, string s2, string lang, string o switch (options[idx]) { case 'i': - opts = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; + opts = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth; break; case 'u': upperFirst = true; diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index cbd011b96fa0c..8b84c416ba11f 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -352,7 +352,7 @@ public void SortKeyKanaTest(CompareInfo compareInfo, string string1, string stri SortKeyTest(compareInfo, string1, string2, options, expected); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))] public void SortKeyTestNotSupported() { try diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index ae01a8c0a0c41..f3e779f582700 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -304,6 +304,12 @@ int32_t GlobalizationNative_GetSortKeyNative( int32_t options) { @autoreleasepool { + if (cwStrLength == 0) + { + sortKey = malloc(1); + sortKey[0] = '\0'; + return 1; + } NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; NSString *sourceStringCleaned = RemoveWeightlessCharacters(sourceString); From 32d5db1d4ec3e1a9974de57a834da32a25bb4c15 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 24 Nov 2023 10:20:32 +0100 Subject: [PATCH 071/105] Do minor fixes and mark active issue --- .../System/Data/SqlTypes/SqlDecimalTest.cs | 1 + .../Data/SqlTypes/SqlStringSortingTest.cs | 5 ++-- .../System/Data/SqlTypes/SqlStringTest.cs | 11 +++++++++ .../DirectoryServices/DirectoryEntry.cs | 1 - .../System/Globalization/CompareInfo.iOS.cs | 2 +- .../src/System/StringComparer.cs | 2 +- .../System/Convert.ToDateTime.cs | 2 +- .../System/StringComparer.cs | 23 +++++++++++-------- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs index 7513730ee0416..1f8bdc8ba0253 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlDecimalTest.cs @@ -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); diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs index 0cae8f7a40409..41c4d4cfde1f2 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs @@ -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 @@ -60,7 +61,7 @@ public static void SqlStringValidComparisonTest(string cultureName, int localeId var culture = new CultureInfo(cultureName); - const SqlCompareOptions DefaultCompareOption = SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth; + const SqlCompareOptions DefaultCompareOption = SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreWidth; SqlStringDefaultCompareOptionTest(localeId); foreach (SqlCompareOptions option in new[] { SqlCompareOptions.None, SqlCompareOptions.BinarySort, SqlCompareOptions.BinarySort2, DefaultCompareOption }) @@ -95,7 +96,7 @@ private static void SqlStringDefaultCompareOptionTest(int localeID) // Some of Windows versions have a regression, so ignore last entry in the s_specialMatchingString if this is the case. if (PlatformDetection.IsWindows10Version1903OrGreater && - CultureInfo.InvariantCulture.CompareInfo.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) != 0) + CultureInfo.InvariantCulture.CompareInfo.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) != 0) { count--; } diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs index 56f8fa51b06ca..1b79fdbe0fdd7 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringTest.cs @@ -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"; @@ -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); @@ -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)); @@ -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 () @@ -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() @@ -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); @@ -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"); @@ -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(); @@ -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]); @@ -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..."); @@ -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 diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs index 0da317c9d72ab..355d0fdf07a80 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs @@ -888,7 +888,6 @@ public void MoveTo(DirectoryEntry newParent, string? newName) if (System.DirectoryServices.ActiveDirectory.Utils.Compare(childPath, 0, parentPath.Length, parentPath, 0, parentPath.Length) == 0) { uint compareFlags = System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNORENONSPACE | - System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNOREKANATYPE | System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNOREWIDTH | System.DirectoryServices.ActiveDirectory.Utils.SORT_STRINGSORT; // work around the ADSI case sensitive diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs index f90c540435e7e..29e868e2b4013 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CompareInfo.iOS.cs @@ -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) => diff --git a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs index 78ebf6c9c3c5d..8b57e78437768 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs @@ -215,7 +215,7 @@ public sealed class CultureAwareComparer : StringComparer, ISerializable internal static readonly CultureAwareComparer InvariantCaseSensitiveInstance = new CultureAwareComparer(CompareInfo.Invariant, CompareOptions.None); internal static readonly CultureAwareComparer InvariantIgnoreCaseInstance = new CultureAwareComparer(CompareInfo.Invariant, CompareOptions.IgnoreCase); - private const CompareOptions ValidCompareMaskOffFlags = ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth | CompareOptions.IgnoreKanaType | CompareOptions.StringSort); + private const CompareOptions ValidCompareMaskOffFlags = ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth | CompareOptions.StringSort); private readonly CompareInfo _compareInfo; // Do not rename (binary serialization) private readonly CompareOptions _options; diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs index 33609a72ceb1f..9ddd1dea1bddb 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs @@ -10,7 +10,7 @@ public class ConvertToDateTimeTests : ConvertTestBase { 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) }; diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs index cb38777716b81..b4ef785fa128f 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/StringComparer.cs @@ -179,16 +179,19 @@ public static IEnumerable CreateFromCultureAndOptionsData() yield return new object[] { "turky i", "TURKY \u0130", "tr-TR", CompareOptions.IgnoreCase, true}; } - yield return new object[] { "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; - yield return new object[] { "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false }; - yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + yield return new object[] { "abcd", "ab cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd", "ab+cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd", "ab%cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd", "ab&cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "a-bcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "abcd*", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + yield return new object[] { "ab$dd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, false }; + yield return new object[] { "abcd", "ab$cd", "en-US", CompareOptions.IgnoreSymbols, true }; + } } public static TheoryData CreateFromCultureAndOptionsStringSortData => new TheoryData From 1134b7ae541c38ba855008b1384dd9f1c9251b1e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 24 Nov 2023 11:13:24 +0100 Subject: [PATCH 072/105] Revert ValidCompareMaskOffFlags changes --- .../System.Private.CoreLib/src/System/StringComparer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs index 8b57e78437768..78ebf6c9c3c5d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs +++ b/src/libraries/System.Private.CoreLib/src/System/StringComparer.cs @@ -215,7 +215,7 @@ public sealed class CultureAwareComparer : StringComparer, ISerializable internal static readonly CultureAwareComparer InvariantCaseSensitiveInstance = new CultureAwareComparer(CompareInfo.Invariant, CompareOptions.None); internal static readonly CultureAwareComparer InvariantIgnoreCaseInstance = new CultureAwareComparer(CompareInfo.Invariant, CompareOptions.IgnoreCase); - private const CompareOptions ValidCompareMaskOffFlags = ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth | CompareOptions.StringSort); + private const CompareOptions ValidCompareMaskOffFlags = ~(CompareOptions.IgnoreCase | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreWidth | CompareOptions.IgnoreKanaType | CompareOptions.StringSort); private readonly CompareInfo _compareInfo; // Do not rename (binary serialization) private readonly CompareOptions _options; From 714ac500a84f2bdb5fc98bc5ce6c7f39ad357407 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 24 Nov 2023 12:08:49 +0100 Subject: [PATCH 073/105] Implement IgnoreKanaType for hybrid --- src/libraries/Common/src/System/Data/Common/AdapterUtil.cs | 2 +- .../Microsoft/VisualBasic/CompilerServices/LikeOperator.vb | 3 ++- .../Microsoft/VisualBasic/CompilerServices/StringType.vb | 5 +++-- .../VisualBasic/CompilerServices/Utils.LateBinder.vb | 2 +- .../src/Microsoft/VisualBasic/Strings.vb | 2 +- .../System.Data.Common/src/System/Data/BaseCollection.cs | 2 +- .../System.Data.Common/src/System/Data/DataTable.cs | 4 ++-- .../tests/System/Data/SqlTypes/SqlStringSortingTest.cs | 4 ++-- .../System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs | 2 +- .../src/System/DirectoryServices/DirectoryEntry.cs | 1 + .../src/System/Xml/Xsl/Runtime/XsltFunctions.cs | 2 +- src/native/libs/System.Globalization.Native/pal_collation.m | 6 +++++- 12 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs b/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs index eaae70578bb7e..3675641903c36 100644 --- a/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/Common/src/System/Data/Common/AdapterUtil.cs @@ -25,7 +25,7 @@ internal static partial class ADP private static Task? _falseTask; internal static Task FalseTask => _falseTask ??= Task.FromResult(false); - internal const CompareOptions DefaultCompareOptions = CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + internal const CompareOptions DefaultCompareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; internal const int DefaultConnectionTimeout = DbConnectionStringDefaults.ConnectTimeout; static partial void TraceException(string trace, Exception e); diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb index 1e8f7b8ea6775..a51a0ac612c9c 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/LikeOperator.vb @@ -279,7 +279,8 @@ Namespace Microsoft.VisualBasic.CompilerServices Else Comparer = GetCultureInfo().CompareInfo Options = CompareOptions.IgnoreCase Or - CompareOptions.IgnoreWidth + CompareOptions.IgnoreWidth Or + CompareOptions.IgnoreKanaType Dim LocaleSpecificLigatureTable As Byte() = New Byte(LigatureExpansions.Length - 1) {} diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb index ec2ec7da3f165..aef9196e73304 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/StringType.vb @@ -418,7 +418,8 @@ Namespace Microsoft.VisualBasic.CompilerServices ci = GetCultureInfo().CompareInfo Options = CompareOptions.IgnoreCase Or _ CompareOptions.IgnoreWidth Or _ - CompareOptions.IgnoreNonSpace + CompareOptions.IgnoreNonSpace Or _ + CompareOptions.IgnoreKanaType Do While PatternIndex < PatternEndIndex p = Pattern.Chars(PatternIndex) @@ -657,7 +658,7 @@ Namespace Microsoft.VisualBasic.CompilerServices If CompareOption = CompareMethod.Binary Then Options = CompareOptions.Ordinal Else - Options = CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreNonSpace + Options = CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreNonSpace Or CompareOptions.IgnoreKanaType End If 'Count = Source.LastIndexOf(TruncatedPattern) diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb index afa6cf2b68b56..d2c97225bf881 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/CompilerServices/Utils.LateBinder.vb @@ -41,7 +41,7 @@ Namespace Microsoft.VisualBasic.CompilerServices Friend Const chGenericManglingChar As Char = "`"c - Friend Const OptionCompareTextFlags As CompareOptions = (CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth) + Friend Const OptionCompareTextFlags As CompareOptions = (CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreKanaType) Private Const ResourceMsgDefault As String = "Message text unavailable. Resource file 'Microsoft.VisualBasic resources' not found." Private Const VBDefaultErrorID As String = "ID95" diff --git a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb index 4aa37ba5c46c5..1357ed3395966 100644 --- a/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb +++ b/src/libraries/Microsoft.VisualBasic.Core/src/Microsoft/VisualBasic/Strings.vb @@ -81,7 +81,7 @@ Namespace Global.Microsoft.VisualBasic Private Const CODEPAGE_SIMPLIFIED_CHINESE As Integer = 936 Private Const CODEPAGE_TRADITIONAL_CHINESE As Integer = 950 Private Const STANDARD_COMPARE_FLAGS As CompareOptions = - CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth + CompareOptions.IgnoreCase Or CompareOptions.IgnoreWidth Or CompareOptions.IgnoreKanaType Private Const NAMEDFORMAT_FIXED As String = "fixed" Private Const NAMEDFORMAT_YES_NO As String = "yes/no" diff --git a/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs b/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs index 25fbb5438f0ae..1b02adb894baf 100644 --- a/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs +++ b/src/libraries/System.Data.Common/src/System/Data/BaseCollection.cs @@ -42,7 +42,7 @@ internal static int NamesEqual(string? s1, string? s2, bool fCaseSensitive, Cult } // Case, kana and width -Insensitive compare - if (locale.CompareInfo.Compare(s1, s2, CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth) == 0) + if (locale.CompareInfo.Compare(s1, s2, CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth) == 0) { return string.Compare(s1, s2, false, locale) == 0 ? 1 : -1; } diff --git a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs index 5e797dc7daee4..428393d70ea17 100644 --- a/src/libraries/System.Data.Common/src/System/Data/DataTable.cs +++ b/src/libraries/System.Data.Common/src/System/Data/DataTable.cs @@ -78,7 +78,7 @@ public class DataTable : MarshalByValueComponent, IListSource, ISupportInitializ private CultureInfo _culture; private bool _cultureUserSet; private CompareInfo? _compareInfo; - private CompareOptions _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth;//CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; + private CompareOptions _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; private IFormatProvider? _formatProvider; private StringComparer? _hashCodeProvider; private bool _caseSensitive; @@ -1063,7 +1063,7 @@ internal bool SetCaseSensitiveValue(bool isCaseSensitive, bool userSet, bool res } else { - _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth; + _compareFlags = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; } if (resetIndexes) { diff --git a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs index 41c4d4cfde1f2..d6a17074d8d93 100644 --- a/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs +++ b/src/libraries/System.Data.Common/tests/System/Data/SqlTypes/SqlStringSortingTest.cs @@ -61,7 +61,7 @@ public static void SqlStringValidComparisonTest(string cultureName, int localeId var culture = new CultureInfo(cultureName); - const SqlCompareOptions DefaultCompareOption = SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreWidth; + const SqlCompareOptions DefaultCompareOption = SqlCompareOptions.IgnoreCase | SqlCompareOptions.IgnoreKanaType | SqlCompareOptions.IgnoreWidth; SqlStringDefaultCompareOptionTest(localeId); foreach (SqlCompareOptions option in new[] { SqlCompareOptions.None, SqlCompareOptions.BinarySort, SqlCompareOptions.BinarySort2, DefaultCompareOption }) @@ -96,7 +96,7 @@ private static void SqlStringDefaultCompareOptionTest(int localeID) // Some of Windows versions have a regression, so ignore last entry in the s_specialMatchingString if this is the case. if (PlatformDetection.IsWindows10Version1903OrGreater && - CultureInfo.InvariantCulture.CompareInfo.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) != 0) + CultureInfo.InvariantCulture.CompareInfo.Compare("\u3060", "\uFF80\uFF9E", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase) != 0) { count--; } diff --git a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs index 7e1e148995198..6f8526a62222d 100644 --- a/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs +++ b/src/libraries/System.Data.OleDb/src/System/Data/Common/AdapterUtil.cs @@ -895,7 +895,7 @@ internal static InvalidOperationException QuotePrefixNotSet(string method) internal const string SetProperties = nameof(SetProperties); internal const string UnquoteIdentifier = nameof(UnquoteIdentifier); - internal const CompareOptions compareOptions = CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + internal const CompareOptions compareOptions = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; internal const int DefaultCommandTimeout = 30; internal const int DefaultConnectionTimeout = DbConnectionStringDefaults.ConnectTimeout; diff --git a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs index 355d0fdf07a80..0da317c9d72ab 100644 --- a/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs +++ b/src/libraries/System.DirectoryServices/src/System/DirectoryServices/DirectoryEntry.cs @@ -888,6 +888,7 @@ public void MoveTo(DirectoryEntry newParent, string? newName) if (System.DirectoryServices.ActiveDirectory.Utils.Compare(childPath, 0, parentPath.Length, parentPath, 0, parentPath.Length) == 0) { uint compareFlags = System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNORENONSPACE | + System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNOREKANATYPE | System.DirectoryServices.ActiveDirectory.Utils.NORM_IGNOREWIDTH | System.DirectoryServices.ActiveDirectory.Utils.SORT_STRINGSORT; // work around the ADSI case sensitive diff --git a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs index ffea54bd78250..7d8613a4d7d3c 100644 --- a/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs +++ b/src/libraries/System.Private.Xml/src/System/Xml/Xsl/Runtime/XsltFunctions.cs @@ -394,7 +394,7 @@ public static double MSStringCompare(string s1, string s2, string lang, string o switch (options[idx]) { case 'i': - opts = CompareOptions.IgnoreCase | CompareOptions.IgnoreWidth; + opts = CompareOptions.IgnoreCase | CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth; break; case 'u': upperFirst = true; diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index f3e779f582700..e15fdc9eab0a9 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -18,6 +18,7 @@ None = 0, IgnoreCase = 1, IgnoreNonSpace = 2, + IgnoreKanaType = 8, IgnoreWidth = 16, StringSort = 536870912, } CompareOptions; @@ -46,7 +47,7 @@ static NSStringCompareOptions ConvertFromCompareOptionsToNSStringCompareOptions(int32_t comparisonOptions) { - int32_t supportedOptions = None | IgnoreCase | IgnoreNonSpace | IgnoreWidth | StringSort; + int32_t supportedOptions = None | IgnoreCase | IgnoreNonSpace | IgnoreWidth | StringSort | IgnoreKanaType; // To achieve an equivalent search behavior to the default in ICU, // NSLiteralSearch is employed as the default search option. NSStringCompareOptions options = NSLiteralSearch; @@ -63,6 +64,9 @@ static NSStringCompareOptions ConvertFromCompareOptionsToNSStringCompareOptions( if (comparisonOptions & IgnoreWidth) options |= NSWidthInsensitiveSearch; + if (comparisonOptions & IgnoreKanaType) + options |= NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch | NSWidthInsensitiveSearch; + return options; } From f16988cdc0ef3411e74eeda322009ef1bbe0cd3e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 24 Nov 2023 14:26:00 +0100 Subject: [PATCH 074/105] Fix System.Runtime.Tests --- .../Common/tests/Tests/System/StringTests.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 78fcd9e317f09..6db82b28f82dc 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1008,7 +1008,7 @@ public static void MakeSureNoCompareToChecksGoOutOfRange_StringComparison() } } - [Fact] + [Fact]//[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] public static void CompareToNoMatch_StringComparison() { for (int length = 1; length < 150; length++) @@ -1037,13 +1037,15 @@ public static void CompareToNoMatch_StringComparison() Assert.Equal( Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); - - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + } Assert.Equal( string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); From af8ba6ab06eb22da823f8ac762760d567a587da2 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 24 Nov 2023 17:35:10 +0100 Subject: [PATCH 075/105] Enable some tests --- .../Common/tests/Tests/System/StringTests.cs | 51 ++++++++++--------- .../NameObjectCollectionBase.KeysTests.cs | 4 +- .../AssemblyNameTests.cs | 2 +- .../System.Runtime.Tests/System/Attributes.cs | 2 +- .../System/StringComparerTests.cs | 4 +- .../System/StringGetHashCodeTests.cs | 7 ++- .../System/StringTests.cs | 34 ++++++------- 7 files changed, 55 insertions(+), 49 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 6db82b28f82dc..9379aba23bad2 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1008,7 +1008,7 @@ public static void MakeSureNoCompareToChecksGoOutOfRange_StringComparison() } } - [Fact]//[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public static void CompareToNoMatch_StringComparison() { for (int length = 1; length < 150; length++) @@ -1284,7 +1284,7 @@ public static void ContainsMatchDifferentSpans_StringComparison() Assert.True(span.Contains(slice, StringComparison.OrdinalIgnoreCase)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public static void ContainsNoMatch_StringComparison() { for (int length = 1; length < 150; length++) @@ -1311,18 +1311,21 @@ public static void ContainsNoMatch_StringComparison() Assert.False(firstSpan.Contains(secondSpan, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.Contains(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.Contains(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.Contains(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.Contains(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.Contains(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.Contains(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.Contains(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.Contains(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + } } } } @@ -1662,7 +1665,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.CurrentCulture, true }; yield return new object[] { "", "a", StringComparison.CurrentCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.CurrentCulture, true }; // CurrentCultureIgnoreCase @@ -1674,7 +1677,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.CurrentCultureIgnoreCase, true }; yield return new object[] { "", "a", StringComparison.CurrentCultureIgnoreCase, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.CurrentCultureIgnoreCase, true }; // InvariantCulture @@ -1687,7 +1690,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.InvariantCulture, true }; yield return new object[] { "", "a", StringComparison.InvariantCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.InvariantCulture, true }; // InvariantCultureIgnoreCase @@ -1699,7 +1702,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.InvariantCultureIgnoreCase, true }; yield return new object[] { "", "a", StringComparison.InvariantCultureIgnoreCase, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "llo" + SoftHyphen, StringComparison.InvariantCultureIgnoreCase, true }; // Ordinal @@ -1726,7 +1729,7 @@ public static IEnumerable EndsWith_StringComparison_TestData() yield return new object[] { "", "a", StringComparison.OrdinalIgnoreCase, false }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(EndsWith_StringComparison_TestData))] public static void EndsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { @@ -4851,7 +4854,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.CurrentCulture, true }; yield return new object[] { "", "hello", StringComparison.CurrentCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.CurrentCulture, true }; // CurrentCultureIgnoreCase @@ -4863,7 +4866,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.CurrentCultureIgnoreCase, true }; yield return new object[] { "", "hello", StringComparison.CurrentCultureIgnoreCase, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.CurrentCultureIgnoreCase, true }; // InvariantCulture @@ -4875,7 +4878,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.InvariantCulture, true }; yield return new object[] { "", "hello", StringComparison.InvariantCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.InvariantCulture, true }; // InvariantCultureIgnoreCase @@ -4887,7 +4890,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "", StringComparison.InvariantCultureIgnoreCase, true }; yield return new object[] { "", "hello", StringComparison.InvariantCultureIgnoreCase, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", SoftHyphen + "Hel", StringComparison.InvariantCultureIgnoreCase, true }; // Ordinal @@ -4921,7 +4924,7 @@ public static IEnumerable StartsWith_StringComparison_TestData() yield return new object[] { "", "hello", StringComparison.OrdinalIgnoreCase, false }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(StartsWith_StringComparison_TestData))] public static void StartsWith_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { diff --git a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs index 301b181a69400..f1edcf9aad34a 100644 --- a/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs +++ b/src/libraries/System.Collections.Specialized/tests/NameObjectCollectionBase/NameObjectCollectionBase.KeysTests.cs @@ -16,7 +16,7 @@ public void Keys_PreservesInstance(int count) Assert.Same(nameObjectCollection.Keys, nameObjectCollection.Keys); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_GetEnumerator(int count) @@ -145,7 +145,7 @@ private static void Keys_CopyTo_Helper(MyNameObjectCollection nameObjectCollecti Assert.Equal(previousCount, keysArray.Length); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [InlineData(0)] [InlineData(10)] public void Keys_CopyTo_Invalid(int count) diff --git a/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs b/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs index a2bf600407298..ebc563eacbfcd 100644 --- a/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs +++ b/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs @@ -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"); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Attributes.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Attributes.cs index 91eed81ecfdee..0b75b48ea133e 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Attributes.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Attributes.cs @@ -326,7 +326,7 @@ private static void GenericAttributesTestHelper(Func customAttributes = typeof(GetCustomAttribute).Module.CustomAttributes.ToList(); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs index 15b4d5f826435..3027c870855b5 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringComparerTests.cs @@ -16,7 +16,7 @@ public void Create_InvalidArguments_Throws() AssertExtensions.Throws("culture", () => StringComparer.Create(null, ignoreCase: true)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public void Create_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, ignoreCase: true); @@ -117,7 +117,7 @@ public void CreateCultureOptions_InvalidArguments_Throws() Assert.Throws(() => StringComparer.Create(null, CompareOptions.None)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public void CreateCultureOptions_CreatesValidComparer() { StringComparer c = StringComparer.Create(CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs index e42d0548ba5d9..59ceb5ceb67aa 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringGetHashCodeTests.cs @@ -61,7 +61,7 @@ public static IEnumerable GetHashCode_TestData() () => { return CultureInfo.CurrentCulture.CompareInfo.GetHashCode("abc", CompareOptions.OrdinalIgnoreCase); } }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(GetHashCodeOrdinalIgnoreCase_TestData))] public void GetHashCode_OrdinalIgnoreCase_ReturnsSameHashCodeAsUpperCaseOrdinal(string input) { @@ -89,7 +89,10 @@ public static IEnumerable GetHashCodeOrdinalIgnoreCase_TestData() { yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u00E9" /* LATIN SMALL LETTER E WITH ACUTE */) }; yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u044D" /* CYRILLIC SMALL LETTER E */) }; - yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u0131" /* LATIN SMALL LETTER DOTLESS I */) }; + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + yield return new object[] { "AaBbCcDdEeFfGgHh".Insert(i, "\u0131" /* LATIN SMALL LETTER DOTLESS I */) }; + } } // Various texts copied from Microsoft's non-U.S. home pages, for further localization tests diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs index 8c09798c0af8c..507c50dfda3ca 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/StringTests.cs @@ -232,7 +232,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "Hello", "", StringComparison.CurrentCulture, true }; yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.CurrentCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "ell" + SoftHyphen, StringComparison.CurrentCulture, true }; // CurrentCultureIgnoreCase @@ -245,7 +245,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "", "hello", StringComparison.CurrentCultureIgnoreCase, false }; yield return new object[] { "Hello", "", StringComparison.CurrentCultureIgnoreCase, true }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) { yield return new object[] { "Hello", "ell" + SoftHyphen, StringComparison.CurrentCultureIgnoreCase, true }; yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.CurrentCultureIgnoreCase, true }; @@ -262,7 +262,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "Hello", "", StringComparison.InvariantCulture, true }; yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.InvariantCulture, false }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "Hello", "ell" + SoftHyphen, StringComparison.InvariantCulture, true }; // InvariantCultureIgnoreCase @@ -275,7 +275,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "", "hello", StringComparison.InvariantCultureIgnoreCase, false }; yield return new object[] { "Hello", "", StringComparison.InvariantCultureIgnoreCase, true }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) { yield return new object[] { "Hello", "ell" + SoftHyphen, StringComparison.InvariantCultureIgnoreCase, true }; yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.InvariantCultureIgnoreCase, true }; @@ -306,7 +306,7 @@ public static IEnumerable Contains_String_StringComparison_TestData() yield return new object[] { "Hello", "Ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(Contains_String_StringComparison_TestData))] public static void Contains_String_StringComparison(string s, string value, StringComparison comparisonType, bool expected) { @@ -699,7 +699,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", "d", StringComparison.CurrentCulture, "adc" }; yield return new object[] { "abc", "b", null, StringComparison.CurrentCulture, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.CurrentCulture, "def" }; yield return new object[] { "abc", "abc", "def", StringComparison.CurrentCultureIgnoreCase, "def" }; @@ -709,7 +709,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", "d", StringComparison.CurrentCultureIgnoreCase, "adc" }; yield return new object[] { "abc", "b", null, StringComparison.CurrentCultureIgnoreCase, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.CurrentCultureIgnoreCase, "def" }; yield return new object[] { "abc", "abc", "def", StringComparison.Ordinal, "def" }; @@ -719,7 +719,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", "d", StringComparison.Ordinal, "adc" }; yield return new object[] { "abc", "b", null, StringComparison.Ordinal, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.Ordinal, "abc" }; yield return new object[] { "abc", "abc", "def", StringComparison.OrdinalIgnoreCase, "def" }; @@ -730,7 +730,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", null, StringComparison.OrdinalIgnoreCase, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.OrdinalIgnoreCase, "abc" }; yield return new object[] { "abc", "abc", "def", StringComparison.InvariantCulture, "def" }; @@ -741,7 +741,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", null, StringComparison.InvariantCulture, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.InvariantCulture, "def" }; yield return new object[] { "abc", "abc", "def", StringComparison.InvariantCultureIgnoreCase, "def" }; @@ -752,7 +752,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "abc", "b", null, StringComparison.InvariantCultureIgnoreCase, "ac" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) { yield return new object[] { "abc", "abc" + SoftHyphen, "def", StringComparison.InvariantCultureIgnoreCase, "def" }; @@ -775,7 +775,7 @@ public static IEnumerable Replace_StringComparison_TestData() yield return new object[] { "", "\0", "y", StringComparison.InvariantCulture, "" }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(Replace_StringComparison_TestData))] public void Replace_StringComparison_ReturnsExpected(string original, string oldValue, string newValue, StringComparison comparisonType, string expected) { @@ -821,7 +821,7 @@ public static IEnumerable Replace_StringComparisonCulture_TestData() yield return new object[] { "abc", "abc", "def", true, CultureInfo.InvariantCulture, "def" }; yield return new object[] { "abc", "ABC", "def", true, CultureInfo.InvariantCulture, "def" }; - if (PlatformDetection.IsNotInvariantGlobalization) + if (PlatformDetection.IsNotInvariantGlobalization && PlatformDetection.IsNotHybridGlobalizationOnOSX) { yield return new object[] { "abc", "abc" + SoftHyphen, "def", false, null, "def" }; yield return new object[] { "abc", "abc" + SoftHyphen, "def", true, null, "def" }; @@ -841,7 +841,7 @@ public static IEnumerable Replace_StringComparisonCulture_TestData() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(Replace_StringComparisonCulture_TestData))] public void Replace_StringComparisonCulture_ReturnsExpected(string original, string oldValue, string newValue, bool ignoreCase, CultureInfo culture, string expected) { @@ -906,7 +906,7 @@ public static void GetHashCode_OfSpan_MatchesOfString() Assert.NotEqual("abc".GetHashCode(), string.GetHashCode("ABC".AsSpan())); // case differences } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public static void GetHashCode_CompareInfo() { // ordinal @@ -926,7 +926,7 @@ public static void GetHashCode_CompareInfo() Assert.Equal("aeiXXabc".GetHashCode(StringComparison.InvariantCultureIgnoreCase), CultureInfo.InvariantCulture.CompareInfo.GetHashCode("aeiXXabc", CompareOptions.IgnoreCase)); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] public static void GetHashCode_CompareInfo_OfSpan() { // ordinal @@ -948,7 +948,7 @@ public static void GetHashCode_CompareInfo_OfSpan() public static IEnumerable GetHashCode_StringComparison_Data => StringComparisons.Select(value => new object[] { value }); - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] [MemberData(nameof(GetHashCode_StringComparison_Data))] public static void GetHashCode_StringComparison(StringComparison comparisonType) { From 52b8f355f4b6f0d4f885d3fb040212df333b32e9 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 27 Nov 2023 17:04:28 +0100 Subject: [PATCH 076/105] fix crash on System.Private.Xml.Tests --- src/native/libs/System.Globalization.Native/pal_collation.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index e15fdc9eab0a9..c464696a50b23 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -327,7 +327,7 @@ int32_t GlobalizationNative_GetSortKeyNative( const char *utf8Bytes = [transformedString UTF8String]; if (utf8Bytes != NULL) { NSUInteger utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - //sortKey = (uint8_t *)malloc(utf8Length); + sortKey = (uint8_t *)malloc(utf8Length); memcpy(sortKey, utf8Bytes, utf8Length); return utf8Length; } @@ -342,6 +342,7 @@ int32_t GlobalizationNative_GetSortKeyNative( if (sortKey != NULL) { // Convert UTF-16 to UTF-8 manually (in this example, using memcpy) + sortKey = (uint8_t *)malloc(utf16Length * 2); memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) return utf16Length * 2; } From 222d52841c903d3ce8dd7291c9711e0852dd3f01 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 27 Nov 2023 18:45:47 +0100 Subject: [PATCH 077/105] Fix failure --- src/native/libs/System.Globalization.Native/pal_collation.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index c464696a50b23..eac66aac9c4ad 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -327,7 +327,8 @@ int32_t GlobalizationNative_GetSortKeyNative( const char *utf8Bytes = [transformedString UTF8String]; if (utf8Bytes != NULL) { NSUInteger utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - sortKey = (uint8_t *)malloc(utf8Length); + if (sortKey == NULL) + sortKey = (uint8_t *)malloc(utf8Length); memcpy(sortKey, utf8Bytes, utf8Length); return utf8Length; } @@ -342,7 +343,7 @@ int32_t GlobalizationNative_GetSortKeyNative( if (sortKey != NULL) { // Convert UTF-16 to UTF-8 manually (in this example, using memcpy) - sortKey = (uint8_t *)malloc(utf16Length * 2); + //sortKey = (uint8_t *)malloc(utf16Length * 2); memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) return utf16Length * 2; } From 940042ba1a2cbc33e1cd4ad2d690879288e8bbdf Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 28 Nov 2023 07:04:03 +0100 Subject: [PATCH 078/105] Fix failure --- .../libs/System.Globalization.Native/pal_collation.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index eac66aac9c4ad..a4961aea569a3 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -310,7 +310,8 @@ int32_t GlobalizationNative_GetSortKeyNative( @autoreleasepool { if (cwStrLength == 0) { - sortKey = malloc(1); + if (sortKey == NULL) + sortKey = malloc(1); sortKey[0] = '\0'; return 1; } @@ -341,12 +342,12 @@ int32_t GlobalizationNative_GetSortKeyNative( const uint16_t *utf16Bytes = (const uint16_t *)[utf16Data bytes]; NSUInteger utf16Length = [utf16Data length] / sizeof(uint16_t); - if (sortKey != NULL) { + if (sortKey == NULL) + sortKey = (uint8_t *)malloc(utf16Length * 2); // Convert UTF-16 to UTF-8 manually (in this example, using memcpy) //sortKey = (uint8_t *)malloc(utf16Length * 2); - memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) - return utf16Length * 2; - } + memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) + return utf16Length * 2; } } From 9ecc945d1e4161192b32340c7dac2a976ea5423d Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 28 Nov 2023 09:48:47 +0100 Subject: [PATCH 079/105] Disable startswith test --- .../Common/tests/Tests/System/StringTests.cs | 93 ++++++++++--------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 9379aba23bad2..2244f87a090e8 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1032,26 +1032,26 @@ public static void CompareToNoMatch_StringComparison() var secondSpan = new ReadOnlySpan(second); Assert.True(0 > firstSpan.CompareTo(secondSpan, StringComparison.Ordinal)); - // Due to differences in the implementation, the exact result of CompareTo will not necessarily match with string.Compare. - // However, the sign will match, which is what defines correctness. - Assert.Equal( - Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), - Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); if (PlatformDetection.IsNotHybridGlobalizationOnOSX) { + // Due to differences in the implementation, the exact result of CompareTo will not necessarily match with string.Compare. + // However, the sign will match, which is what defines correctness. + Assert.Equal( + Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), + Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } } } @@ -7251,39 +7251,42 @@ public static void StartsWithNoMatch_StringComparison() Assert.False(s1.StartsWith(s2, StringComparison.OrdinalIgnoreCase)); - // Different behavior depending on OS - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCulture), - s1.StartsWith(s2, StringComparison.CurrentCulture)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), - s1.StartsWith(s2, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCulture), - s1.StartsWith(s2, StringComparison.InvariantCulture)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), - s1.StartsWith(s2, StringComparison.InvariantCultureIgnoreCase)); + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + // Different behavior depending on OS + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCulture), + s1.StartsWith(s2, StringComparison.CurrentCulture)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), + s1.StartsWith(s2, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCulture), + s1.StartsWith(s2, StringComparison.InvariantCulture)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), + s1.StartsWith(s2, StringComparison.InvariantCultureIgnoreCase)); - ReadOnlySpan firstSpan = s1.AsSpan(); - ReadOnlySpan secondSpan = s2.AsSpan(); - Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.Ordinal)); + ReadOnlySpan firstSpan = s1.AsSpan(); + ReadOnlySpan secondSpan = s2.AsSpan(); + Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.Ordinal)); - Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); + Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); - // Different behavior depending on OS - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.StartsWith(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.StartsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.StartsWith(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.StartsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + // Different behavior depending on OS + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.StartsWith(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.StartsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.StartsWith(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.StartsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + } } } } From 317bd6a0c09e179ac59583aa53172618be54bf9a Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 28 Nov 2023 12:12:45 +0100 Subject: [PATCH 080/105] Skip NoMatch_stringComparisonTests --- .../Common/tests/Tests/System/StringTests.cs | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 2244f87a090e8..bbb3fe85f8248 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -2136,18 +2136,21 @@ public static void EndsWithNoMatch_StringComparison() Assert.False(s1.EndsWith(s2, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCulture), - s1.EndsWith(s2, StringComparison.CurrentCulture)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), - s1.EndsWith(s2, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCulture), - s1.EndsWith(s2, StringComparison.InvariantCulture)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), - s1.EndsWith(s2, StringComparison.InvariantCultureIgnoreCase)); + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCulture), + s1.EndsWith(s2, StringComparison.CurrentCulture)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), + s1.EndsWith(s2, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCulture), + s1.EndsWith(s2, StringComparison.InvariantCulture)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), + s1.EndsWith(s2, StringComparison.InvariantCultureIgnoreCase)); + } var firstSpan = new ReadOnlySpan(first); var secondSpan = new ReadOnlySpan(second); @@ -2156,18 +2159,21 @@ public static void EndsWithNoMatch_StringComparison() Assert.False(firstSpan.EndsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.EndsWith(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.EndsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.EndsWith(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.EndsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.EndsWith(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.EndsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.EndsWith(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.EndsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); + } } } } From a18110c92867660b07be6008567f89b9ebb1ba8d Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 28 Nov 2023 12:19:00 +0100 Subject: [PATCH 081/105] enable hybrid mode on XmlFormatWriterGeneratorAot --- .../iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj b/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj index 6f72500c94912..eef8e057d43c8 100644 --- a/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj +++ b/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj @@ -11,6 +11,7 @@ false 42 true + true From caafa6b99e658df9d83415ef4307fca6a7691e0a Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 28 Nov 2023 17:37:11 +0100 Subject: [PATCH 082/105] check if utf16 convertion is needed --- .../pal_collation.m | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index a4961aea569a3..5d80059f4b31a 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -310,14 +310,14 @@ int32_t GlobalizationNative_GetSortKeyNative( @autoreleasepool { if (cwStrLength == 0) { - if (sortKey == NULL) + if (sortKey == NULL) sortKey = malloc(1); sortKey[0] = '\0'; return 1; } NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; NSString *sourceStringCleaned = RemoveWeightlessCharacters(sourceString); - + NSLocale *locale = GetCurrentLocale(localeName, lNameLength); NSStringCompareOptions comparisonOptions = options == 0 ? 0 : ConvertFromCompareOptionsToNSStringCompareOptions(options); @@ -326,30 +326,25 @@ int32_t GlobalizationNative_GetSortKeyNative( // Convert the string to UTF-8 representation const char *utf8Bytes = [transformedString UTF8String]; + NSData *dataToUse = nil; + NSUInteger utf8Length = 0; if (utf8Bytes != NULL) { - NSUInteger utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - if (sortKey == NULL) + utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; + } + // else { + // // Convert the string to UTF-16 representation + // dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; + // utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; + // } + + if (dataToUse != nil) { + const uint8_t *bytesToCopy = (const uint8_t *)[dataToUse bytes]; + if (sortKey == NULL) sortKey = (uint8_t *)malloc(utf8Length); - memcpy(sortKey, utf8Bytes, utf8Length); + memcpy(sortKey, bytesToCopy, utf8Length); return utf8Length; } - else - { - // Convert the string to UTF-16 representation - NSData *utf16Data = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; - - if (utf16Data != nil) { - const uint16_t *utf16Bytes = (const uint16_t *)[utf16Data bytes]; - NSUInteger utf16Length = [utf16Data length] / sizeof(uint16_t); - - if (sortKey == NULL) - sortKey = (uint8_t *)malloc(utf16Length * 2); - // Convert UTF-16 to UTF-8 manually (in this example, using memcpy) - //sortKey = (uint8_t *)malloc(utf16Length * 2); - memcpy(sortKey, utf16Bytes, utf16Length * 2); // Assuming UTF-16 (2 bytes per character) - return utf16Length * 2; - } - } return 0; } From 352c1c2c849a64e48f534747e77f349d92a66290 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 29 Nov 2023 12:39:50 +0100 Subject: [PATCH 083/105] Test GlobalizationNative_GetSortKeyNative --- .../pal_collation.m | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 5d80059f4b31a..5bc4081192c46 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -310,9 +310,11 @@ int32_t GlobalizationNative_GetSortKeyNative( @autoreleasepool { if (cwStrLength == 0) { - if (sortKey == NULL) - sortKey = malloc(1); - sortKey[0] = '\0'; + if (sortKey != NULL) + { + //sortKey = malloc(1); + sortKey[0] = '\0'; + } return 1; } NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; @@ -332,17 +334,19 @@ int32_t GlobalizationNative_GetSortKeyNative( utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; } - // else { - // // Convert the string to UTF-16 representation - // dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; - // utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; - // } + else { + // Convert the string to UTF-16 representation + dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; + utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; + } if (dataToUse != nil) { const uint8_t *bytesToCopy = (const uint8_t *)[dataToUse bytes]; - if (sortKey == NULL) - sortKey = (uint8_t *)malloc(utf8Length); - memcpy(sortKey, bytesToCopy, utf8Length); + if (sortKey != NULL) + { + //sortKey = (uint8_t *)malloc(utf8Length); + memcpy(sortKey, bytesToCopy, utf8Length); + } return utf8Length; } From d29f2b558cadb27e0b6dcb4685f337730946eb23 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 30 Nov 2023 11:21:45 +0100 Subject: [PATCH 084/105] Enable SortKey tests on hybrid mode --- .../CompareInfo/CompareInfoTests.cs | 197 +++++++++--------- .../pal_collation.m | 4 +- 2 files changed, 103 insertions(+), 98 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index 8b84c416ba11f..51da4f84683db 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -114,72 +114,75 @@ public static IEnumerable SortKey_Kana_TestData() public static IEnumerable SortKey_TestData() { - CompareOptions ignoreKanaIgnoreWidthIgnoreCase = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; - yield return new object[] { s_invariantCompare, "\u3042", "\u30A2", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u3042", "\uFF71", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - - yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u30E3", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u3083", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u304D \u3083", "\u30AD\u3083", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3044", "I", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - - yield return new object[] { s_invariantCompare, "a", "A", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "a", "\uFF41", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23\uFF24\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "ABCDE", "a\uFF22\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "ABCDE", "\uFF41\uFF42\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - - yield return new object[] { s_invariantCompare, "\u6FA4", "\u6CA2", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - - yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u30D6\u30D9\u30DC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u3076\u30D9\u30DC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3079\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3071\u3074\u30D7\u307A", "\uFF8B\uFF9F\uFF8C\uFF9F", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C\u3079\u307C", "\u3079\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - - yield return new object[] { s_invariantCompare, "ABDDE", "D", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "ABCDE", "\uFF43D", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "ABCDE", "c", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u3060", "\u305F", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u30BF", "\uFF80", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - - yield return new object[] { s_invariantCompare, "\u68EE\u9D0E\u5916", "\u68EE\u9DD7\u5916", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u68EE\u9DD7\u5916", "\u68EE\u9DD7\u5916", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u2019\u2019\u2019\u2019", "''''", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u2019", "'", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "", "'", ignoreKanaIgnoreWidthIgnoreCase, -1 }; - yield return new object[] { s_invariantCompare, "\u4E00", "\uFF11", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u2160", "\uFF11", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - - yield return new object[] { s_invariantCompare, "0", "\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "10", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "9999\uFF1910", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "9999\uFF191010", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - - yield return new object[] { s_invariantCompare, "'\u3000'", "' '", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\uFF1B", ";", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\uFF08", "(", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\uFF70", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\uFF0D", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\u30FC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\u2015", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\u2010", ignoreKanaIgnoreWidthIgnoreCase, 1 }; - - yield return new object[] { s_invariantCompare, "/", "\uFF0F", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "\"", "\uFF02", ignoreKanaIgnoreWidthIgnoreCase, 0 }; - - if (!PlatformDetection.IsWindows7) + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) { - // For the below string, LCMapStringEx and CompareStringEx on Windows 7 return inconsistent results. - // We'll only run this test case on Win8+ or on non-Windows machines. - yield return new object[] { s_invariantCompare, "'", "\uFF07", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + CompareOptions ignoreKanaIgnoreWidthIgnoreCase = CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; + yield return new object[] { s_invariantCompare, "\u3042", "\u30A2", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u3042", "\uFF71", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + + yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u30E3", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u3083", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u304D \u3083", "\u30AD\u3083", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3044", "I", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + + yield return new object[] { s_invariantCompare, "a", "A", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "a", "\uFF41", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23\uFF24\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "ABCDE", "a\uFF22\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "ABCDE", "\uFF41\uFF42\uFF23D\uFF25", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + + yield return new object[] { s_invariantCompare, "\u6FA4", "\u6CA2", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + + yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u30D6\u30D9\u30DC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u3076\u30D9\u30DC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3079\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3071\u3074\u30D7\u307A", "\uFF8B\uFF9F\uFF8C\uFF9F", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C\u3079\u307C", "\u3079\uFF8E\uFF9E", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3070\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + + yield return new object[] { s_invariantCompare, "ABDDE", "D", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "ABCDE", "\uFF43D", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "ABCDE", "c", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u3060", "\u305F", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u30BF", "\uFF80", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + + yield return new object[] { s_invariantCompare, "\u68EE\u9D0E\u5916", "\u68EE\u9DD7\u5916", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u68EE\u9DD7\u5916", "\u68EE\u9DD7\u5916", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u2019\u2019\u2019\u2019", "''''", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u2019", "'", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "", "'", ignoreKanaIgnoreWidthIgnoreCase, -1 }; + yield return new object[] { s_invariantCompare, "\u4E00", "\uFF11", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u2160", "\uFF11", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + + yield return new object[] { s_invariantCompare, "0", "\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "10", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "9999\uFF1910", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "9999\uFF191010", "1\uFF10", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + + yield return new object[] { s_invariantCompare, "'\u3000'", "' '", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\uFF1B", ";", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\uFF08", "(", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\uFF70", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\uFF0D", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\u30FC", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\u2015", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\u2010", ignoreKanaIgnoreWidthIgnoreCase, 1 }; + + yield return new object[] { s_invariantCompare, "/", "\uFF0F", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + yield return new object[] { s_invariantCompare, "\"", "\uFF02", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + + if (!PlatformDetection.IsWindows7) + { + // For the below string, LCMapStringEx and CompareStringEx on Windows 7 return inconsistent results. + // We'll only run this test case on Win8+ or on non-Windows machines. + yield return new object[] { s_invariantCompare, "'", "\uFF07", ignoreKanaIgnoreWidthIgnoreCase, 0 }; + } } yield return new object[] { s_invariantCompare, "\u3042", "\u30A1", CompareOptions.None, s_expectedHiraganaToKatakanaCompare }; @@ -190,12 +193,12 @@ public static IEnumerable SortKey_TestData() yield return new object[] { s_invariantCompare, "\u304D \u3083", "\u30AD\u3083", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3044", "I", CompareOptions.None, 1 }; - yield return new object[] { s_invariantCompare, "a", "A", CompareOptions.None, -1 }; + yield return new object[] { s_invariantCompare, "a", "A", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? 1 : -1 }; yield return new object[] { s_invariantCompare, "a", "\uFF41", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23\uFF24\uFF25", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "ABCDE", "\uFF21\uFF22\uFF23D\uFF25", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, new string('a', 5555), new string('a', 5554) + "b", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "ABCDE", "\uFF41\uFF42\uFF23D\uFF25", CompareOptions.None, 1 }; + yield return new object[] { s_invariantCompare, "ABCDE", "\uFF41\uFF42\uFF23D\uFF25", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; yield return new object[] { s_invariantCompare, "\u6FA4", "\u6CA2", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u30D6\u30D9\u30DC", CompareOptions.None, s_expectedHiraganaToKatakanaCompare }; @@ -206,7 +209,7 @@ public static IEnumerable SortKey_TestData() yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3079\uFF8E\uFF9E", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3071\u3074\u30D7\u307A", "\uFF8B\uFF9F\uFF8C\uFF9F", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", CompareOptions.None, 1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C\u3079\u307C", "\u3079\uFF8E\uFF9E", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3070\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", CompareOptions.None, -1 }; @@ -225,8 +228,8 @@ public static IEnumerable SortKey_TestData() yield return new object[] { s_invariantCompare, "\u2019", "'", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "", "'", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "\u4E00", "\uFF11", CompareOptions.None, 1 }; - yield return new object[] { s_invariantCompare, "\u2160", "\uFF11", CompareOptions.None, 1 }; + yield return new object[] { s_invariantCompare, "\u4E00", "\uFF11", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; + yield return new object[] { s_invariantCompare, "\u2160", "\uFF11", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; yield return new object[] { s_invariantCompare, "0", "\uFF10", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "10", "1\uFF10", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "1\uFF10", "1\uFF10", CompareOptions.None, 0 }; @@ -236,7 +239,7 @@ public static IEnumerable SortKey_TestData() yield return new object[] { s_invariantCompare, "'\u3000'", "' '", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "\uFF1B", ";", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "\uFF08", "(", CompareOptions.None, 1 }; - yield return new object[] { s_invariantCompare, "\u30FC", "\uFF0D", CompareOptions.None, 1 }; + yield return new object[] { s_invariantCompare, "\u30FC", "\uFF0D", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; yield return new object[] { s_invariantCompare, "\u30FC", "\u30FC", CompareOptions.None, 0 }; yield return new object[] { s_invariantCompare, "\u30FC", "\u2015", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "\u30FC", "\u2010", CompareOptions.None, 1 }; @@ -248,59 +251,63 @@ public static IEnumerable SortKey_TestData() // Turkish yield return new object[] { s_turkishCompare, "i", "I", CompareOptions.None, 1 }; // Android has its own ICU, which doesn't work well with tr - if (!PlatformDetection.IsAndroid && !PlatformDetection.IsLinuxBionic) + if (!PlatformDetection.IsAndroid && !PlatformDetection.IsLinuxBionic && PlatformDetection.IsNotHybridGlobalizationOnOSX) { yield return new object[] { s_turkishCompare, "i", "I", CompareOptions.IgnoreCase, 1 }; yield return new object[] { s_turkishCompare, "i", "\u0130", CompareOptions.IgnoreCase, 0 }; } yield return new object[] { s_invariantCompare, "i", "\u0130", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "i", "I", CompareOptions.None, -1 }; + yield return new object[] { s_invariantCompare, "i", "I", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? 1 : -1 }; yield return new object[] { s_invariantCompare, "i", "I", CompareOptions.IgnoreCase, 0 }; yield return new object[] { s_invariantCompare, "i", "\u0130", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "i", "\u0130", CompareOptions.IgnoreCase, -1 }; yield return new object[] { s_invariantCompare, "\u00C0", "A\u0300", CompareOptions.None, 0 }; - yield return new object[] { s_invariantCompare, "\u00C0", "a\u0300", CompareOptions.None, 1 }; + yield return new object[] { s_invariantCompare, "\u00C0", "a\u0300", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? - 1 : 1 }; yield return new object[] { s_invariantCompare, "\u00C0", "a\u0300", CompareOptions.IgnoreCase, 0 }; yield return new object[] { s_invariantCompare, "FooBA\u0300R", "FooB\u00C0R", CompareOptions.IgnoreNonSpace, 0 }; - yield return new object[] { s_invariantCompare, "Test's", "Tests", CompareOptions.IgnoreSymbols, 0 }; - yield return new object[] { s_invariantCompare, "Test's", "Tests", CompareOptions.StringSort, -1 }; - yield return new object[] { s_invariantCompare, new string('a', 5555), new string('a', 5555), CompareOptions.None, 0 }; yield return new object[] { s_invariantCompare, "foobar", "FooB\u00C0R", CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase, 0 }; - yield return new object[] { s_invariantCompare, "foobar", "FooB\u00C0R", CompareOptions.IgnoreNonSpace, -1 }; + yield return new object[] { s_invariantCompare, "foobar", "FooB\u00C0R", CompareOptions.IgnoreNonSpace, PlatformDetection.IsHybridGlobalizationOnOSX ? 1 : -1 }; - yield return new object[] { s_invariantCompare, "\uFF9E", "\u3099", CompareOptions.IgnoreNonSpace, 0 }; - yield return new object[] { s_invariantCompare, "\uFF9E", "\u3099", CompareOptions.IgnoreCase, 0 }; yield return new object[] { s_invariantCompare, "\u20A9", "\uFFE6", CompareOptions.IgnoreWidth, 0 }; yield return new object[] { s_invariantCompare, "\u20A9", "\uFFE6", CompareOptions.IgnoreCase, -1 }; yield return new object[] { s_invariantCompare, "\u20A9", "\uFFE6", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "\u0021", "\uFF01", CompareOptions.IgnoreSymbols, 0 }; - yield return new object[] { s_invariantCompare, "\u00A2", "\uFFE0", CompareOptions.IgnoreSymbols, 0 }; - yield return new object[] { s_invariantCompare, "$", "&", CompareOptions.IgnoreSymbols, 0 }; - yield return new object[] { s_invariantCompare, "\uFF65", "\u30FB", CompareOptions.IgnoreSymbols, 0 }; yield return new object[] { s_invariantCompare, "\u0021", "\uFF01", CompareOptions.IgnoreWidth, 0 }; yield return new object[] { s_invariantCompare, "\u0021", "\uFF01", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.IgnoreWidth, 0 }; - yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.IgnoreSymbols, s_expectedHalfToFullFormsComparison }; yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.IgnoreCase, s_expectedHalfToFullFormsComparison }; yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.IgnoreNonSpace, s_expectedHalfToFullFormsComparison }; yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.None, s_expectedHalfToFullFormsComparison }; - yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", CompareOptions.IgnoreKanaType, 0 }; yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", CompareOptions.IgnoreCase, s_expectedHiraganaToKatakanaCompare }; - yield return new object[] { s_invariantCompare, "c", "C", CompareOptions.IgnoreKanaType, -1 }; // Spanish yield return new object[] { new CultureInfo("es-ES").CompareInfo, "llegar", "lugar", CompareOptions.None, -1 }; - // Zero-weight code points - // In both NLS (Windows) and ICU the code point U+200C ZERO WIDTH NON-JOINER has a zero weight, - // so it's compared as equal to the empty string. This means that we can't special-case GetHashCode("") - // and return a fixed value; we actually need to call the underlying OS or ICU API to calculate the sort key. - yield return new object[] { s_invariantCompare, "", "\u200c", CompareOptions.None, 0 }; + if (PlatformDetection.IsNotHybridGlobalizationOnOSX) + { + yield return new object[] { s_invariantCompare, "\uFF9E", "\u3099", CompareOptions.IgnoreNonSpace, 0 }; + yield return new object[] { s_invariantCompare, "\uFF9E", "\u3099", CompareOptions.IgnoreCase, 0 }; + + yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", CompareOptions.IgnoreKanaType, 0 }; + yield return new object[] { s_invariantCompare, "c", "C", CompareOptions.IgnoreKanaType, -1 }; + // Zero-weight code points + // In both NLS (Windows) and ICU the code point U+200C ZERO WIDTH NON-JOINER has a zero weight, + // so it's compared as equal to the empty string. This means that we can't special-case GetHashCode("") + // and return a fixed value; we actually need to call the underlying OS or ICU API to calculate the sort key. + yield return new object[] { s_invariantCompare, "", "\u200c", CompareOptions.None, 0 }; + + yield return new object[] { s_invariantCompare, "Test's", "Tests", CompareOptions.IgnoreSymbols, 0 }; + yield return new object[] { s_invariantCompare, "Test's", "Tests", CompareOptions.StringSort, -1 }; + yield return new object[] { s_invariantCompare, "\u0021", "\uFF01", CompareOptions.IgnoreSymbols, 0 }; + yield return new object[] { s_invariantCompare, "\u00A2", "\uFFE0", CompareOptions.IgnoreSymbols, 0 }; + yield return new object[] { s_invariantCompare, "$", "&", CompareOptions.IgnoreSymbols, 0 }; + yield return new object[] { s_invariantCompare, "\uFF65", "\u30FB", CompareOptions.IgnoreSymbols, 0 }; + yield return new object[] { s_invariantCompare, "\uFF66", "\u30F2", CompareOptions.IgnoreSymbols, s_expectedHalfToFullFormsComparison }; + } } public static IEnumerable IndexOf_TestData() @@ -395,7 +402,7 @@ public void SortKeyTestNotSupported() private static bool WindowsVersionHasTheCompareStringRegression => PlatformDetection.IsNlsGlobalization && CompareStringEx("", NORM_LINGUISTIC_CASING, "", 0, "\u200C", 1, IntPtr.Zero, IntPtr.Zero, 0) != 2; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(SortKey_TestData))] public void SortKeyTest(CompareInfo compareInfo, string string1, string string2, CompareOptions options, int expectedSign) { @@ -405,7 +412,7 @@ public void SortKeyTest(CompareInfo compareInfo, string string1, string string2, Assert.Equal(expectedSign, Math.Sign(SortKey.Compare(sk1, sk2))); Assert.Equal(expectedSign == 0, sk1.Equals(sk2)); - if (!WindowsVersionHasTheCompareStringRegression) + if (!WindowsVersionHasTheCompareStringRegression && PlatformDetection.IsNotHybridGlobalizationOnOSX) { Assert.Equal(Math.Sign(compareInfo.Compare(string1, string2, options)), Math.Sign(SortKey.Compare(sk1, sk2))); } @@ -444,7 +451,7 @@ unsafe static void RunSpanSortKeyTest(CompareInfo compareInfo, ReadOnlySpan Date: Thu, 30 Nov 2023 15:08:03 +0100 Subject: [PATCH 085/105] Fix XmlFormatWriterGeneratorAot test --- src/native/libs/System.Globalization.Native/pal_locale.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 8c5df3f7f0d5c..5c8219a4cefa5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -60,7 +60,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity int32_t i; if (localeID == NULL) - localeID = [NSLocale systemLocale].localeIdentifier.UTF8String; + localeID = [NSLocale currentLocale].localeIdentifier.UTF8String;//[NSLocale systemLocale].localeIdentifier.UTF8String; lastUnderscore = strrchr(localeID, '-'); if (lastUnderscore != NULL) @@ -89,7 +89,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity // terminate chars if (i >= 0 && i < parentCapacity) - parent[i] = 0; + parent[i] = '\0'; } /** From 2944f96ec811adcc9e960b09e69232076651e8c0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 4 Dec 2023 10:16:29 +0100 Subject: [PATCH 086/105] refactor GetSortKey function --- .../CompareInfo/CompareInfoTests.cs | 8 +++---- .../pal_collation.m | 23 ++++++++++++++++--- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index 51da4f84683db..0ae7ca5d265a3 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -57,10 +57,10 @@ public void EqualsTest(CompareInfo compare1, object value, bool expected) new object[] { "abc", CompareOptions.Ordinal, "ABC", CompareOptions.Ordinal, false }, new object[] { "abc", CompareOptions.Ordinal, "abc", CompareOptions.Ordinal, true }, new object[] { "abc", CompareOptions.None, "abc", CompareOptions.None, true }, - new object[] { "", CompareOptions.None, "\u200c", CompareOptions.None, true }, // see comment at bottom of SortKey_TestData + //new object[] { "", CompareOptions.None, "\u200c", CompareOptions.None, true }, // see comment at bottom of SortKey_TestData }; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(GetHashCodeTestData))] public void GetHashCodeTest(string source1, CompareOptions options1, string source2, CompareOptions options2, bool expected) { @@ -536,7 +536,7 @@ public void VersionTest() Assert.NotEqual(sv1.SortId, sv2.SortId); } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] [MemberData(nameof(GetHashCodeTestData))] public void GetHashCode_Span(string source1, CompareOptions options1, string source2, CompareOptions options2, bool expectSameHashCode) { @@ -553,7 +553,7 @@ public void GetHashCode_Span(string source1, CompareOptions options1, string sou Assert.Equal(expectSameHashCode, hashOfSource1AsSpan == hashOfSource2AsSpan); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] + [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] public void GetHashCode_NullAndEmptySpan() { // Ensure that null spans and non-null empty spans produce the same hash code. diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index d2bcd3fcdfc62..5e44e0c96b000 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -334,9 +334,26 @@ int32_t GlobalizationNative_GetSortKeyNative( dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; } else { - // Convert the string to UTF-16 representation - dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; - utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; + // // Convert the string to UTF-16 representation + // dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; + // utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; + // In case of invalid characters, we need to iterate through the string character by character + NSMutableString *cleanString = [NSMutableString stringWithCapacity:[transformedString length]]; + + [transformedString enumerateSubstringsInRange:NSMakeRange(0, [transformedString length]) + options:NSStringEnumerationByComposedCharacterSequences + usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop){ + // Check if the substring can be encoded in UTF-8 + if ([substring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 0) { + [cleanString appendString:substring]; + } else { + // Handle invalid characters (if needed) + NSLog(@"Invalid character found and omitted: %@", substring); + } + }]; + utf8Bytes = [cleanString UTF8String]; + utf8Length = [cleanString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; + dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; } if (dataToUse != nil) { From 09dd4760355bc53e71ceaca1c5e8cd9ca670a315 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 4 Dec 2023 14:25:22 +0100 Subject: [PATCH 087/105] check if calendar is the cause --- .../src/System/Globalization/CultureData.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 5628bf35fc506..b16decd17427c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -547,6 +547,7 @@ internal static CultureInfo[] GetCultures(CultureTypes types) private static CultureData CreateCultureWithInvariantData() { // Make a new culturedata + System.Diagnostics.Debug.Write("CreateCultureWithInvariantData CultureData ctor: Making new culturedata for: "); CultureData invariant = new CultureData(); // Basics @@ -633,8 +634,8 @@ private static CultureData CreateCultureWithInvariantData() if (!GlobalizationMode.Invariant) { // Store for specific data about each calendar - invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; - invariant._calendars[0] = CalendarData.Invariant; + //invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; + // invariant._calendars[0] = CalendarData.Invariant; } // Text information From 43aca306a655eee106223d83c06106375421e884 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 4 Dec 2023 15:37:26 +0100 Subject: [PATCH 088/105] check if _calendars is null --- .../src/System/Globalization/CultureData.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index b16decd17427c..fc9f607e3d92b 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -547,7 +547,6 @@ internal static CultureInfo[] GetCultures(CultureTypes types) private static CultureData CreateCultureWithInvariantData() { // Make a new culturedata - System.Diagnostics.Debug.Write("CreateCultureWithInvariantData CultureData ctor: Making new culturedata for: "); CultureData invariant = new CultureData(); // Basics @@ -634,8 +633,12 @@ private static CultureData CreateCultureWithInvariantData() if (!GlobalizationMode.Invariant) { // Store for specific data about each calendar - //invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; - // invariant._calendars[0] = CalendarData.Invariant; + invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; + // Make sure that calendar has data + if (invariant._calendars != null && invariant._calendars.Count > 0) + { + invariant._calendars[0] = CalendarData.Invariant; + } } // Text information From d94c91770fc6e5fee6706be3bbdde2c679a3e2b6 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 4 Dec 2023 16:05:07 +0100 Subject: [PATCH 089/105] check for _calendars?.Length --- .../src/System/Globalization/CultureData.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index fc9f607e3d92b..f1492176125a2 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -635,7 +635,7 @@ private static CultureData CreateCultureWithInvariantData() // Store for specific data about each calendar invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; // Make sure that calendar has data - if (invariant._calendars != null && invariant._calendars.Count > 0) + if (invariant._calendars != null && invariant._calendars?.Length > 0) { invariant._calendars[0] = CalendarData.Invariant; } From 6193794798a6030fdf50e054f3ce276bc75dee47 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 5 Dec 2023 14:38:18 +0100 Subject: [PATCH 090/105] Refactor GetSortKey --- .../pal_collation.m | 66 +++++-------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 5e44e0c96b000..c1d0c527a1b4f 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -298,26 +298,25 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l } } -int32_t GlobalizationNative_GetSortKeyNative( - const uint16_t* localeName, - int32_t lNameLength, - const UChar* lpStr, - int32_t cwStrLength, - uint8_t* sortKey, - int32_t cbSortKeyLength, - int32_t options) +int32_t GlobalizationNative_GetSortKeyNative(const uint16_t* localeName, int32_t lNameLength, const UChar* lpStr, int32_t cwStrLength, + uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) { @autoreleasepool { if (cwStrLength == 0) { if (sortKey != NULL) - { sortKey[0] = '\0'; - } return 1; } NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; NSString *sourceStringCleaned = RemoveWeightlessCharacters(sourceString).precomposedStringWithCanonicalMapping; + // If the string is empty after removing weightless characters, return 1 + if(sourceStringCleaned.length == 0) + { + if (sortKey != NULL) + sortKey[0] = '\0'; + return 1; + } NSLocale *locale = GetCurrentLocale(localeName, lNameLength); NSStringCompareOptions comparisonOptions = options == 0 ? 0 : ConvertFromCompareOptionsToNSStringCompareOptions(options); @@ -325,45 +324,14 @@ int32_t GlobalizationNative_GetSortKeyNative( // Generate a sort key for the original string based on the locale NSString *transformedString = [sourceStringCleaned stringByFoldingWithOptions:comparisonOptions locale:locale]; - // Convert the string to UTF-8 representation - const char *utf8Bytes = [transformedString UTF8String]; - NSData *dataToUse = nil; - NSUInteger utf8Length = 0; - if (utf8Bytes != NULL) { - utf8Length = [transformedString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; - } - else { - // // Convert the string to UTF-16 representation - // dataToUse = [transformedString dataUsingEncoding:NSUTF16StringEncoding]; - // utf8Length = ([dataToUse length] / sizeof(uint16_t)) * 2; - // In case of invalid characters, we need to iterate through the string character by character - NSMutableString *cleanString = [NSMutableString stringWithCapacity:[transformedString length]]; - - [transformedString enumerateSubstringsInRange:NSMakeRange(0, [transformedString length]) - options:NSStringEnumerationByComposedCharacterSequences - usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop){ - // Check if the substring can be encoded in UTF-8 - if ([substring lengthOfBytesUsingEncoding:NSUTF8StringEncoding] > 0) { - [cleanString appendString:substring]; - } else { - // Handle invalid characters (if needed) - NSLog(@"Invalid character found and omitted: %@", substring); - } - }]; - utf8Bytes = [cleanString UTF8String]; - utf8Length = [cleanString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - dataToUse = [NSData dataWithBytes:utf8Bytes length:utf8Length]; - } - - if (dataToUse != nil) { - const uint8_t *bytesToCopy = (const uint8_t *)[dataToUse bytes]; - if (sortKey != NULL) - { - memcpy(sortKey, bytesToCopy, utf8Length); - } - return utf8Length; - } + NSUInteger transformedStringBytes = [transformedString lengthOfBytesUsingEncoding: NSUTF16StringEncoding]; + if (sortKey == NULL) + return (int32_t)transformedStringBytes; + NSRange range = NSMakeRange(0, [transformedString length]); + NSUInteger usedLength = 0; + BOOL result = [transformedString getBytes:sortKey maxLength:transformedStringBytes usedLength:&usedLength encoding:NSUTF16StringEncoding options:0 range:range remainingRange:NULL]; + if (result) + return (int32_t)usedLength; return 0; } From 632178491e3de556ef12cd39f66ec3e71f698bd0 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 5 Dec 2023 12:53:23 -0500 Subject: [PATCH 091/105] Stop using GlobalizationMode Settings static constructor because we don't need to load icu any longer. Also default GlobalizationMode.Hybrid to true because there is only one mode now for apple mobile platforms --- .../src/System/Globalization/GlobalizationMode.Unix.cs | 6 ++---- .../src/System/Globalization/GlobalizationMode.cs | 4 +++- src/tasks/AppleAppBuilder/Templates/runtime.m | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs index 3c47652fbe256..df937e56e34fe 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.Unix.cs @@ -12,16 +12,13 @@ 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. /// +#if !TARGET_MACCATALYST && !TARGET_IOS && !TARGET_TVOS static Settings() { // Use GlobalizationMode.Invariant to allow ICU initialization to be trimmed when Invariant=true // and PredefinedCulturesOnly is unspecified. if (!GlobalizationMode.Invariant) { -#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS - if (GlobalizationMode.Hybrid) - return; -#endif if (TryGetAppLocalIcuSwitchValue(out string? icuSuffixAndVersion)) { LoadAppLocalIcu(icuSuffixAndVersion); @@ -36,6 +33,7 @@ static Settings() } } } +#endif private static string GetIcuLoadFailureMessage() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs index a81023eedccc2..cd6f9e53c937d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -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; +#else if 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); diff --git a/src/tasks/AppleAppBuilder/Templates/runtime.m b/src/tasks/AppleAppBuilder/Templates/runtime.m index 925e8175fc73d..3d825f50f0079 100644 --- a/src/tasks/AppleAppBuilder/Templates/runtime.m +++ b/src/tasks/AppleAppBuilder/Templates/runtime.m @@ -261,10 +261,6 @@ static bool is_pinvoke_override_library (const char* libraryName) setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); #endif -#if HYBRID_GLOBALIZATION - setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); -#endif - #if ENABLE_RUNTIME_LOGGING setenv ("MONO_LOG_LEVEL", "debug", TRUE); setenv ("MONO_LOG_MASK", "all", TRUE); From 8ec77271ce981fa3375e86710a3c7dfcfe46dcb1 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 6 Dec 2023 08:19:15 +0100 Subject: [PATCH 092/105] Fix syntax error --- .../src/System/Globalization/GlobalizationMode.cs | 2 +- .../System.Globalization.Tests/CompareInfo/CompareInfoTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs index cd6f9e53c937d..314bb33692dc7 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/GlobalizationMode.cs @@ -15,7 +15,7 @@ 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 internal static bool Hybrid { get; } = true; -#else if TARGET_BROWSER +#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); diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index 0ae7ca5d265a3..df1b88015efc1 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -402,7 +402,7 @@ public void SortKeyTestNotSupported() private static bool WindowsVersionHasTheCompareStringRegression => PlatformDetection.IsNlsGlobalization && CompareStringEx("", NORM_LINGUISTIC_CASING, "", 0, "\u200C", 1, IntPtr.Zero, IntPtr.Zero, 0) != 2; - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalization))] [MemberData(nameof(SortKey_TestData))] public void SortKeyTest(CompareInfo compareInfo, string string1, string string2, CompareOptions options, int expectedSign) { From 6ca8bd14e93a6fca956292f4a5a308d54e49eff7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 6 Dec 2023 12:10:37 +0100 Subject: [PATCH 093/105] Refactor --- .../src/System/Globalization/CultureData.cs | 6 +-- .../CompareInfo/CompareInfoTests.cs | 2 +- .../pal_collation.m | 39 ------------------- 3 files changed, 2 insertions(+), 45 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs index 7d0af71a14cdb..1973aa523bcc0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs @@ -634,11 +634,7 @@ private static CultureData CreateCultureWithInvariantData() { // Store for specific data about each calendar invariant._calendars = new CalendarData[CalendarData.MAX_CALENDARS]; - // Make sure that calendar has data - if (invariant._calendars != null && invariant._calendars?.Length > 0) - { - invariant._calendars[0] = CalendarData.Invariant; - } + invariant._calendars[0] = CalendarData.Invariant; } // Text information diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index b09a0548875a6..dc4789b3fa41b 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -57,7 +57,7 @@ public void EqualsTest(CompareInfo compare1, object value, bool expected) new object[] { "abc", CompareOptions.Ordinal, "ABC", CompareOptions.Ordinal, false }, new object[] { "abc", CompareOptions.Ordinal, "abc", CompareOptions.Ordinal, true }, new object[] { "abc", CompareOptions.None, "abc", CompareOptions.None, true }, - //new object[] { "", CompareOptions.None, "\u200c", CompareOptions.None, true }, // see comment at bottom of SortKey_TestData + new object[] { "", CompareOptions.None, "\u200c", CompareOptions.None, true }, // see comment at bottom of SortKey_TestData }; [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnBrowser))] diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index 1368e009ad9f4..c1d0c527a1b4f 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -298,45 +298,6 @@ int32_t GlobalizationNative_EndsWithNative(const uint16_t* localeName, int32_t l } } -int32_t GlobalizationNative_GetSortKeyNative(const uint16_t* localeName, int32_t lNameLength, const UChar* lpStr, int32_t cwStrLength, - uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) -{ - @autoreleasepool { - if (cwStrLength == 0) - { - if (sortKey != NULL) - sortKey[0] = '\0'; - return 1; - } - NSString *sourceString = [NSString stringWithCharacters: lpStr length: cwStrLength]; - NSString *sourceStringCleaned = RemoveWeightlessCharacters(sourceString).precomposedStringWithCanonicalMapping; - // If the string is empty after removing weightless characters, return 1 - if(sourceStringCleaned.length == 0) - { - if (sortKey != NULL) - sortKey[0] = '\0'; - return 1; - } - - NSLocale *locale = GetCurrentLocale(localeName, lNameLength); - NSStringCompareOptions comparisonOptions = options == 0 ? 0 : ConvertFromCompareOptionsToNSStringCompareOptions(options); - - // Generate a sort key for the original string based on the locale - NSString *transformedString = [sourceStringCleaned stringByFoldingWithOptions:comparisonOptions locale:locale]; - - NSUInteger transformedStringBytes = [transformedString lengthOfBytesUsingEncoding: NSUTF16StringEncoding]; - if (sortKey == NULL) - return (int32_t)transformedStringBytes; - NSRange range = NSMakeRange(0, [transformedString length]); - NSUInteger usedLength = 0; - BOOL result = [transformedString getBytes:sortKey maxLength:transformedStringBytes usedLength:&usedLength encoding:NSUTF16StringEncoding options:0 range:range remainingRange:NULL]; - if (result) - return (int32_t)usedLength; - - return 0; - } -} - int32_t GlobalizationNative_GetSortKeyNative(const uint16_t* localeName, int32_t lNameLength, const UChar* lpStr, int32_t cwStrLength, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) { From a50fb14e03e70ce1c988141ad6e4e8ab466e6c20 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 6 Dec 2023 13:33:43 +0100 Subject: [PATCH 094/105] Fix wrong merge --- .../System.Globalization.Tests/CompareInfo/CompareInfoTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs index dc4789b3fa41b..8ca1892cde0c8 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CompareInfo/CompareInfoTests.cs @@ -209,7 +209,7 @@ public static IEnumerable SortKey_TestData() yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3079\uFF8E\uFF9E", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3070\u3073\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3071\u3074\u30D7\u307A", "\uFF8B\uFF9F\uFF8C\uFF9F", CompareOptions.None, -1 }; - yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", CompareOptions.None, PlatformDetection.IsHybridGlobalizationOnOSX ? -1 : 1 }; + yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u3070\uFF8E\uFF9E\u30D6", CompareOptions.None, 1 }; yield return new object[] { s_invariantCompare, "\u3070\u30DC\uFF8C\uFF9E\uFF8D\uFF9E\u307C\u3079\u307C", "\u3079\uFF8E\uFF9E", CompareOptions.None, -1 }; yield return new object[] { s_invariantCompare, "\u3070\uFF8C\uFF9E\uFF8D\uFF9E\u307C", "\u30D6", CompareOptions.None, -1 }; From f6708f0af11ba5997cd598497b7fd9017564eaf7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 7 Dec 2023 11:51:08 +0100 Subject: [PATCH 095/105] Changes requested by review --- .../Microsoft.NETCore.Native.Unix.targets | 3 +- .../Common/tests/Tests/System/StringTests.cs | 187 ++++++++---------- .../pal_collation.m | 1 + .../System.Globalization.Native/pal_locale.m | 4 +- .../FunctionalTests/Directory.Build.props | 1 - 5 files changed, 90 insertions(+), 106 deletions(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index af4ee4e62259d..4971541fa7849 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -92,8 +92,7 @@ The .NET Foundation licenses this file to you under the MIT license. - - + diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 7f1bd86c1cfb8..88610d60f8a6c 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1033,26 +1033,23 @@ public static void CompareToNoMatch_StringComparison() var secondSpan = new ReadOnlySpan(second); Assert.True(0 > firstSpan.CompareTo(secondSpan, StringComparison.Ordinal)); - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) - { - // Due to differences in the implementation, the exact result of CompareTo will not necessarily match with string.Compare. - // However, the sign will match, which is what defines correctness. - Assert.Equal( - Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), - Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.InvariantCultureIgnoreCase)); - } + // Due to differences in the implementation, the exact result of CompareTo will not necessarily match with string.Compare. + // However, the sign will match, which is what defines correctness. + Assert.Equal( + Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), + Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } } } @@ -1313,21 +1310,18 @@ public static void ContainsNoMatch_StringComparison() Assert.False(firstSpan.Contains(secondSpan, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) - { - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.Contains(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.Contains(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.Contains(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.Contains(secondSpan, StringComparison.InvariantCultureIgnoreCase)); - } + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.Contains(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.Contains(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.Contains(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.Contains(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } } } @@ -2139,21 +2133,18 @@ public static void EndsWithNoMatch_StringComparison() Assert.False(s1.EndsWith(s2, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) - { - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCulture), - s1.EndsWith(s2, StringComparison.CurrentCulture)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), - s1.EndsWith(s2, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCulture), - s1.EndsWith(s2, StringComparison.InvariantCulture)); - Assert.Equal( - s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), - s1.EndsWith(s2, StringComparison.InvariantCultureIgnoreCase)); - } + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCulture), + s1.EndsWith(s2, StringComparison.CurrentCulture)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), + s1.EndsWith(s2, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCulture), + s1.EndsWith(s2, StringComparison.InvariantCulture)); + Assert.Equal( + s1.ToString().EndsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), + s1.EndsWith(s2, StringComparison.InvariantCultureIgnoreCase)); var firstSpan = new ReadOnlySpan(first); var secondSpan = new ReadOnlySpan(second); @@ -2162,21 +2153,18 @@ public static void EndsWithNoMatch_StringComparison() Assert.False(firstSpan.EndsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); // Different behavior depending on OS - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) - { - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.EndsWith(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.EndsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.EndsWith(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.EndsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); - } + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.EndsWith(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.EndsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.EndsWith(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().EndsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.EndsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } } } @@ -7263,42 +7251,39 @@ public static void StartsWithNoMatch_StringComparison() Assert.False(s1.StartsWith(s2, StringComparison.OrdinalIgnoreCase)); - if (PlatformDetection.IsNotHybridGlobalizationOnOSX) - { - // Different behavior depending on OS - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCulture), - s1.StartsWith(s2, StringComparison.CurrentCulture)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), - s1.StartsWith(s2, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCulture), - s1.StartsWith(s2, StringComparison.InvariantCulture)); - Assert.Equal( - s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), - s1.StartsWith(s2, StringComparison.InvariantCultureIgnoreCase)); - - ReadOnlySpan firstSpan = s1.AsSpan(); - ReadOnlySpan secondSpan = s2.AsSpan(); - Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.Ordinal)); - - Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); - - // Different behavior depending on OS - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.StartsWith(secondSpan, StringComparison.CurrentCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.StartsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), - firstSpan.StartsWith(secondSpan, StringComparison.InvariantCulture)); - Assert.Equal( - firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), - firstSpan.StartsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); - } + // Different behavior depending on OS + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCulture), + s1.StartsWith(s2, StringComparison.CurrentCulture)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.CurrentCultureIgnoreCase), + s1.StartsWith(s2, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCulture), + s1.StartsWith(s2, StringComparison.InvariantCulture)); + Assert.Equal( + s1.ToString().StartsWith(s2.ToString(), StringComparison.InvariantCultureIgnoreCase), + s1.StartsWith(s2, StringComparison.InvariantCultureIgnoreCase)); + + ReadOnlySpan firstSpan = s1.AsSpan(); + ReadOnlySpan secondSpan = s2.AsSpan(); + Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.Ordinal)); + + Assert.False(firstSpan.StartsWith(secondSpan, StringComparison.OrdinalIgnoreCase)); + + // Different behavior depending on OS + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.StartsWith(secondSpan, StringComparison.CurrentCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.StartsWith(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCulture), + firstSpan.StartsWith(secondSpan, StringComparison.InvariantCulture)); + Assert.Equal( + firstSpan.ToString().StartsWith(secondSpan.ToString(), StringComparison.InvariantCultureIgnoreCase), + firstSpan.StartsWith(secondSpan, StringComparison.InvariantCultureIgnoreCase)); } } } diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index c1d0c527a1b4f..68f8f4b64ccf1 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -336,4 +336,5 @@ int32_t GlobalizationNative_GetSortKeyNative(const uint16_t* localeName, int32_t return 0; } } + #endif diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 5c8219a4cefa5..f1c5ac41725bd 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -60,7 +60,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity int32_t i; if (localeID == NULL) - localeID = [NSLocale currentLocale].localeIdentifier.UTF8String;//[NSLocale systemLocale].localeIdentifier.UTF8String; + localeID = [NSLocale currentLocale].localeIdentifier.UTF8String; lastUnderscore = strrchr(localeID, '-'); if (lastUnderscore != NULL) @@ -89,7 +89,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity // terminate chars if (i >= 0 && i < parentCapacity) - parent[i] = '\0'; + parent[i] = 0; } /** diff --git a/src/tests/FunctionalTests/Directory.Build.props b/src/tests/FunctionalTests/Directory.Build.props index 871509c70fbc3..bd0f1c463f6c0 100644 --- a/src/tests/FunctionalTests/Directory.Build.props +++ b/src/tests/FunctionalTests/Directory.Build.props @@ -39,7 +39,6 @@ false false true - true false false false From 7dfc9088ae1c86364f0624211cbed18ffeebca06 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Thu, 7 Dec 2023 11:54:36 +0100 Subject: [PATCH 096/105] Align lines --- src/libraries/Common/tests/Tests/System/StringTests.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/tests/Tests/System/StringTests.cs b/src/libraries/Common/tests/Tests/System/StringTests.cs index 88610d60f8a6c..c0b31d5d352c3 100644 --- a/src/libraries/Common/tests/Tests/System/StringTests.cs +++ b/src/libraries/Common/tests/Tests/System/StringTests.cs @@ -1038,12 +1038,13 @@ public static void CompareToNoMatch_StringComparison() Assert.Equal( Math.Sign(string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.OrdinalIgnoreCase)), Math.Sign(firstSpan.CompareTo(secondSpan, StringComparison.OrdinalIgnoreCase))); + Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCulture), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCulture)); Assert.Equal( - string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), - firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); + string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.CurrentCultureIgnoreCase), + firstSpan.CompareTo(secondSpan, StringComparison.CurrentCultureIgnoreCase)); Assert.Equal( string.Compare(firstSpan.ToString(), secondSpan.ToString(), StringComparison.InvariantCulture), firstSpan.CompareTo(secondSpan, StringComparison.InvariantCulture)); From 213f6a4fc4181317bb2735de9554c586dd0df765 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 12 Dec 2023 14:11:01 +0100 Subject: [PATCH 097/105] Mark test cases as activeissue --- docs/design/features/globalization-hybrid-mode.md | 5 ++--- .../tests/CaseInsensitiveComparerTests.cs | 3 ++- .../tests/CaseInsensitiveHashCodeProviderTests.cs | 3 ++- .../CultureInfo/CultureInfoCtor.cs | 3 ++- .../DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs | 3 ++- .../tests/System.Reflection.Tests/AssemblyNameTests.cs | 3 ++- .../System/Convert.ToDateTime.cs | 3 ++- .../tests/System.Runtime.Tests/System/DateTimeTests.cs | 6 ++++-- 8 files changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index 2be75ac3150e6..1be6581282953 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -343,7 +343,8 @@ The number of `CompareOptions` and `NSStringCompareOptions` combinations are lim - `IgnoreSymbols` is not supported because there is no equivalent in native api. Throws `PlatformNotSupportedException`. -- `IgnoreKanaType` is not supported because there is no equivalent in native api. Throws `PlatformNotSupportedException`. +- `IgnoreKanaType`: + `CompareOptions.IgnoreKanaType` is mapped to `NSStringCompareOptions.NSCaseInsensitiveSearch | NSStringCompareOptions.NSDiacriticInsensitiveSearch | `NSStringCompareOptions.NSWidthInsensitiveSearch` - `None`: @@ -385,8 +386,6 @@ The number of `CompareOptions` and `NSStringCompareOptions` combinations are lim `IgnoreSymbols`, - `IgnoreKanaType`, - ## String starts with / ends with Affected public APIs: diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs index ecc42d3e2da34..362a76fc3dc35 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveComparerTests.cs @@ -64,8 +64,9 @@ public void Ctor_CultureInfo_Compare(object a, object b, int expected) } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public void Ctor_CultureInfo_Compare_TurkishI() { var cultureNames = Helpers.TestCultureNames; diff --git a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs index cf3889a557708..fdacdfb65fece 100644 --- a/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs +++ b/src/libraries/System.Collections.NonGeneric/tests/CaseInsensitiveHashCodeProviderTests.cs @@ -94,8 +94,9 @@ public void Ctor_CultureInfo_ChangeCurrentCulture_GetHashCodeCompare(object a, o } } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] [ActiveIssue("https://github.com/dotnet/runtime/issues/37069", TestPlatforms.Android | TestPlatforms.LinuxBionic)] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public void Ctor_CultureInfo_GetHashCodeCompare_TurkishI() { var cultureNames = Helpers.TestCultureNames; diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCtor.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCtor.cs index 9edf9c5dfe6cf..71f1392588294 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCtor.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCtor.cs @@ -400,7 +400,8 @@ public void Ctor_String(string name, string[] expectedNames) Assert.Equal(cultureName, culture.ToString(), ignoreCase: true); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public void Ctor_String_Invalid() { AssertExtensions.Throws("name", () => new CultureInfo(null)); // Name is null diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs index 6182546199a92..348310b6a69e9 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs @@ -49,7 +49,8 @@ public static IEnumerable GetEra_TestData() yield return new object[] { frFRFormat, "ap J-C", -1 }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] [MemberData(nameof(GetEra_TestData))] public void GetEra_Invoke_ReturnsExpected(DateTimeFormatInfo format, string eraName, int expected) { diff --git a/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs b/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs index ebc563eacbfcd..3079f6f0129f6 100644 --- a/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs +++ b/src/libraries/System.Runtime/tests/System.Reflection.Tests/AssemblyNameTests.cs @@ -221,7 +221,8 @@ public void CultureName_Set(AssemblyName assemblyName, string originalCultureNam Assert.Equal(new AssemblyName(expectedEqualString).FullName, assemblyName.FullName); } - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public void CultureName_Set_Invalid_ThrowsCultureNotFoundException() { var assemblyName = new AssemblyName("Test"); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs index 9ddd1dea1bddb..245ccd8f3af4f 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Extensions.Tests/System/Convert.ToDateTime.cs @@ -10,7 +10,8 @@ public class ConvertToDateTimeTests : ConvertTestBase { private static readonly DateTimeFormatInfo s_dateTimeFormatInfo = new DateTimeFormatInfo(); - [ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Fact] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] 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) }; diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DateTimeTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DateTimeTests.cs index 843078537171f..b73820bc60687 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DateTimeTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/DateTimeTests.cs @@ -2002,7 +2002,8 @@ public static IEnumerable Parse_ValidInput_Succeeds_MemberData() } } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] [MemberData(nameof(Parse_ValidInput_Succeeds_MemberData))] public static void Parse_ValidInput_Succeeds(string input, CultureInfo culture, DateTime? expected) { @@ -2462,7 +2463,8 @@ public static IEnumerable ToString_MatchesExpected_MemberData() yield return new object[] { new DateTime(2023, 04, 17, 10, 46, 12, DateTimeKind.Utc), "HH\u202dmm", null, "10\u202d46" }; } - [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] + [Theory] + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] [MemberData(nameof(Parse_ValidInput_Succeeds_MemberData))] public static void Parse_Span_ValidInput_Succeeds(string input, CultureInfo culture, DateTime? expected) { From 51277853b29aafee0ebe42d1420ba36319106917 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 12 Dec 2023 14:34:57 +0100 Subject: [PATCH 098/105] Revert the change and update documentation --- docs/design/features/globalization-hybrid-mode.md | 2 +- .../DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/design/features/globalization-hybrid-mode.md b/docs/design/features/globalization-hybrid-mode.md index 1be6581282953..213cff9066735 100644 --- a/docs/design/features/globalization-hybrid-mode.md +++ b/docs/design/features/globalization-hybrid-mode.md @@ -344,7 +344,7 @@ The number of `CompareOptions` and `NSStringCompareOptions` combinations are lim - `IgnoreSymbols` is not supported because there is no equivalent in native api. Throws `PlatformNotSupportedException`. - `IgnoreKanaType`: - `CompareOptions.IgnoreKanaType` is mapped to `NSStringCompareOptions.NSCaseInsensitiveSearch | NSStringCompareOptions.NSDiacriticInsensitiveSearch | `NSStringCompareOptions.NSWidthInsensitiveSearch` + `CompareOptions.IgnoreKanaType` is mapped to `NSStringCompareOptions.NSCaseInsensitiveSearch | NSStringCompareOptions.NSDiacriticInsensitiveSearch | NSStringCompareOptions.NSWidthInsensitiveSearch` - `None`: diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs index 348310b6a69e9..6182546199a92 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/DateTimeFormatInfo/DateTimeFormatInfoGetEra.cs @@ -49,8 +49,7 @@ public static IEnumerable GetEra_TestData() yield return new object[] { frFRFormat, "ap J-C", -1 }; } - [Theory] - [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] + [ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotHybridGlobalizationOnOSX))] [MemberData(nameof(GetEra_TestData))] public void GetEra_Invoke_ReturnsExpected(DateTimeFormatInfo format, string eraName, int expected) { From 20096cdeefdfe60b20b220a034847f2cf7a05167 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 12 Dec 2023 16:12:13 +0100 Subject: [PATCH 099/105] include ICU headers in pal_icushim_internal.h --- eng/testing/tests.ioslike.targets | 3 --- src/mono/sample/iOS-NativeAOT/Program.csproj | 1 - src/native/libs/System.Globalization.Native/pal_casing.m | 1 - src/native/libs/System.Globalization.Native/pal_common.c | 3 --- .../libs/System.Globalization.Native/pal_errors_internal.h | 4 +--- .../libs/System.Globalization.Native/pal_icushim_internal.h | 5 +++++ src/native/libs/System.Globalization.Native/pal_idna.h | 5 ----- src/native/libs/System.Globalization.Native/pal_locale.h | 1 - .../libs/System.Globalization.Native/pal_locale_internal.h | 4 +--- src/tasks/AppleAppBuilder/Templates/main-console.m | 3 --- src/tasks/AppleAppBuilder/Templates/main-simple.m | 3 --- src/tests/Directory.Build.props | 1 - .../iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj | 1 - 13 files changed, 7 insertions(+), 28 deletions(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index 8f788e03b055e..ac6eeccaabc06 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -157,9 +157,6 @@ - - true - true true AppleTestRunner.dll diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index 6017daf8565f1..ceaa61bfcdc95 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -4,7 +4,6 @@ bin $(MSBuildThisFileDirectory)/obj/ $(NetCoreAppCurrent) - true iossimulator true $(TargetOS)-$(TargetArchitecture) diff --git a/src/native/libs/System.Globalization.Native/pal_casing.m b/src/native/libs/System.Globalization.Native/pal_casing.m index 642cd831f109c..8f826769a603e 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.m +++ b/src/native/libs/System.Globalization.Native/pal_casing.m @@ -6,7 +6,6 @@ #include "pal_errors.h" #import -#include #if !__has_feature(objc_arc) #error This file relies on ARC for memory management, but ARC is not enabled. diff --git a/src/native/libs/System.Globalization.Native/pal_common.c b/src/native/libs/System.Globalization.Native/pal_common.c index 6141b66699871..5904a1c3bdbe2 100644 --- a/src/native/libs/System.Globalization.Native/pal_common.c +++ b/src/native/libs/System.Globalization.Native/pal_common.c @@ -1,9 +1,6 @@ #include #include "pal_icushim_internal.h" #include "pal_casing.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#include -#endif void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget) { diff --git a/src/native/libs/System.Globalization.Native/pal_errors_internal.h b/src/native/libs/System.Globalization.Native/pal_errors_internal.h index 4ee385fd4c90a..1680335834736 100644 --- a/src/native/libs/System.Globalization.Native/pal_errors_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_errors_internal.h @@ -5,9 +5,7 @@ #include "pal_icushim_internal.h" #include "pal_errors.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#include -#endif + /* Converts a UErrorCode to a ResultCode. */ diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index ee1dd5e8db017..30b3d919e6d18 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -21,6 +21,11 @@ // All ICU headers need to be included here so that all function prototypes are // available before the function pointers are declared below. +#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) +#include +#include +#include +#endif #if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_idna.h b/src/native/libs/System.Globalization.Native/pal_idna.h index f4d23935318ac..d50f90f36ad94 100644 --- a/src/native/libs/System.Globalization.Native/pal_idna.h +++ b/src/native/libs/System.Globalization.Native/pal_idna.h @@ -7,11 +7,6 @@ #include "pal_locale.h" #include "pal_compiler.h" -#if defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS) -#include -#include -#endif - PALEXPORT int32_t GlobalizationNative_ToAscii(uint32_t flags, const UChar* lpSrc, int32_t cwSrcLength, diff --git a/src/native/libs/System.Globalization.Native/pal_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 2ab7457dcbf8b..3249ff15176da 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -18,7 +18,6 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeNam int shortFormat, UChar* value, int32_t valueLength); #else -#include PALEXPORT const char* GlobalizationNative_GetDefaultLocaleNameNative(void); diff --git a/src/native/libs/System.Globalization.Native/pal_locale_internal.h b/src/native/libs/System.Globalization.Native/pal_locale_internal.h index 7c80adc7d051d..c754554bbfdd5 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_locale_internal.h @@ -4,9 +4,7 @@ #pragma once #include "pal_icushim_internal.h" -#if defined(TARGET_MACCATALYST) || defined(TARGET_IOS) || defined(TARGET_TVOS) -#include -#endif + /* Function: UErrorCodeToBool diff --git a/src/tasks/AppleAppBuilder/Templates/main-console.m b/src/tasks/AppleAppBuilder/Templates/main-console.m index 880881d71c79c..5bad15ff67de1 100644 --- a/src/tasks/AppleAppBuilder/Templates/main-console.m +++ b/src/tasks/AppleAppBuilder/Templates/main-console.m @@ -74,9 +74,6 @@ - (void)viewDidLoad { #else #if INVARIANT_GLOBALIZATION setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); -#endif -#if HYBRID_GLOBALIZATION - setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); #endif char **managed_argv; int managed_argc = get_managed_args (&managed_argv); diff --git a/src/tasks/AppleAppBuilder/Templates/main-simple.m b/src/tasks/AppleAppBuilder/Templates/main-simple.m index 50e6bb60d4734..36bf576d51397 100644 --- a/src/tasks/AppleAppBuilder/Templates/main-simple.m +++ b/src/tasks/AppleAppBuilder/Templates/main-simple.m @@ -56,9 +56,6 @@ - (void)viewDidLoad { #else #if INVARIANT_GLOBALIZATION setenv ("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1", TRUE); -#endif -#if HYBRID_GLOBALIZATION - setenv ("DOTNET_SYSTEM_GLOBALIZATION_HYBRID", "1", TRUE); #endif char **managed_argv; int managed_argc = get_managed_args (&managed_argv); diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 55f5fbff427da..485ef96914b0a 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,7 +223,6 @@ <_IsApplePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_IsiOSLikePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_SymbolPrefix Condition="'$(_IsApplePlatform)' == 'true'">_ - true diff --git a/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj b/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj index eef8e057d43c8..6f72500c94912 100644 --- a/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj +++ b/src/tests/FunctionalTests/iOS/Simulator/XmlFormatWriterGeneratorAOT/iOS.Simulator.XmlFormatWriterGeneratorAot.Test.csproj @@ -11,7 +11,6 @@ false 42 true - true From 1245214cef1cdf480b050dc553bdb3e4ce76be4d Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 12 Dec 2023 18:02:07 +0100 Subject: [PATCH 100/105] Fix nativeaot failures --- src/tests/Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 485ef96914b0a..55f5fbff427da 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,6 +223,7 @@ <_IsApplePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_IsiOSLikePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_SymbolPrefix Condition="'$(_IsApplePlatform)' == 'true'">_ + true From b602e0a72e6911d2eb4897997b287a894b4803cd Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Fri, 15 Dec 2023 11:32:10 +0100 Subject: [PATCH 101/105] mark the function as static --- src/native/libs/System.Globalization.Native/pal_collation.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/native/libs/System.Globalization.Native/pal_collation.m b/src/native/libs/System.Globalization.Native/pal_collation.m index ee03fb8008857..aa51b8d6ba138 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.m +++ b/src/native/libs/System.Globalization.Native/pal_collation.m @@ -71,7 +71,7 @@ static NSStringCompareOptions ConvertFromCompareOptionsToNSStringCompareOptions( return options; } -NSString *ConvertToKatakana(NSString *input) +static NSString *ConvertToKatakana(NSString *input) { NSMutableString *mutableString = [input mutableCopy]; CFStringTransform((__bridge CFMutableStringRef)mutableString, NULL, kCFStringTransformHiraganaKatakana, false); From 83076e022e7d8997143447aa36cb513873ac0fdc Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 18 Dec 2023 13:31:44 +0100 Subject: [PATCH 102/105] Fix nativeaot failures --- src/mono/sample/iOS-NativeAOT/Program.csproj | 1 + src/tests/Directory.Build.props | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index ceaa61bfcdc95..fc41414a99f8c 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -7,6 +7,7 @@ iossimulator true $(TargetOS)-$(TargetArchitecture) + true HelloiOS true true diff --git a/src/tests/Directory.Build.props b/src/tests/Directory.Build.props index 55f5fbff427da..60badfac3c1a3 100644 --- a/src/tests/Directory.Build.props +++ b/src/tests/Directory.Build.props @@ -223,7 +223,7 @@ <_IsApplePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_IsiOSLikePlatform Condition="'$(TargetsAppleMobile)' == 'true'">true <_SymbolPrefix Condition="'$(_IsApplePlatform)' == 'true'">_ - true + true From c422d077005d8179224c93d3d797b87b1ded7130 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 18 Dec 2023 14:22:14 +0100 Subject: [PATCH 103/105] check if this broke nativeaot tests --- .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index 107f750af7290..a80c627afe42b 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -92,7 +92,8 @@ The .NET Foundation licenses this file to you under the MIT license. - + + From 2b42a43a401924078c8d39b67b1ab010898ee35b Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Mon, 18 Dec 2023 14:57:31 +0100 Subject: [PATCH 104/105] Fix nativeaot failure --- eng/testing/tests.ioslike.targets | 2 ++ .../BuildIntegration/Microsoft.NETCore.Native.Unix.targets | 3 +-- src/mono/sample/iOS-NativeAOT/Program.csproj | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/testing/tests.ioslike.targets b/eng/testing/tests.ioslike.targets index ac6eeccaabc06..df77a1481fcc7 100644 --- a/eng/testing/tests.ioslike.targets +++ b/eng/testing/tests.ioslike.targets @@ -157,6 +157,8 @@ + + true true true AppleTestRunner.dll diff --git a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets index a80c627afe42b..107f750af7290 100644 --- a/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets +++ b/src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets @@ -92,8 +92,7 @@ The .NET Foundation licenses this file to you under the MIT license. - - + diff --git a/src/mono/sample/iOS-NativeAOT/Program.csproj b/src/mono/sample/iOS-NativeAOT/Program.csproj index fc41414a99f8c..ceaa61bfcdc95 100644 --- a/src/mono/sample/iOS-NativeAOT/Program.csproj +++ b/src/mono/sample/iOS-NativeAOT/Program.csproj @@ -7,7 +7,6 @@ iossimulator true $(TargetOS)-$(TargetArchitecture) - true HelloiOS true true From ba3aecbd157fc10e12a2b5c0675ff6c78418f7ce Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 19 Dec 2023 11:17:12 +0100 Subject: [PATCH 105/105] review refactoring --- src/mono/CMakeLists.txt | 9 ++++++++- .../System.Globalization.Native/pal_icushim_internal.h | 3 +-- src/native/libs/System.Globalization.Native/pal_locale.m | 2 +- src/tests/FunctionalTests/Directory.Build.props | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/mono/CMakeLists.txt b/src/mono/CMakeLists.txt index 3cd96dd319b86..623944f3ec464 100644 --- a/src/mono/CMakeLists.txt +++ b/src/mono/CMakeLists.txt @@ -747,7 +747,14 @@ elseif(HOST_BROWSER) set(STATIC_ICU 1) set(ICU_LIBS "icucore") elseif(HOST_IOS OR HOST_TVOS OR HOST_MACCAT) - set(ICU_FLAGS "-DTARGET_UNIX -DTARGET_IOS -DTARGET_TVOS -DTARGET_MACCATALYST -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") + set(ICU_FLAGS "-DTARGET_UNIX -DU_DISABLE_RENAMING -Wno-reserved-id-macro -Wno-documentation -Wno-documentation-unknown-command -Wno-switch-enum -Wno-covered-switch-default -Wno-extra-semi-stmt -Wno-unknown-warning-option -Wno-deprecated-declarations") + if(HOST_IOS) + string(APPEND ICU_FLAGS " -DTARGET_IOS") + elseif(HOST_TVOS) + string(APPEND ICU_FLAGS " -DTARGET_TVOS") + elseif(HOST_MACCAT) + string(APPEND ICU_FLAGS " -DTARGET_MACCATALYST") + endif() set(HAVE_SYS_ICU 1) set(STATIC_ICU 1) elseif(HOST_ANDROID) diff --git a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h index 30b3d919e6d18..88026f9ddec48 100644 --- a/src/native/libs/System.Globalization.Native/pal_icushim_internal.h +++ b/src/native/libs/System.Globalization.Native/pal_icushim_internal.h @@ -25,8 +25,7 @@ #include #include #include -#endif -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) +#else #include #include #include diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 773eeb9b811bd..4d35dbe0dcddb 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -60,7 +60,7 @@ static void GetParent(const char* localeID, char* parent, int32_t parentCapacity int32_t i; if (localeID == NULL) - localeID = [NSLocale currentLocale].localeIdentifier.UTF8String; + localeID = [NSLocale systemLocale].localeIdentifier.UTF8String; lastUnderscore = strrchr(localeID, '-'); if (lastUnderscore != NULL) diff --git a/src/tests/FunctionalTests/Directory.Build.props b/src/tests/FunctionalTests/Directory.Build.props index bd0f1c463f6c0..16117373adea2 100644 --- a/src/tests/FunctionalTests/Directory.Build.props +++ b/src/tests/FunctionalTests/Directory.Build.props @@ -5,7 +5,7 @@ true true true - true + true