From b96b9f14825efc918387e3377bf6de30ae3510c7 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 9 Jan 2024 14:59:29 +0100 Subject: [PATCH 1/9] Inlcude all symbols for Globalization --- src/mono/mono/mini/CMakeLists.txt | 1 + .../CMakeLists.txt | 1 + .../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 | 346 ++++++++++++++++++ .../pal_timeZoneInfo.h | 3 +- 12 files changed, 357 insertions(+), 18 deletions(-) create mode 100644 src/native/libs/System.Globalization.Native/pal_placeholders.c diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 609765da38e359..81c66742b8e4f5 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -80,6 +80,7 @@ endif() if (TARGET_DARWIN) set(icu_shim_darwin_sources_base + pal_placeholders.c pal_locale.m pal_collation.m pal_casing.m diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index fabfedd61b84b8..9458d2b91f2cf0 100644 --- a/src/native/libs/System.Globalization.Native/CMakeLists.txt +++ b/src/native/libs/System.Globalization.Native/CMakeLists.txt @@ -115,6 +115,7 @@ if (CLR_CMAKE_TARGET_APPLE) add_definitions(-DTARGET_MACCATALYST) endif() set(NATIVEGLOBALIZATION_SOURCES_OBJC + pal_placeholders.c pal_locale.m pal_collation.m pal_casing.m diff --git a/src/native/libs/System.Globalization.Native/entrypoints.c b/src/native/libs/System.Globalization.Native/entrypoints.c index cb3b845b8861a7..0883c5c08dc0ea 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 3abd02446b317f..cc0116b7e86ec9 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 cf006b4387faaf..088153ffa489b4 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 4f86ac11e64bf2..c9bde6cab0f198 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 3249ff15176da4..e52cc62fde71ad 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 2fef6b294673c7..495d1114ec6ca9 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 cfa3e1575f8919..5698a6a49c1b0d 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 44b937e35075ca..50d9ef7d706c51 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 00000000000000..83b315366c2dd7 --- /dev/null +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -0,0 +1,346 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#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" + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wunused-parameter" +#pragma clang diagnostic ignored "-Wunused-command-line-argument" +// Placeholder for calendar data +int32_t GlobalizationNative_GetCalendars( + const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity) +{ + // Use parameters as unused to avoid compiler warnings + (void)localeName; + (void)calendars; + (void)calendarsCapacity; + return 1; +} + +ResultCode GlobalizationNative_GetCalendarInfo( + const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, UChar* result, int32_t resultCapacity) +{ + (void)localeName; + (void)calendarId; + (void)dataType; + (void)result; + (void)resultCapacity; + return Success; +} + +int32_t GlobalizationNative_EnumCalendarInfo( + EnumCalendarInfoCallback callback, const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, const void* context) +{ + (void)callback; + (void)localeName; + (void)calendarId; + (void)dataType; + (void)context; + return 1; +} + +int32_t GlobalizationNative_GetLatestJapaneseEra(void) +{ + return 1; +} + +int32_t GlobalizationNative_GetJapaneseEraStartDate( + int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay) +{ + (void)era; + (void)startYear; + (void)startMonth; + (void)startDay; + return 1; +} + +// Placeholder for casing data +void GlobalizationNative_ChangeCase( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + (void)lpSrc; + (void)cwSrcLength; + (void)lpDst; + (void)cwDstLength; + (void)bToUpper; +} + +void GlobalizationNative_ChangeCaseInvariant( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + (void)lpSrc; + (void)cwSrcLength; + (void)lpDst; + (void)cwDstLength; + (void)bToUpper; +} + +void GlobalizationNative_ChangeCaseTurkish( + const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) +{ + (void)lpSrc; + (void)cwSrcLength; + (void)lpDst; + (void)cwDstLength; + (void)bToUpper; +} + +// Placeholder for collation data +ResultCode GlobalizationNative_GetSortHandle( + const char* lpLocaleName, SortHandle** pSortHandle) +{ + (void)lpLocaleName; + (void)pSortHandle; + return Success; +} + +void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle) +{ + (void)pSortHandle; +} + +int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle) +{ + (void)pSortHandle; + return 1; +} + +int32_t GlobalizationNative_CompareString( + SortHandle* pSortHandle, const UChar* lpStr1, int32_t cwStr1Length, const UChar* lpStr2, int32_t cwStr2Length, int32_t options) +{ + (void)pSortHandle; + (void)lpStr1; + (void)cwStr1Length; + (void)lpStr2; + (void)cwStr2Length; + (void)options; + return 1; +} + +int32_t GlobalizationNative_IndexOf( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + (void)pSortHandle; + (void)lpTarget; + (void)cwTargetLength; + (void)lpSource; + (void)cwSourceLength; + (void)options; + (void)pMatchedLength; + return 1; +} + +int32_t GlobalizationNative_LastIndexOf( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + (void)pSortHandle; + (void)lpTarget; + (void)cwTargetLength; + (void)lpSource; + (void)cwSourceLength; + (void)options; + (void)pMatchedLength; + return 1; +} + +int32_t GlobalizationNative_StartsWith( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + (void)pSortHandle; + (void)lpTarget; + (void)cwTargetLength; + (void)lpSource; + (void)cwSourceLength; + (void)options; + (void)pMatchedLength; + return 1; +} + +int32_t GlobalizationNative_EndsWith( + SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) +{ + (void)pSortHandle; + (void)lpTarget; + (void)cwTargetLength; + (void)lpSource; + (void)cwSourceLength; + (void)options; + (void)pMatchedLength; + return 1; +} + +int32_t GlobalizationNative_GetSortKey( + SortHandle* pSortHandle, const UChar* lpStr, int32_t cwStrLength, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) +{ + (void)pSortHandle; + (void)lpStr; + (void)cwStrLength; + (void)sortKey; + (void)cbSortKeyLength; + (void)options; + return 1; +} + +// Placeholder for locale data +int32_t GlobalizationNative_GetLocales( + UChar *value, int32_t valueLength) +{ + (void)value; + (void)valueLength; + return 1; +} + +int32_t GlobalizationNative_GetLocaleName( + const UChar* localeName, UChar* value, int32_t valueLength) +{ + (void)localeName; + (void)value; + (void)valueLength; + return 1; +} + +int32_t GlobalizationNative_GetDefaultLocaleName( + UChar* value, int32_t valueLength) +{ + (void)value; + (void)valueLength; + return 1; +} + +int32_t GlobalizationNative_IsPredefinedLocale( + const UChar* localeName) +{ + (void)localeName; + return 1; +} + +int32_t GlobalizationNative_GetLocaleTimeFormat( + const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength) +{ + (void)localeName; + (void)shortFormat; + (void)value; + (void)valueLength; + return 1; +} + +// Placeholder for locale number data +int32_t GlobalizationNative_GetLocaleInfoInt( + const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value) +{ + (void)localeName; + (void)localeNumberData; + (void)value; + return 1; +} + +int32_t GlobalizationNative_GetLocaleInfoGroupingSizes( + const UChar* localeName, LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize) +{ + (void)localeName; + (void)localeGroupingData; + (void)primaryGroupSize; + (void)secondaryGroupSize; + return 1; +} + +// Placeholder for icu shim data +int32_t GlobalizationNative_LoadICU(void) +{ + return 1; +} + +void GlobalizationNative_InitICUFunctions( + void* icuuc, void* icuin, const char* version, const char* suffix) +{ + (void)icuuc; + (void)icuin; + (void)version; + (void)suffix; +} + +int32_t GlobalizationNative_GetICUVersion(void) +{ + return 1; +} + +int32_t +GlobalizationNative_LoadICUData(const char* path) +{ + (void)path; + return 1; +} + +// Placeholder for locale string data +int32_t GlobalizationNative_GetLocaleInfoString( + const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName) +{ + (void)localeName; + (void)localeStringData; + (void)value; + (void)valueLength; + (void)uiLocaleName; + return 1; +} + +//Placeholder for normalization data +int32_t GlobalizationNative_IsNormalized( + NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength) +{ + (void)normalizationForm; + (void)lpStr; + (void)cwStrLength; + return 1; +} + +int32_t GlobalizationNative_NormalizeString( + NormalizationForm normalizationForm, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength) +{ + (void)normalizationForm; + (void)lpSrc; + (void)cwSrcLength; + (void)lpDst; + (void)cwDstLength; + return 1; +} + +// Placeholder for time zone data +int32_t GlobalizationNative_WindowsIdToIanaId( + const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength) +{ + (void)windowsId; + (void)region; + (void)ianaId; + (void)ianaIdLength; + return 1; +} + +ResultCode GlobalizationNative_GetTimeZoneDisplayName( + const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength) +{ + (void)localeName; + (void)timeZoneId; + (void)type; + (void)result; + (void)resultLength; + return Success; +} + +int32_t GlobalizationNative_IanaIdToWindowsId( + const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength) +{ + (void)ianaId; + (void)windowsId; + (void)windowsIdLength; + return 1; +} +#pragma clang diagnostic pop diff --git a/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h b/src/native/libs/System.Globalization.Native/pal_timeZoneInfo.h index 1bf1fe98f99363..86d438ef96e8e1 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 From ea9731d3030be4e983746345285c839ec0de8588 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 9 Jan 2024 15:27:38 +0100 Subject: [PATCH 2/9] Fix build failure --- src/mono/mono/mini/CMakeLists.txt | 8 +- .../CMakeLists.txt | 8 +- .../pal_placeholders.c | 132 +----------------- 3 files changed, 15 insertions(+), 133 deletions(-) diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index 81c66742b8e4f5..3628dd3a19de26 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -76,11 +76,17 @@ 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) set(icu_shim_darwin_sources_base - pal_placeholders.c pal_locale.m pal_collation.m pal_casing.m diff --git a/src/native/libs/System.Globalization.Native/CMakeLists.txt b/src/native/libs/System.Globalization.Native/CMakeLists.txt index 9458d2b91f2cf0..ce361a2b03527c 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) @@ -115,7 +122,6 @@ if (CLR_CMAKE_TARGET_APPLE) add_definitions(-DTARGET_MACCATALYST) endif() set(NATIVEGLOBALIZATION_SOURCES_OBJC - pal_placeholders.c pal_locale.m pal_collation.m pal_casing.m diff --git a/src/native/libs/System.Globalization.Native/pal_placeholders.c b/src/native/libs/System.Globalization.Native/pal_placeholders.c index 83b315366c2dd7..f2b6f600a18e0c 100644 --- a/src/native/libs/System.Globalization.Native/pal_placeholders.c +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -12,39 +12,22 @@ #include "pal_normalization.h" #include "pal_timeZoneInfo.h" -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunused-parameter" -#pragma clang diagnostic ignored "-Wunused-command-line-argument" // Placeholder for calendar data int32_t GlobalizationNative_GetCalendars( const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity) { - // Use parameters as unused to avoid compiler warnings - (void)localeName; - (void)calendars; - (void)calendarsCapacity; return 1; } ResultCode GlobalizationNative_GetCalendarInfo( const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, UChar* result, int32_t resultCapacity) { - (void)localeName; - (void)calendarId; - (void)dataType; - (void)result; - (void)resultCapacity; return Success; } int32_t GlobalizationNative_EnumCalendarInfo( EnumCalendarInfoCallback callback, const UChar* localeName, CalendarId calendarId, CalendarDataType dataType, const void* context) { - (void)callback; - (void)localeName; - (void)calendarId; - (void)dataType; - (void)context; return 1; } @@ -56,10 +39,6 @@ int32_t GlobalizationNative_GetLatestJapaneseEra(void) int32_t GlobalizationNative_GetJapaneseEraStartDate( int32_t era, int32_t* startYear, int32_t* startMonth, int32_t* startDay) { - (void)era; - (void)startYear; - (void)startMonth; - (void)startDay; return 1; } @@ -67,126 +46,67 @@ int32_t GlobalizationNative_GetJapaneseEraStartDate( void GlobalizationNative_ChangeCase( const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) { - (void)lpSrc; - (void)cwSrcLength; - (void)lpDst; - (void)cwDstLength; - (void)bToUpper; } void GlobalizationNative_ChangeCaseInvariant( const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) { - (void)lpSrc; - (void)cwSrcLength; - (void)lpDst; - (void)cwDstLength; - (void)bToUpper; } void GlobalizationNative_ChangeCaseTurkish( const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength, int32_t bToUpper) { - (void)lpSrc; - (void)cwSrcLength; - (void)lpDst; - (void)cwDstLength; - (void)bToUpper; } // Placeholder for collation data ResultCode GlobalizationNative_GetSortHandle( const char* lpLocaleName, SortHandle** pSortHandle) { - (void)lpLocaleName; - (void)pSortHandle; return Success; } -void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle) +void GlobalizationNative_CloseSortHandle(SortHandle* pSortHandle) { - (void)pSortHandle; } int32_t GlobalizationNative_GetSortVersion(SortHandle* pSortHandle) { - (void)pSortHandle; return 1; } int32_t GlobalizationNative_CompareString( SortHandle* pSortHandle, const UChar* lpStr1, int32_t cwStr1Length, const UChar* lpStr2, int32_t cwStr2Length, int32_t options) { - (void)pSortHandle; - (void)lpStr1; - (void)cwStr1Length; - (void)lpStr2; - (void)cwStr2Length; - (void)options; return 1; } int32_t GlobalizationNative_IndexOf( SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) { - (void)pSortHandle; - (void)lpTarget; - (void)cwTargetLength; - (void)lpSource; - (void)cwSourceLength; - (void)options; - (void)pMatchedLength; return 1; } int32_t GlobalizationNative_LastIndexOf( SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) { - (void)pSortHandle; - (void)lpTarget; - (void)cwTargetLength; - (void)lpSource; - (void)cwSourceLength; - (void)options; - (void)pMatchedLength; return 1; } int32_t GlobalizationNative_StartsWith( SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) { - (void)pSortHandle; - (void)lpTarget; - (void)cwTargetLength; - (void)lpSource; - (void)cwSourceLength; - (void)options; - (void)pMatchedLength; return 1; } int32_t GlobalizationNative_EndsWith( SortHandle* pSortHandle, const UChar* lpTarget, int32_t cwTargetLength, const UChar* lpSource, int32_t cwSourceLength, int32_t options, int32_t* pMatchedLength) { - (void)pSortHandle; - (void)lpTarget; - (void)cwTargetLength; - (void)lpSource; - (void)cwSourceLength; - (void)options; - (void)pMatchedLength; return 1; } int32_t GlobalizationNative_GetSortKey( SortHandle* pSortHandle, const UChar* lpStr, int32_t cwStrLength, uint8_t* sortKey, int32_t cbSortKeyLength, int32_t options) { - (void)pSortHandle; - (void)lpStr; - (void)cwStrLength; - (void)sortKey; - (void)cbSortKeyLength; - (void)options; return 1; } @@ -194,42 +114,30 @@ int32_t GlobalizationNative_GetSortKey( int32_t GlobalizationNative_GetLocales( UChar *value, int32_t valueLength) { - (void)value; - (void)valueLength; return 1; } int32_t GlobalizationNative_GetLocaleName( const UChar* localeName, UChar* value, int32_t valueLength) { - (void)localeName; - (void)value; - (void)valueLength; return 1; } int32_t GlobalizationNative_GetDefaultLocaleName( UChar* value, int32_t valueLength) { - (void)value; - (void)valueLength; return 1; } int32_t GlobalizationNative_IsPredefinedLocale( const UChar* localeName) { - (void)localeName; return 1; } int32_t GlobalizationNative_GetLocaleTimeFormat( const UChar* localeName, int shortFormat, UChar* value, int32_t valueLength) { - (void)localeName; - (void)shortFormat; - (void)value; - (void)valueLength; return 1; } @@ -237,19 +145,12 @@ int32_t GlobalizationNative_GetLocaleTimeFormat( int32_t GlobalizationNative_GetLocaleInfoInt( const UChar* localeName, LocaleNumberData localeNumberData, int32_t* value) { - (void)localeName; - (void)localeNumberData; - (void)value; return 1; } int32_t GlobalizationNative_GetLocaleInfoGroupingSizes( const UChar* localeName, LocaleNumberData localeGroupingData, int32_t* primaryGroupSize, int32_t* secondaryGroupSize) { - (void)localeName; - (void)localeGroupingData; - (void)primaryGroupSize; - (void)secondaryGroupSize; return 1; } @@ -262,10 +163,6 @@ int32_t GlobalizationNative_LoadICU(void) void GlobalizationNative_InitICUFunctions( void* icuuc, void* icuin, const char* version, const char* suffix) { - (void)icuuc; - (void)icuin; - (void)version; - (void)suffix; } int32_t GlobalizationNative_GetICUVersion(void) @@ -276,7 +173,6 @@ int32_t GlobalizationNative_GetICUVersion(void) int32_t GlobalizationNative_LoadICUData(const char* path) { - (void)path; return 1; } @@ -284,11 +180,6 @@ GlobalizationNative_LoadICUData(const char* path) int32_t GlobalizationNative_GetLocaleInfoString( const UChar* localeName, LocaleStringData localeStringData, UChar* value, int32_t valueLength, const UChar* uiLocaleName) { - (void)localeName; - (void)localeStringData; - (void)value; - (void)valueLength; - (void)uiLocaleName; return 1; } @@ -296,20 +187,12 @@ int32_t GlobalizationNative_GetLocaleInfoString( int32_t GlobalizationNative_IsNormalized( NormalizationForm normalizationForm, const UChar* lpStr, int32_t cwStrLength) { - (void)normalizationForm; - (void)lpStr; - (void)cwStrLength; return 1; } int32_t GlobalizationNative_NormalizeString( NormalizationForm normalizationForm, const UChar* lpSrc, int32_t cwSrcLength, UChar* lpDst, int32_t cwDstLength) { - (void)normalizationForm; - (void)lpSrc; - (void)cwSrcLength; - (void)lpDst; - (void)cwDstLength; return 1; } @@ -317,30 +200,17 @@ int32_t GlobalizationNative_NormalizeString( int32_t GlobalizationNative_WindowsIdToIanaId( const UChar* windowsId, const char* region, UChar* ianaId, int32_t ianaIdLength) { - (void)windowsId; - (void)region; - (void)ianaId; - (void)ianaIdLength; return 1; } ResultCode GlobalizationNative_GetTimeZoneDisplayName( const UChar* localeName, const UChar* timeZoneId, TimeZoneDisplayNameType type, UChar* result, int32_t resultLength) { - (void)localeName; - (void)timeZoneId; - (void)type; - (void)result; - (void)resultLength; return Success; } int32_t GlobalizationNative_IanaIdToWindowsId( const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength) { - (void)ianaId; - (void)windowsId; - (void)windowsIdLength; return 1; } -#pragma clang diagnostic pop From 6c0b048e5f1f4eab9e86af23f6e7d23f0d6d80c0 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Tue, 9 Jan 2024 17:28:31 +0100 Subject: [PATCH 3/9] Merge with main and mark as known issue ICU_Casing_Invariant --- .../tests/System.Runtime.Tests/System/Text/RuneTests.cs | 1 + 1 file changed, 1 insertion(+) 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 01f43253dcf577..82611495e694b1 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); From f301a899202d656c237394e48c9eee1688d650a6 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 9 Jan 2024 16:39:47 -0500 Subject: [PATCH 4/9] Skip IcuShouldNotBeLoaded test --- .../tests/System.Globalization.Tests/Invariant/InvariantMode.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs index 287de904ae8be7..8cd249c186d8a4 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs @@ -559,6 +559,7 @@ public static IEnumerable GetUnicode_TestData() } [ConditionalFact(nameof(PredefinedCulturesOnlyIsDisabled))] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "We are using the system icu and not loading it directly on these platforms")] public static void IcuShouldNotBeLoaded() { Assert.False(PlatformDetection.IsIcuGlobalization); From 3d421dfa2e3e86835620b530c11f88af1392197f Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 9 Jan 2024 22:10:02 -0500 Subject: [PATCH 5/9] Revert disabling test and make sure IsIcuGlobalization is false for invariant mode --- .../Common/tests/TestUtilities/System/PlatformDetection.cs | 2 +- .../tests/System.Globalization.Tests/Invariant/InvariantMode.cs | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index f3a8aae9b38fd6..e92715cd6da26e 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -386,7 +386,7 @@ 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); + public static bool IsIcuGlobalization => !IsInvariantGlobalization && 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; diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs index 8cd249c186d8a4..287de904ae8be7 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/Invariant/InvariantMode.cs @@ -559,7 +559,6 @@ public static IEnumerable GetUnicode_TestData() } [ConditionalFact(nameof(PredefinedCulturesOnlyIsDisabled))] - [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "We are using the system icu and not loading it directly on these platforms")] public static void IcuShouldNotBeLoaded() { Assert.False(PlatformDetection.IsIcuGlobalization); From 1163d12de97ee0a51e9a7d5bfd62ad98dfbfcdd2 Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 9 Jan 2024 22:24:25 -0500 Subject: [PATCH 6/9] Add asserts to placeholders --- .../TestUtilities/System/PlatformDetection.cs | 5 +- .../pal_placeholders.c | 92 +++++++++++++------ 2 files changed, 67 insertions(+), 30 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index e92715cd6da26e..66ec9abd843930 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 => !IsInvariantGlobalization && 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; diff --git a/src/native/libs/System.Globalization.Native/pal_placeholders.c b/src/native/libs/System.Globalization.Native/pal_placeholders.c index f2b6f600a18e0c..e9306877e5f054 100644 --- a/src/native/libs/System.Globalization.Native/pal_placeholders.c +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -16,201 +16,235 @@ int32_t GlobalizationNative_GetCalendars( const UChar* localeName, CalendarId* calendars, int32_t calendarsCapacity) { - return 1; + 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) { - return Success; + 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) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } int32_t GlobalizationNative_GetLatestJapaneseEra(void) { - return 1; + 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) { - return 1; + 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) { - return Success; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } // Placeholder for locale data int32_t GlobalizationNative_GetLocales( UChar *value, int32_t valueLength) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } int32_t GlobalizationNative_GetLocaleName( const UChar* localeName, UChar* value, int32_t valueLength) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } int32_t GlobalizationNative_GetDefaultLocaleName( UChar* value, int32_t valueLength) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } int32_t GlobalizationNative_IsPredefinedLocale( const UChar* localeName) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } // Placeholder for icu shim data int32_t GlobalizationNative_LoadICU(void) { - return 1; + 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) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } int32_t GlobalizationNative_LoadICUData(const char* path) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return 1; + 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) { - return Success; + assert_msg(false, "Not supported on this platform", 0); + return UnknownError; } int32_t GlobalizationNative_IanaIdToWindowsId( const UChar* ianaId, UChar* windowsId, int32_t windowsIdLength) { - return 1; + assert_msg(false, "Not supported on this platform", 0); + return 0; } From f5cce9ba096afa85487027b2bfacedac6b8fd17c Mon Sep 17 00:00:00 2001 From: Steve Pfister Date: Tue, 9 Jan 2024 23:14:04 -0500 Subject: [PATCH 7/9] Fix compiler error --- .../pal_placeholders.c | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/native/libs/System.Globalization.Native/pal_placeholders.c b/src/native/libs/System.Globalization.Native/pal_placeholders.c index e9306877e5f054..e813392ac975ec 100644 --- a/src/native/libs/System.Globalization.Native/pal_placeholders.c +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#include + #include "pal_icushim_internal.h" #include "pal_icushim.h" #include "pal_calendarData.h" @@ -12,6 +14,29 @@ #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) From 7d1f15b2d214949bd8b8b6a42dad7135eb87940e Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 10 Jan 2024 08:49:42 +0100 Subject: [PATCH 8/9] Fix compiler error --- src/native/libs/System.Globalization.Native/pal_placeholders.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/native/libs/System.Globalization.Native/pal_placeholders.c b/src/native/libs/System.Globalization.Native/pal_placeholders.c index e813392ac975ec..7d0f9624e082b3 100644 --- a/src/native/libs/System.Globalization.Native/pal_placeholders.c +++ b/src/native/libs/System.Globalization.Native/pal_placeholders.c @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. #include +#include #include "pal_icushim_internal.h" #include "pal_icushim.h" From e5c931a1e3b2b19f096018232f92121da5b01cb5 Mon Sep 17 00:00:00 2001 From: Meri Khamoyan Date: Wed, 10 Jan 2024 10:17:15 +0100 Subject: [PATCH 9/9] Don't call from tests GetICUVersion when hg --- .../TestUtilities/System/PlatformDetection.cs | 24 +++++++++++-------- .../IcuAppLocal/IcuAppLocal.cs | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs index 66ec9abd843930..cc378dcc8872a0 100644 --- a/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs +++ b/src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs @@ -389,7 +389,7 @@ public static string GetDistroVersionString() // 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; @@ -419,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 92355058306af3..2e53286298a844 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));