-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
PredefinedCulturesOnly=false not respected in new CultureInfo(int) #86878
Comments
Tagging subscribers to this area: @dotnet/area-system-globalization Issue DetailsDescriptionThis creates issue for WinForms see runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs Lines 860 to 872 in 182591a
and runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs Lines 670 to 682 in 182591a
Reproduction Steps
_ = new CultureInfo(1100); Expected behaviorreturn Invariant culture Actual behaviorexception Regression?No response Known WorkaroundsNo response ConfigurationNo response Other informationNo response
|
Why would you enable the invariant globalization mode for a WinForm app? I believe this is not the suitable environment for running WinForm apps for several reasons. Additionally, we generally discourage the use of LCID (Locale Identifier) as it is considered obsolete, and we try to avoid investing in outdated technologies. The appropriate course of action in this case is to disable the invariant mode for your WinForm apps. |
This issue has been marked |
I'm developing tool to convert data from one well defined format to another, and doesn't have any plans on localization. Usage of this constructor is tied to what we get from Fix is trivial and will bring in consistency between constructor overloads. internal static CultureData GetCultureData(int culture, bool bUseUserOverride)
{
CultureData? retVal = null;
if (culture == CultureInfo.LOCALE_INVARIANT)
{
return Invariant;
}
if (GlobalizationMode.Invariant)
{
+ if (!GlobalizationMode.PredefinedCulturesOnly)
+ {
+ return Invariant;
+ }
// LCID is not supported in the InvariantMode
throw new CultureNotFoundException(nameof(culture), culture, SR.Argument_CultureNotSupportedInInvariantMode);
} |
@OwnageIsMagic thanks for the info. in your tool, who is creating the culture using the LCID? Is it your tool or WinFoms? If it is your tool, then you can just avoid creating the culture in the first place and use Invariant Culture. If it is WinForms, then you have something seriously wrong trying to use WinFomrs and expect it will handle the cultural operation correctly while you are enabling Invariant Globalization mode.
This is not the point; the point is we need to refrain users from using LCIDs in general. Helping fixing cases to support LCIDs will make it worse to obsolete such APIs moving forward. |
This issue has been marked |
@tarekgh the culture is created in WinForms as part of creating
In invariant mode LCID is actually unused and ignored, so I don't think that can be considered as support. |
@OwnageIsMagic are you interested to submit a PR? |
Description
This creates issue for WinForms
dotnet/winforms#9191 (comment)
see
runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs
Lines 860 to 872 in 182591a
and
runtime/src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs
Lines 670 to 682 in 182591a
Reproduction Steps
dotnet build /p:InvariantGlobalization=true /p:PredefinedCulturesOnly=false && dotnet run --no-build
Expected behavior
Return Invariant culture.
Actual behavior
Exception.
The text was updated successfully, but these errors were encountered: