-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Fix number parsing with negative sign #47613
Conversation
Tagging subscribers to this area: @tarekgh, @safern, @krwq Issue DetailsFixes #47524 This change allow parsing negative numbers written with the hyphen character
|
src/libraries/System.Private.CoreLib/src/System/Number.Parsing.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also need to update runtime/src/libraries/Common/src/System/Globalization/FormatProvider.Number.cs? There are some references to NumberFormatInfo.NegativeSign
in that file.
Other files to inspect:
- System/Windows/Forms/NumericUpDown.cs
- System/Text/Json/Serialization/Converters/Value/EnumConverter.cs
(That latter file stores current culture data into a static field, which is probably a bug.)
src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Globalization/NumberFormatInfo.cs
Outdated
Show resolved
Hide resolved
Yes, you are right. I'll fix this one too. I am not sure why we have parsing code in multiple places.
This file is in WinForms repo and not runtime. I looked at it and they have
This should be fine because they are testing with the linguistic StartsWith which should work. |
Any other comments here? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Though I'd still like to see a comment on the switch statement saying "here's where we pulled this list of values from."
@tarekgh I sent an IM to you on Teams asking for clarification on something. Check that if you have a sec before merging. |
Do we need to create a followup issue track reducing duplication you discovered here? |
I just discovered there some changes I didn't submit yet :-( so I am going to submit it soon. |
@danmosemsft There's a tracking issue at #28657. |
Now all changes is submitted. |
Thanks for adding the comments and tests! 👍 |
Fixes #47524
This change allow parsing negative numbers written with the hyphen character
-
when using cultures with negative sign not hyphen but it is one of the alternative Unicode minus sign characters.I have done some basic perf testing with this change and didn't notice any noticeable change.