Skip to content

Commit b86de6f

Browse files
committed
Improvements
1 parent 3434e4d commit b86de6f

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/Components/WebAssembly/WebAssembly/src/Hosting/WebAssemblyCultureProvider.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,6 @@ internal static string[] GetCultures(CultureInfo? cultureInfo, CultureInfo? uiCu
7676
{
7777
var culturesToLoad = new List<string>();
7878

79-
if (uiCultureInfo == null)
80-
{
81-
uiCultureInfo = cultureInfo;
82-
}
83-
8479
// Once WASM is ready, we have to use .NET's assembly loading to load additional assemblies.
8580
// First calculate all possible cultures that the application might want to load. We do this by
8681
// starting from the current culture and walking up the graph of parents.
@@ -98,8 +93,8 @@ internal static string[] GetCultures(CultureInfo? cultureInfo, CultureInfo? uiCu
9893
culturesToLoad.Add(uiCultureInfo.Name);
9994
}
10095

101-
cultureInfo = cultureInfo?.Parent;
102-
uiCultureInfo = uiCultureInfo?.Parent;
96+
cultureInfo = (cultureInfo?.Parent == cultureInfo) ? null : cultureInfo?.Parent;
97+
uiCultureInfo = (uiCultureInfo?.Parent == uiCultureInfo) ? null : uiCultureInfo?.Parent;
10398
}
10499

105100
return culturesToLoad.ToArray();

src/Components/WebAssembly/WebAssembly/test/Hosting/WebAssemblyCultureProviderTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ public void GetCultures_ReturnsCultureClosure(string cultureName, string[] expec
2626

2727
[Theory]
2828
[InlineData("fr-FR", "tzm-Latn-DZ", new[] { "fr-FR", "tzm-Latn-DZ", "fr", "tzm-Latn", "tzm" })]
29+
[InlineData("fr-FR", null, new[] { "fr-FR", "fr" })]
30+
[InlineData(null, null, new string[0])]
2931
public void GetCultures_ReturnCultureClosureWithUICulture(string cultureName, string uiCultureName, string[] expected)
3032
{
3133
// Arrange
32-
var culture = new CultureInfo(cultureName);
33-
var uiCulture = new CultureInfo(uiCultureName);
34+
var culture = cultureName != null ? new CultureInfo(cultureName) : null;
35+
var uiCulture = uiCultureName != null ? new CultureInfo(uiCultureName) : null;
3436
// Act
3537
var actual = WebAssemblyCultureProvider.GetCultures(culture, uiCulture);
3638
// Assert

0 commit comments

Comments
 (0)