Skip to content

Commit a491ad7

Browse files
committed
Revert "[wasm] Throw exception if culture data does not exist in icu (dotnet#47301)"
This reverts commit 128c757.
1 parent 1ce676f commit a491ad7

File tree

21 files changed

+416
-472
lines changed

21 files changed

+416
-472
lines changed

src/libraries/Common/tests/Tests/System/StringTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2567,7 +2567,8 @@ public void Equals_Encyclopaedia_ReturnsExpected(StringComparison comparison, bo
25672567
{
25682568
string source = "encyclop\u00e6dia";
25692569
string target = "encyclopaedia";
2570-
using (new ThreadCultureChange(PlatformDetection.IsBrowser ?"pl-PL" : "se-SE"))
2570+
2571+
using (new ThreadCultureChange("se-SE"))
25712572
{
25722573
Assert.Equal(expected, string.Equals(source, target, comparison));
25732574
Assert.Equal(expected, source.AsSpan().Equals(target.AsSpan(), comparison));

src/libraries/System.ComponentModel.TypeConverter/tests/CultureInfoConverterTests.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ public override IEnumerable<ConvertTest> ConvertFromTestData()
3333
yield return ConvertTest.Valid("nl-B", new CultureInfo("nl--B"), CultureInfo.InvariantCulture);
3434
yield return ConvertTest.Valid("nl-B", new CultureInfo("nl--B"), new CultureInfo("en-US"));
3535
}
36-
if (PlatformDetection.IsNotBrowser)
37-
{
38-
yield return ConvertTest.Valid("Afrikaans", new CultureInfo("af"));
39-
}
36+
37+
yield return ConvertTest.Valid("Afrikaans", new CultureInfo("af"));
4038

4139
yield return ConvertTest.CantConvertFrom(CultureInfo.CurrentCulture);
4240
yield return ConvertTest.CantConvertFrom(1);

src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.Compare.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,8 @@ public static IEnumerable<object[]> Compare_TestData()
254254
yield return new object[] { s_hungarianCompare, "dzsdzs", "ddzs", CompareOptions.None, useNls ? 0 : -1 };
255255
yield return new object[] { s_invariantCompare, "Test's", "Tests", CompareOptions.None, useNls ? 1 : -1 };
256256
yield return new object[] { new CultureInfo("de-DE").CompareInfo, "\u00DC", "UE", CompareOptions.None, -1 };
257-
if (PlatformDetection.IsNotBrowser)
258-
{
259-
yield return new object[] { new CultureInfo("de-DE_phoneb").CompareInfo, "\u00DC", "UE", CompareOptions.None, useNls ? 0 : -1 };
260-
yield return new object[] { new CultureInfo("es-ES_tradnl").CompareInfo, "llegar", "lugar", CompareOptions.None, useNls ? 1 : -1 };
261-
}
257+
yield return new object[] { new CultureInfo("de-DE_phoneb").CompareInfo, "\u00DC", "UE", CompareOptions.None, useNls ? 0 : -1 };
258+
yield return new object[] { new CultureInfo("es-ES_tradnl").CompareInfo, "llegar", "lugar", CompareOptions.None, useNls ? 1 : -1 };
262259
}
263260

264261
// There is a regression in Windows 190xx version with the Kana comparison. Avoid running this test there.

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoAll.cs

Lines changed: 91 additions & 106 deletions
Large diffs are not rendered by default.

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCtor.cs

Lines changed: 238 additions & 245 deletions
Large diffs are not rendered by default.

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoCurrentCulture.cs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,11 @@ public void CurrentCulture()
2222
Assert.Equal(CultureInfo.CurrentCulture, newCulture);
2323
}
2424

25-
if (PlatformDetection.IsNotBrowser)
25+
newCulture = new CultureInfo("de-DE_phoneb");
26+
using (new ThreadCultureChange(newCulture))
2627
{
27-
newCulture = new CultureInfo("de-DE_phoneb");
28-
using (new ThreadCultureChange(newCulture))
29-
{
30-
Assert.Equal(CultureInfo.CurrentCulture, newCulture);
31-
Assert.Equal("de-DE_phoneb", newCulture.CompareInfo.Name);
32-
}
28+
Assert.Equal(CultureInfo.CurrentCulture, newCulture);
29+
Assert.Equal("de-DE_phoneb", newCulture.CompareInfo.Name);
3330
}
3431
}
3532

@@ -48,14 +45,11 @@ public void CurrentUICulture()
4845
Assert.Equal(CultureInfo.CurrentUICulture, newUICulture);
4946
}
5047

51-
if (PlatformDetection.IsNotBrowser)
48+
newUICulture = new CultureInfo("de-DE_phoneb");
49+
using (new ThreadCultureChange(null, newUICulture))
5250
{
53-
newUICulture = new CultureInfo("de-DE_phoneb");
54-
using (new ThreadCultureChange(null, newUICulture))
55-
{
56-
Assert.Equal(CultureInfo.CurrentUICulture, newUICulture);
57-
Assert.Equal("de-DE_phoneb", newUICulture.CompareInfo.Name);
58-
}
51+
Assert.Equal(CultureInfo.CurrentUICulture, newUICulture);
52+
Assert.Equal("de-DE_phoneb", newUICulture.CompareInfo.Name);
5953
}
6054
}
6155

