Uh oh!
There was an error while loading. Please reload this page.
Use correct NumberStyle when parsing double and float - #59205
Conversation
IParseable<float> and IParseable<double> would fail when parsing a decimal point number due to incorrect NumberStyles parameter. E.g. IParseable<double>.TryParse would fail as opposed to IParseable<double>.Parse because the former explicitly states to use NumberStyles.Integer
ghost
commented
Sep 16, 2021
Tagging subscribers to this area: @dotnet/area-system-numerics Issue Details
E.g.
|
tannergooding
commented
Sep 16, 2021
CC. @jeffhandley, can we do a bar check for this? |
pgovind
commented
Sep 16, 2021
+1 on backporting this, especially considering that it's behind a preview attribute |
jeffhandley
commented
Sep 16, 2021
This has my support for either RC2 or GA. Customer-reported and fixed functional issue in new functionality introduced in a late preview, plus the changes are limited to the Generic Math Preview feature. @danmoseley, what do you think? |
tannergooding
commented
Sep 16, 2021
I'll merge this PR either way after and then backport and fill in the template if Dan also thinks its fine to take. |
danmoseley
commented
Sep 16, 2021
I think we can take changes to the preview paths for a while, including this one. Assuming risk to existing codepaths is negligible. So yeah please template and PR against RC2 if you want to. |
| { | ||
| if (s == null) ThrowHelper.ThrowArgumentNullException(ExceptionArgument.s); | ||
| return Number.ParseHalf(s, NumberStyles.Float | NumberStyles.AllowThousands, NumberFormatInfo.GetInstance(provider)); | ||
| return Number.ParseHalf(s, DefaultParseStyle, NumberFormatInfo.GetInstance(provider)); |
There was a problem hiding this comment.
Noting that this and above are the only changes to non preview code and they're a no-op. (It might have been nice if we used DefaultParseStyle in Float and Double or not at all, so they look the same)
danmoseley
commented
Sep 16, 2021
Can we include tests please? |
tannergooding
commented
Sep 17, 2021
@danmoseley, I'll add some basic tests. I don't think we want to duplicate all the parsing tests as these explicit bindings are going away here shortly (they were only for .NET 6 to help separate stable vs experimental APIs). |
Uh oh!
There was an error while loading. Please reload this page.
tannergooding
commented
Sep 20, 2021
/backport to release/6.0 |
Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1254170359 |
tannergooding
commented
Sep 20, 2021
/backport to release/6.0-rc2 |
Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1254861149 |
IParseable<float>andIParseable<double>would fail when parsing a decimal point number due to incorrectNumberStylesparameter.E.g.
IParseable<double>.TryParsewould fail as opposed toIParseable<double>.Parsebecause the former explicitly states to useNumberStyles.Integer