From 72db600a20d581fdc6776edce1863bcf8da0b1cd Mon Sep 17 00:00:00 2001 From: Meri Khamoyan <96171496+mkhamoyan@users.noreply.github.com> Date: Wed, 10 Jan 2024 17:27:58 +0100 Subject: [PATCH] [HybridGlobalization] Include all globalization symbols (#96684) * Include all symbols for Globalization Co-authored-by: Steve Pfister --- .../TestUtilities/System/PlatformDetection.cs | 27 +- .../IcuAppLocal/IcuAppLocal.cs | 2 +- .../System/Text/RuneTests.cs | 1 + src/mono/mono/mini/CMakeLists.txt | 7 + .../CMakeLists.txt | 7 + .../System.Globalization.Native/entrypoints.c | 3 +- .../pal_calendarData.h | 3 +- .../System.Globalization.Native/pal_casing.h | 3 +- .../pal_collation.h | 3 +- .../System.Globalization.Native/pal_locale.h | 3 +- .../pal_localeNumberData.h | 3 +- .../pal_localeStringData.h | 3 +- .../pal_normalization.h | 3 +- .../pal_placeholders.c | 276 ++++++++++++++++++ .../pal_timeZoneInfo.h | 3 +- 15 files changed, 318 insertions(+), 29 deletions(-) create mode 100644 src/native/libs/System.Globalization.Native/pal_placeholders.c diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index f3a8aae9b38fd..cc378dcc8872a 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -386,7 +386,10 @@ public static string GetDistroVersionString() 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); + + // HG on apple platforms implies ICU + public static bool IsIcuGlobalization => !IsInvariantGlobalization && (IsHybridGlobalizationOnOSX || 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 && !IsHybridGlobalization; @@ -416,22 +419,26 @@ public static bool IsSubstAvailable private static Version GetICUVersion() { int version = 0; - try + // When HG on Apple platforms, our ICU lib is not loaded + if (IsNotHybridGlobalizationOnOSX) { - Type interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib"); - if (interopGlobalization != null) + try { - MethodInfo methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static); - if (methodInfo != null) + Type interopGlobalization = Type.GetType("Interop+Globalization, System.Private.CoreLib"); + if (interopGlobalization != null) { - // Ensure that ICU has been loaded - GC.KeepAlive(System.Globalization.CultureInfo.InstalledUICulture); + MethodInfo methodInfo = interopGlobalization.GetMethod("GetICUVersion", BindingFlags.NonPublic | BindingFlags.Static); + if (methodInfo != null) + { + // Ensure that ICU has been loaded + GC.KeepAlive(System.Globalization.CultureInfo.InstalledUICulture); - version = (int)methodInfo.Invoke(null, null); + version = (int)methodInfo.Invoke(null, null); + } } } + catch { } } - catch { } return new Version(version >> 24, (version >> 16) & 0xFF, diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/IcuAppLocal/IcuAppLocal.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/IcuAppLocal/IcuAppLocal.cs index 92355058306af..2e53286298a84 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/IcuAppLocal/IcuAppLocal.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/IcuAppLocal/IcuAppLocal.cs @@ -10,7 +10,7 @@ namespace System.Globalization.Tests { public class IcuAppLocalTests { - private static bool SupportsIcuPackageDownload => RemoteExecutor.IsSupported && + private static bool SupportsIcuPackageDownload => PlatformDetection.IsNotHybridGlobalizationOnOSX && RemoteExecutor.IsSupported && ((PlatformDetection.IsWindows && !PlatformDetection.IsArmProcess) || (PlatformDetection.IsLinux && (PlatformDetection.IsX64Process || PlatformDetection.IsArm64Process) && !PlatformDetection.IsAlpine && !PlatformDetection.IsLinuxBionic)); diff --git a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs index 01f43253dcf57..82611495e694b 100644 --- a/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs +++ b/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Text/RuneTests.cs @@ -70,6 +70,7 @@ public static void Casing_Invariant(int original, int upper, int lower) [InlineData('\u0131', '\u0131', '\u0131')] // U+0131 LATIN SMALL LETTER DOTLESS I [InlineData(0x10400, 0x10400, 0x10428)] // U+10400 DESERET CAPITAL LETTER LONG I [InlineData(0x10428, 0x10400, 0x10428)] // U+10428 DESERET SMALL LETTER LONG I + [ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnOSX))] public static void ICU_Casing_Invariant(int original, int upper, int lower) { var rune = new Rune(original); diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 609765da38e35..3628dd3a19de2 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -76,6 +76,13 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM ) endif() +if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + set(icu_shim_sources_base + ${icu_shim_sources_base} + pal_placeholders.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 5e9ccb1e8991b..11e8401a0c14e 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -74,6 +74,13 @@ if (NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CM ) endif() +if (CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET_IOS OR CLR_CMAKE_TARGET_TVOS) + set(NATIVEGLOBALIZATION_SOURCES + ${NATIVEGLOBALIZATION_SOURCES} + pal_placeholders.c + ) +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) diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index cb3b845b8861a..0883c5c08dc0e 100644 --- a/src/native/libs/System.Globalization.Native/entrypoints.c +++ b/src/native/libs/System.Globalization.Native/entrypoints.c @@ -19,7 +19,6 @@ typedef uint16_t UChar; static const Entry s_globalizationNative[] = { -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) DllImportEntry(GlobalizationNative_ChangeCase) DllImportEntry(GlobalizationNative_ChangeCaseInvariant) DllImportEntry(GlobalizationNative_ChangeCaseTurkish) @@ -56,7 +55,7 @@ static const Entry s_globalizationNative[] = DllImportEntry(GlobalizationNative_NormalizeString) DllImportEntry(GlobalizationNative_StartsWith) DllImportEntry(GlobalizationNative_WindowsIdToIanaId) -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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 3abd02446b317..cc0116b7e86ec 100644 --- a/src/native/libs/System.Globalization.Native/pal_calendarData.h +++ b/src/native/libs/System.Globalization.Native/pal_calendarData.h @@ -79,7 +79,6 @@ 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)) PALEXPORT int32_t GlobalizationNative_GetCalendars(const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity); @@ -102,7 +101,7 @@ PALEXPORT int32_t GlobalizationNative_GetJapaneseEraStartDate(int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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 cf006b4387faa..088153ffa489b 100644 --- a/src/native/libs/System.Globalization.Native/pal_casing.h +++ b/src/native/libs/System.Globalization.Native/pal_casing.h @@ -6,7 +6,6 @@ PALEXPORT void GlobalizationNative_InitOrdinalCasingPage(int32_t pageNumber, UChar* pTarget); -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT void GlobalizationNative_ChangeCase(const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, @@ -24,7 +23,7 @@ PALEXPORT void GlobalizationNative_ChangeCaseTurkish(const UChar* lpSrc, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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 4f86ac11e64bf..c9bde6cab0f19 100644 --- a/src/native/libs/System.Globalization.Native/pal_collation.h +++ b/src/native/libs/System.Globalization.Native/pal_collation.h @@ -13,7 +13,6 @@ typedef struct _Range { int32_t length; } Range; -#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); @@ -66,7 +65,7 @@ PALEXPORT int32_t GlobalizationNative_GetSortKey(SortHandle* pSortHandle, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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_locale.h b/src/native/libs/System.Globalization.Native/pal_locale.h index 3249ff15176da..e52cc62fde71a 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.h +++ b/src/native/libs/System.Globalization.Native/pal_locale.h @@ -5,7 +5,6 @@ #include "pal_compiler.h" -#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); @@ -17,7 +16,7 @@ PALEXPORT int32_t GlobalizationNative_IsPredefinedLocale(const UChar* localeName PALEXPORT int32_t GlobalizationNative_GetLocaleTimeFormat(const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) 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 2fef6b294673c..495d1114ec6ca 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeNumberData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeNumberData.h @@ -34,7 +34,6 @@ typedef enum WeekRule_FirstFullWeek = 1, WeekRule_FirstFourDayWeek = 2 } CalendarWeekRule; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoInt(const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value); @@ -43,7 +42,7 @@ PALEXPORT int32_t GlobalizationNative_GetLocaleInfoGroupingSizes(const UChar* lo LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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 cfa3e1575f891..5698a6a49c1b0 100644 --- a/src/native/libs/System.Globalization.Native/pal_localeStringData.h +++ b/src/native/libs/System.Globalization.Native/pal_localeStringData.h @@ -43,13 +43,12 @@ typedef enum LocaleString_PercentSymbol = 0x00000076, LocaleString_PerMilleSymbol = 0x00000077 } LocaleStringData; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_GetLocaleInfoString(const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT const char* GlobalizationNative_GetLocaleInfoStringNative(const char* localeName, LocaleStringData localeStringData, const char* currentUILocaleName); #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..50d9ef7d706c5 100644 --- a/src/native/libs/System.Globalization.Native/pal_normalization.h +++ b/src/native/libs/System.Globalization.Native/pal_normalization.h @@ -17,7 +17,6 @@ typedef enum FormKC = 0x5, FormKD = 0x6 } NormalizationForm; -#if !defined(__APPLE__) || (defined(__APPLE__) && !(TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS)) PALEXPORT int32_t GlobalizationNative_IsNormalized(NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength); @@ -27,7 +26,7 @@ PALEXPORT int32_t GlobalizationNative_NormalizeString(NormalizationForm normaliz int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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_placeholders.c b/src/native/libs/System.Globalization.Native/pal_placeholders.c new file mode 100644 index 0000000000000..7d0f9624e082b --- /dev/null +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -0,0 +1,276 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#include +#include + +#include "pal_icushim_internal.h" +#include "pal_icushim.h" +#include "pal_calendarData.h" +#include "pal_casing.h" +#include "pal_collation.h" +#include "pal_locale.h" +#include "pal_localeNumberData.h" +#include "pal_localeStringData.h" +#include "pal_normalization.h" +#include "pal_timeZoneInfo.h" + +#ifdef DEBUG +#define assert_err(cond, msg, err) do \ +{ \ + if(!(cond)) \ + { \ + fprintf(stderr, "%s (%d): error %d: %s. %s (%s failed)\n", __FILE__, __LINE__, err, msg, strerror(err), #cond); \ + assert(false && "assert_err failed"); \ + } \ +} while(0) +#define assert_msg(cond, msg, val) do \ +{ \ + if(!(cond)) \ + { \ + fprintf(stderr, "%s (%d): error %d: %s (%s failed)\n", __FILE__, __LINE__, val, msg, #cond); \ + assert(false && "assert_msg failed"); \ + } \ +} while(0) +#else // DEBUG +#define assert_err(cond, msg, err) +#define assert_msg(cond, msg, val) +#endif // DEBUG + + +// Placeholder for calendar data +int32_t GlobalizationNative_GetCalendars( + const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +ResultCode GlobalizationNative_GetCalendarInfo( + const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, UChar* result, int32_t resultCapacity) +{ + assert_msg(false, "Not supported on this platform", 0); + return UnknownError; +} + +int32_t GlobalizationNative_EnumCalendarInfo( + EnumCalendarInfoCallback callback, const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, const void* context) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetLatestJapaneseEra(void) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetJapaneseEraStartDate( + int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for casing data +void GlobalizationNative_ChangeCase( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + assert_msg(false, "Not supported on this platform", 0); +} + +void GlobalizationNative_ChangeCaseInvariant( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + assert_msg(false, "Not supported on this platform", 0); +} + +void GlobalizationNative_ChangeCaseTurkish( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + assert_msg(false, "Not supported on this platform", 0); +} + +// Placeholder for collation data +ResultCode GlobalizationNative_GetSortHandle( + const char* lpLocaleName, SortHandle** pSortHandle) +{ + assert_msg(false, "Not supported on this platform", 0); + return UnknownError; +} + +void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle) +{ + assert_msg(false, "Not supported on this platform", 0); +} + +int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_CompareString( + SortHandle* pSortHandle, const UChar* lpStr1, int32_t cwStr1Length, const UChar* lpStr2, int32_t cwStr2Length, int32_t options) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_IndexOf( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_LastIndexOf( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_StartsWith( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_EndsWith( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetSortKey( + SortHandle* pSortHandle, const UChar* lpStr, int32_t cwStrLength, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for locale data +int32_t GlobalizationNative_GetLocales( + UChar *value, int32_t valueLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetLocaleName( + const UChar* localeName, UChar* value, int32_t valueLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetDefaultLocaleName( + UChar* value, int32_t valueLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_IsPredefinedLocale( + const UChar* localeName) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetLocaleTimeFormat( + const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for locale number data +int32_t GlobalizationNative_GetLocaleInfoInt( + const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_GetLocaleInfoGroupingSizes( + const UChar* localeName, LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for icu shim data +int32_t GlobalizationNative_LoadICU(void) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +void GlobalizationNative_InitICUFunctions( + void* icuuc, void* icuin, const char* version, const char* suffix) +{ + assert_msg(false, "Not supported on this platform", 0); +} + +int32_t GlobalizationNative_GetICUVersion(void) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t +GlobalizationNative_LoadICUData(const char* path) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for locale string data +int32_t GlobalizationNative_GetLocaleInfoString( + const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +//Placeholder for normalization data +int32_t GlobalizationNative_IsNormalized( + NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +int32_t GlobalizationNative_NormalizeString( + NormalizationForm normalizationForm, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +// Placeholder for time zone data +int32_t GlobalizationNative_WindowsIdToIanaId( + const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} + +ResultCode GlobalizationNative_GetTimeZoneDisplayName( + const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return UnknownError; +} + +int32_t GlobalizationNative_IanaIdToWindowsId( + const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength) +{ + assert_msg(false, "Not supported on this platform", 0); + return 0; +} diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 1bf1fe98f9936..86d438ef96e8e 100644 --- a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h +++ b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h @@ -20,11 +20,10 @@ typedef enum TimeZoneDisplayName_ExemplarCity = 4, TimeZoneDisplayName_TimeZoneName = 5, } TimeZoneDisplayNameType; -#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); -#else +#if (defined(__APPLE__) && (TARGET_MACCATALYST || TARGET_IOS || 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