src/libraries/System.Globalization/tests/CultureInfo/CultureInfoParent.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,10 @@ public void Parent(string name, string expectedParentName)
3535
[Fact]
3636
public void Parent_ParentChain()
3737
{
38-
if (PlatformDetection.IsNotBrowser)
39-
{
40-
CultureInfo myExpectParentCulture = new CultureInfo("uz-Cyrl-UZ");
41-
Assert.Equal("uz-Cyrl", myExpectParentCulture.Parent.Name);
42-
Assert.Equal("uz", myExpectParentCulture.Parent.Parent.Name);
43-
Assert.Equal("", myExpectParentCulture.Parent.Parent.Parent.Name);
44-
}
45-
else
46-
{
47-
CultureInfo myExpectParentCulture = new CultureInfo("zh-Hans-CN");
48-
Assert.Equal("zh-Hans", myExpectParentCulture.Parent.Name);
49-
Assert.Equal("zh", myExpectParentCulture.Parent.Parent.Name);
50-
Assert.Equal("", myExpectParentCulture.Parent.Parent.Parent.Name);
51-
}
38+
CultureInfo myExpectParentCulture = new CultureInfo("uz-Cyrl-UZ");
39+
Assert.Equal("uz-Cyrl", myExpectParentCulture.Parent.Name);
40+
Assert.Equal("uz", myExpectParentCulture.Parent.Parent.Name);
41+
Assert.Equal("", myExpectParentCulture.Parent.Parent.Parent.Name);
5242
}
5343
}
5444
}

src/libraries/System.Globalization/tests/CultureInfo/GetCultureInfo.cs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Generic;
5-
using Microsoft.DotNet.RemoteExecutor;
6-
using System.Diagnostics;
75
using Xunit;
86

97
namespace System.Globalization.Tests
108
{
119
public class GetCultureInfoTests
1210
{
13-
public static bool PlatformSupportsFakeCulture => (!PlatformDetection.IsWindows || (PlatformDetection.WindowsVersion >= 10 && !PlatformDetection.IsNetFramework)) && PlatformDetection.IsNotBrowser;
14-
public static bool PlatformSupportsFakeCultureAndRemoteExecutor => PlatformSupportsFakeCulture && RemoteExecutor.IsSupported;
11+
public static bool PlatformSupportsFakeCulture => !PlatformDetection.IsWindows || (PlatformDetection.WindowsVersion >= 10 && !PlatformDetection.IsNetFramework);
1512

1613
public static IEnumerable<object[]> GetCultureInfoTestData()
1714
{
@@ -113,31 +110,5 @@ public void TestFakeCultureNames(string name)
113110
Assert.Equal(name, CultureInfo.GetCultureInfo(name, predefinedOnly: false).Name);
114111
Assert.Throws<CultureNotFoundException>(() => CultureInfo.GetCultureInfo(name, predefinedOnly: true));
115112
}
116-
117-
[ConditionalTheory(nameof(PlatformSupportsFakeCultureAndRemoteExecutor))]
118-
[InlineData("1", "xx-XY")]
119-
[InlineData("1", "zx-ZY")]
120-
[InlineData("0", "xx-XY")]
121-
[InlineData("0", "zx-ZY")]
122-
public void PredefinedCulturesOnlyEnvVarTest(string predefinedCulturesOnlyEnvVar, string cultureName)
123-
{
124-
var psi = new ProcessStartInfo();
125-
psi.Environment.Clear();
126-
127-
psi.Environment.Add("DOTNET_SYSTEM_GLOBALIZATION_PREDEFINED_CULTURES_ONLY", predefinedCulturesOnlyEnvVar);
128-
129-
RemoteExecutor.Invoke((culture, predefined) =>
130-
{
131-
if (predefined == "1")
132-
{
133-
AssertExtensions.Throws<CultureNotFoundException>(() => new CultureInfo(culture));
134-
}
135-
else
136-
{
137-
CultureInfo ci = new CultureInfo(culture);
138-
Assert.Equal(culture, ci.Name);
139-
}
140-
}, cultureName, predefinedCulturesOnlyEnvVar, new RemoteInvokeOptions { StartInfo = psi }).Dispose();
141-
}
142113
}
143114
}

src/libraries/System.Globalization/tests/System/Globalization/TextInfoTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ public static IEnumerable<object[]> ToLower_TestData()
288288
// ICU has special tailoring for the en-US-POSIX locale which treats "i" and "I" as different letters
289289
// instead of two letters with a case difference during collation. Make sure this doesn't confuse our
290290
// casing implementation, which uses collation to understand if we need to do Turkish casing or not.
291-
if (!PlatformDetection.IsWindows && PlatformDetection.IsNotBrowser)
291+
if (!PlatformDetection.IsWindows)
292292
{
293293
yield return new object[] { "en-US-POSIX", "I", "i" };
294294
}
@@ -411,7 +411,7 @@ public static IEnumerable<object[]> ToUpper_TestData()
411411
// ICU has special tailoring for the en-US-POSIX locale which treats "i" and "I" as different letters
412412
// instead of two letters with a case difference during collation. Make sure this doesn't confuse our
413413
// casing implementation, which uses collation to understand if we need to do Turkish casing or not.
414-
if (!PlatformDetection.IsWindows && PlatformDetection.IsNotBrowser)
414+
if (!PlatformDetection.IsWindows)
415415
{
416416
yield return new object[] { "en-US-POSIX", "i", "I" };
417417
}

src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@
307307
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Icu.cs" />
308308
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureData.Nls.cs" />
309309
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureInfo.cs" />
310+
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureInfo.Icu.cs" />
311+
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureInfo.Nls.cs" />
310312
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureNotFoundException.cs" />
311313
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CultureTypes.cs" />
312314
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\DateTimeFormat.cs" />

0 commit comments

Comments
 (0)