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

Enum should use the supplied IFormatProvider #38779

Closed
HobbsCode opened this issue Jul 4, 2020 · 3 comments
Closed

Enum should use the supplied IFormatProvider #38779

HobbsCode opened this issue Jul 4, 2020 · 3 comments
Labels
area-System.Globalization untriaged New issue has not been triaged by the area owner

Comments

@HobbsCode
Copy link

Much of Enum's implementation of IConvertible disregards the supplied IFormatProvider, and instead uses CurrentCulture. Is this intentional? Example:

ulong IConvertible.ToUInt64(IFormatProvider? provider)
{
     return Convert.ToUInt64(GetValue(), CultureInfo.CurrentCulture);
}
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Globalization untriaged New issue has not been triaged by the area owner labels Jul 4, 2020
@ghost
Copy link

ghost commented Jul 4, 2020

Tagging subscribers to this area: @tarekgh, @safern, @krwq
Notify danmosemsft if you want to be subscribed.

@GrabYourPitchforks
Copy link
Member

Enum is backed by numeric types (byte, int, long, etc.). Conversion from one numeric type to another is always culture-agnostic because there's no localization that ever has to be performed.

Honestly the implementation should probably be passing null rather than CultureInfo.CurrentCulture as an optimization.

@HobbsCode
Copy link
Author

If using CurrentCulture doesn't result in any correctness problem, then I'm going to close the issue. Thanks for the quick response.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Globalization untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

3 participants