diff --git a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs index 9c34a6a128a873..f7fa352690c3f4 100644 --- a/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs +++ b/src/libraries/System.Runtime/tests/System.Globalization.Tests/CultureInfo/CultureInfoCurrentCulture.cs @@ -44,6 +44,15 @@ public void CurrentCulture_Default_Not_Invariant() Assert.NotEqual(CultureInfo.CurrentUICulture, CultureInfo.InvariantCulture); } + [Fact] + [PlatformSpecific(TestPlatforms.OSX | TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS)] + [SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS, "https://github.com/dotnet/runtime/issues/111501")] + public void CurrentCulture_Default_Is_Specific() + { + // On OSX-like platforms, the current culture taken from default system culture should be specific. + Assert.False(CultureInfo.CurrentCulture.IsNeutralCulture); + } + [Fact] public void CurrentCulture_Set_Null_ThrowsArgumentNullException() { diff --git a/src/native/libs/System.Globalization.Native/pal_locale.m b/src/native/libs/System.Globalization.Native/pal_locale.m index 6d13c807bec95d..a26cc318f14613 100644 --- a/src/native/libs/System.Globalization.Native/pal_locale.m +++ b/src/native/libs/System.Globalization.Native/pal_locale.m @@ -786,13 +786,6 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) } } -static NSString* GetBaseName(NSString *localeIdentifier) -{ - NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:localeIdentifier]; - NSString *languageCode = [locale objectForKey:NSLocaleLanguageCode]; - return languageCode; -} - const char* GlobalizationNative_GetDefaultLocaleNameNative(void) { @autoreleasepool @@ -800,7 +793,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) if (NSLocale.preferredLanguages.count > 0) { NSString *preferredLanguage = [NSLocale.preferredLanguages objectAtIndex:0]; - return strdup([GetBaseName(preferredLanguage) UTF8String]); + return strdup([preferredLanguage UTF8String]); } else { @@ -821,7 +814,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length) localeName = currentLocale.localeIdentifier; } - return strdup([GetBaseName(localeName) UTF8String]); + return strdup([localeName UTF8String]); } } }