Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios][HybridGlobalization] Fix default culture #104071

Merged
merged 2 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ public void AdjustScale()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void ConvertToPrecScale()
{
Assert.Equal(new SqlDecimal(6464.6m).Value, SqlDecimal.ConvertToPrecScale(_test1, 5, 1).Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +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.IsHybridGlobalizationOnApplePlatform))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95338", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
[InlineData("ja-JP", 0x0411)] // Japanese - Japan
[InlineData("ar-SA", 0x0401)] // Arabic - Saudi Arabia
[InlineData("de-DE", 0x0407)] // German - Germany
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public SqlStringTest()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void Constructor_Value_Success()
{
const string value = "foo";
Expand Down Expand Up @@ -220,7 +219,6 @@ public void CompareToSqlTypeException()
}

[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInvariantGlobalization))]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void CompareTo()
{
Assert.True(_test1.CompareTo(_test3) < 0);
Expand Down Expand Up @@ -261,7 +259,6 @@ public void CompareTo()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void EqualsMethods()
{
Assert.False(_test1.Equals(_test2));
Expand All @@ -278,7 +275,6 @@ public void EqualsMethods()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void Greaters()
{
// GreateThan ()
Expand All @@ -293,7 +289,6 @@ public void Greaters()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void Lessers()
{
// LessThan()
Expand All @@ -309,7 +304,6 @@ public void Lessers()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void NotEquals()
{
Assert.True(SqlString.NotEquals(_test1, _test2).Value);
Expand All @@ -320,7 +314,6 @@ public void NotEquals()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void Concat()
{
_test1 = new SqlString("First TestString");
Expand All @@ -332,7 +325,6 @@ public void Concat()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void Clone()
{
SqlString testSqlString = _test1.Clone();
Expand All @@ -352,7 +344,6 @@ public void CompareOptionsFromSqlCompareOptions()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void UnicodeBytes()
{
Assert.Equal((byte)105, _test1.GetNonUnicodeBytes()[1]);
Expand Down Expand Up @@ -549,7 +540,6 @@ public void Conversions()
// OPERATORS

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void ArithmeticOperators()
{
SqlString testString = new SqlString("...Testing...");
Expand All @@ -558,7 +548,6 @@ public void ArithmeticOperators()
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void ThanOrEqualOperators()
{
// == -operator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ public void CultureName_Set(AssemblyName assemblyName, string originalCultureNam
}

[Fact]
[ActiveIssue("https://github.com/dotnet/runtime/issues/95195", typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
public void CultureName_Set_Invalid_ThrowsCultureNotFoundException()
{
var assemblyName = new AssemblyName("Test");
Expand Down
12 changes: 10 additions & 2 deletions src/native/libs/System.Globalization.Native/pal_locale.m
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,21 @@ 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
{
if (NSLocale.preferredLanguages.count > 0)
{
return strdup([NSLocale.preferredLanguages[0] UTF8String]);
NSString *preferredLanguage = [NSLocale.preferredLanguages objectAtIndex:0];
return strdup([GetBaseName(preferredLanguage) UTF8String]);
mkhamoyan marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Expand All @@ -813,7 +821,7 @@ int32_t GlobalizationNative_GetLocalesNative(UChar* value, int32_t length)
localeName = currentLocale.localeIdentifier;
}

return strdup([localeName UTF8String]);
return strdup([GetBaseName(localeName) UTF8String]);
}
}
}
Expand Down
Loading