Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
More feedback addressing
  • Loading branch information
tarekgh committed Jun 30, 2021
commit 57d66c08def760c9996ac3358ac68968911d0b29
Original file line number Diff line number Diff line change
Expand Up @@ -669,15 +669,9 @@ private static CultureData CreateCultureWithInvariantData()
return CultureData.Invariant;
}

if (GlobalizationMode.Invariant && GlobalizationMode.PredefinedCulturesOnly)
{
return null;
}

if (GlobalizationMode.PredefinedCulturesOnly)
{
Debug.Assert(!GlobalizationMode.Invariant);
if (GlobalizationMode.UseNls ? !NlsIsEnsurePredefinedLocaleName(cultureName): !IcuIsEnsurePredefinedLocaleName(cultureName))
if (GlobalizationMode.Invariant || (GlobalizationMode.UseNls ? !NlsIsEnsurePredefinedLocaleName(cultureName): !IcuIsEnsurePredefinedLocaleName(cultureName)))
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ private static CultureInfo InitializeUserDefaultUICulture()
return s_userDefaultUICulture!;
}

private static string GetCultureNotSupportedExceptionMessage() => GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported;

public CultureInfo(string name) : this(name, true)
{
}
Expand All @@ -174,7 +176,7 @@ public CultureInfo(string name, bool useUserOverride)

if (cultureData == null)
{
throw new CultureNotFoundException(nameof(name), name, GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported);
throw new CultureNotFoundException(nameof(name), name, GetCultureNotSupportedExceptionMessage());
}

_cultureData = cultureData;
Expand Down Expand Up @@ -249,7 +251,7 @@ internal CultureInfo(string cultureName, string textAndCompareCultureName)
}

CultureData? cultureData = CultureData.GetCultureData(cultureName, false) ??
throw new CultureNotFoundException(nameof(cultureName), cultureName, GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported);
throw new CultureNotFoundException(nameof(cultureName), cultureName, GetCultureNotSupportedExceptionMessage());

_cultureData = cultureData;

Expand Down Expand Up @@ -1060,7 +1062,7 @@ public static CultureInfo GetCultureInfo(int culture)
}
catch (ArgumentException)
{
throw new CultureNotFoundException(nameof(culture), culture, GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported);
throw new CultureNotFoundException(nameof(culture), culture, GetCultureNotSupportedExceptionMessage());
}

lock (lcidTable)
Expand Down Expand Up @@ -1096,7 +1098,7 @@ public static CultureInfo GetCultureInfo(string name)
}

result = CreateCultureInfoNoThrow(name, useUserOverride: false) ??
throw new CultureNotFoundException(nameof(name), name, GlobalizationMode.Invariant ? SR.Argument_CultureNotSupportedInInvariantMode : SR.Argument_CultureNotSupported);
throw new CultureNotFoundException(nameof(name), name, GetCultureNotSupportedExceptionMessage());
result._isReadOnly = true;

// Remember our name as constructed. Do NOT use alternate sort name versions because
Expand Down