From 6bfeca10e18573d2ca79ab0c364a6b9b3c054e99 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 12 Jul 2023 14:26:24 -0700 Subject: [PATCH 1/5] Use macos12 machines in official build Scout out macos 12 images in official build only. --- eng/pipelines/common/xplat-setup.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/pipelines/common/xplat-setup.yml b/eng/pipelines/common/xplat-setup.yml index c1a4e1f8a8c6f..d6b8d260f95e7 100644 --- a/eng/pipelines/common/xplat-setup.yml +++ b/eng/pipelines/common/xplat-setup.yml @@ -146,10 +146,13 @@ jobs: name: $(DncEngInternalBuildPool) demands: ImageOverride -equals Build.Ubuntu.1804.Amd64 - # OSX Build Pool (we don't have on-prem OSX BuildPool - ${{ if in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator') }}: + # OSX Build Pool (we don't have on-prem OSX BuildPool). Use 11 on public, 12 on internal. + ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), eq(variables['System.TeamProject'], 'public')) }}: vmImage: 'macos-11' + ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), ne(variables['System.TeamProject'], 'public')) }}: + vmImage: 'macos-12' + # Official Build Windows Pool ${{ if and(or(eq(parameters.osGroup, 'windows'), eq(parameters.jobParameters.hostedOs, 'windows')), ne(variables['System.TeamProject'], 'public')) }}: name: $(DncEngInternalBuildPool) From be58950b06bab8eb5e94b4dd2d3285e13ac5e116 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 12 Jul 2023 14:27:27 -0700 Subject: [PATCH 2/5] Temporarily use 12 in PR Temporarily use macos12 in PR to check that everything works. --- eng/pipelines/common/xplat-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/xplat-setup.yml b/eng/pipelines/common/xplat-setup.yml index d6b8d260f95e7..d54620d67a812 100644 --- a/eng/pipelines/common/xplat-setup.yml +++ b/eng/pipelines/common/xplat-setup.yml @@ -148,7 +148,7 @@ jobs: # OSX Build Pool (we don't have on-prem OSX BuildPool). Use 11 on public, 12 on internal. ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), eq(variables['System.TeamProject'], 'public')) }}: - vmImage: 'macos-11' + vmImage: 'macos-12' ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), ne(variables['System.TeamProject'], 'public')) }}: vmImage: 'macos-12' From 8c3ce7dcc1ae4bf8df31427cdfafe18b479f83e0 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 12 Jul 2023 15:52:07 -0700 Subject: [PATCH 3/5] Fix warnings on macos 12 --- .../System.Globalization.Native/pal_locale.m | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 7856a8cb6728f..fa33e1963bb92 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -13,7 +13,7 @@ { NSLocale *currentLocale = [NSLocale currentLocale]; NSString *localeName = @""; - + if (!currentLocale) { return strdup([localeName UTF8String]); @@ -27,7 +27,7 @@ { localeName = currentLocale.localeIdentifier; } - + return strdup([localeName UTF8String]); } @@ -143,7 +143,7 @@ case LocaleString_MonetaryThousandSeparator: case LocaleString_Iso639LanguageThreeLetterName: case LocaleString_ParentName: - case LocaleString_Iso3166CountryName2: + case LocaleString_Iso3166CountryName2: default: value = ""; break; @@ -169,14 +169,14 @@ Returns a numeric string pattern in a format that we can match against the appropriate managed pattern. Examples: For PositiveMonetaryNumberFormat "ยค#,##0.00" becomes "Cn" -For NegativeNumberFormat "#,##0.00;(#,##0.00)" becomes "(n)" +For NegativeNumberFormat "#,##0.00;(#,##0.00)" becomes "(n)" */ static char* NormalizeNumericPattern(const char* srcPattern, int isNegative) { int iStart = 0; int iEnd = strlen(srcPattern); - // ';' separates positive and negative subpatterns. + // ';' separates positive and negative subpatterns. // When there is no explicit negative subpattern, // an implicit negative subpattern is formed from the positive pattern with a prefixed '-'. char * ptrNegativePattern = strrchr(srcPattern,';'); @@ -328,7 +328,7 @@ static int GetPatternIndex(char* normalizedPattern,const char* patterns[], int p static int32_t GetValueForNumberFormat(NSLocale *currentLocale, LocaleNumberData localeNumberData) { - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; numberFormatter.locale = currentLocale; const char *pFormat; int32_t value; @@ -390,7 +390,9 @@ static int32_t GetValueForNumberFormat(NSLocale *currentLocale, LocaleNumberData int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData) { +#if !NDEBUG bool isSuccess = true; +#endif int32_t value; NSString *locName = [NSString stringWithFormat:@"%s", localeName]; NSLocale *currentLocale = [[NSLocale alloc] initWithLocaleIdentifier:locName]; @@ -402,12 +404,12 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local const char *measurementSystem = [[currentLocale objectForKey:NSLocaleMeasurementSystem] UTF8String]; NSLocale *usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; const char *us_measurementSystem = [[usLocale objectForKey:NSLocaleMeasurementSystem] UTF8String]; - value = (measurementSystem == us_measurementSystem) ? 1 : 0; + value = (measurementSystem == us_measurementSystem) ? 1 : 0; break; } case LocaleNumber_FractionalDigitsCount: { - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; numberFormatter.locale = currentLocale; numberFormatter.numberStyle = NSNumberFormatterDecimalStyle; value = (int32_t)numberFormatter.maximumFractionDigits; @@ -415,12 +417,12 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local } case LocaleNumber_MonetaryFractionalDigitsCount: { - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; numberFormatter.locale = currentLocale; numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle; value = (int32_t)numberFormatter.maximumFractionDigits; break; - } + } case LocaleNumber_PositiveMonetaryNumberFormat: case LocaleNumber_NegativeMonetaryNumberFormat: case LocaleNumber_NegativeNumberFormat: @@ -428,10 +430,12 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local case LocaleNumber_PositivePercentFormat: { value = GetValueForNumberFormat(currentLocale, localeNumberData); +#if !NDEBUG if (value < 0) { isSuccess = false; } +#endif break; } case LocaleNumber_FirstWeekOfYear: @@ -451,12 +455,14 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local value = WeekRule_FirstFourDayWeek; } else - { + { value = -1; +#if !NDEBUG isSuccess = false; +#endif } break; - } + } case LocaleNumber_ReadingLayout: { NSLocaleLanguageDirection langDir = [NSLocale characterDirectionForLanguage:[currentLocale objectForKey:NSLocaleLanguageCode]]; @@ -473,7 +479,9 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local } default: value = -1; +#if !NDEBUG isSuccess = false; +#endif break; } @@ -490,11 +498,10 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local */ int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative(const char* localeName, LocaleNumberData localeGroupingData) { - bool isSuccess = true; NSString *locName = [NSString stringWithFormat:@"%s", localeName]; NSLocale *currentLocale = [[NSLocale alloc] initWithLocaleIdentifier:locName]; - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; - numberFormatter.locale = currentLocale; + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; + numberFormatter.locale = currentLocale; switch (localeGroupingData) { @@ -505,11 +512,10 @@ int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative(const char* l numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle; break; default: - isSuccess = false; - assert(isSuccess); + assert(false); break; } - return [numberFormatter groupingSize]; + return [numberFormatter groupingSize]; } /* @@ -520,11 +526,10 @@ int32_t GlobalizationNative_GetLocaleInfoPrimaryGroupingSizeNative(const char* l */ int32_t GlobalizationNative_GetLocaleInfoSecondaryGroupingSizeNative(const char* localeName, LocaleNumberData localeGroupingData) { - bool isSuccess = true; NSString *locName = [NSString stringWithFormat:@"%s", localeName]; NSLocale *currentLocale = [[NSLocale alloc] initWithLocaleIdentifier:locName]; - NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; - numberFormatter.locale = currentLocale; + NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init]; + numberFormatter.locale = currentLocale; switch (localeGroupingData) { @@ -535,8 +540,7 @@ int32_t GlobalizationNative_GetLocaleInfoSecondaryGroupingSizeNative(const char* numberFormatter.numberStyle = NSNumberFormatterCurrencyStyle; break; default: - isSuccess = false; - assert(isSuccess); + assert(false); break; } From 5dbf79037ff28f75e17b014d68fb5e25b327b868 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 12 Jul 2023 16:53:07 -0700 Subject: [PATCH 4/5] Go back to 11 on public --- eng/pipelines/common/xplat-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/common/xplat-setup.yml b/eng/pipelines/common/xplat-setup.yml index d54620d67a812..d6b8d260f95e7 100644 --- a/eng/pipelines/common/xplat-setup.yml +++ b/eng/pipelines/common/xplat-setup.yml @@ -148,7 +148,7 @@ jobs: # OSX Build Pool (we don't have on-prem OSX BuildPool). Use 11 on public, 12 on internal. ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), eq(variables['System.TeamProject'], 'public')) }}: - vmImage: 'macos-12' + vmImage: 'macos-11' ${{ if and(in(parameters.osGroup, 'osx', 'maccatalyst', 'ios', 'iossimulator', 'tvos', 'tvossimulator'), ne(variables['System.TeamProject'], 'public')) }}: vmImage: 'macos-12' From 043ab629c7726320c92e892d1aae776d849502a4 Mon Sep 17 00:00:00 2001 From: Andy Gocke Date: Wed, 12 Jul 2023 16:58:59 -0700 Subject: [PATCH 5/5] Use ifndef instead of if \! --- src/native/libs/System.Globalization.Native/pal_locale.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index fa33e1963bb92..fb4e2ab9db7e4 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -390,7 +390,7 @@ static int32_t GetValueForNumberFormat(NSLocale *currentLocale, LocaleNumberData int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, LocaleNumberData localeNumberData) { -#if !NDEBUG +#ifndef NDEBUG bool isSuccess = true; #endif int32_t value; @@ -430,7 +430,7 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local case LocaleNumber_PositivePercentFormat: { value = GetValueForNumberFormat(currentLocale, localeNumberData); -#if !NDEBUG +#ifndef NDEBUG if (value < 0) { isSuccess = false; @@ -457,7 +457,7 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local else { value = -1; -#if !NDEBUG +#ifndef NDEBUG isSuccess = false; #endif } @@ -479,7 +479,7 @@ int32_t GlobalizationNative_GetLocaleInfoIntNative(const char* localeName, Local } default: value = -1; -#if !NDEBUG +#ifndef NDEBUG isSuccess = false; #endif break;