Skip to content

Conversation

@7rakir
Copy link
Contributor

@7rakir 7rakir commented Sep 16, 2021

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

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 ghost added area-System.Numerics community-contribution Indicates that the PR has been added by a community member labels Sep 16, 2021
@ghost
Copy link

ghost commented Sep 16, 2021

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

Issue Details

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

Author: 7rakir
Assignees: -
Labels:

area-System.Numerics

Milestone: -

@dnfadmin
Copy link

dnfadmin commented Sep 16, 2021

CLA assistant check
All CLA requirements met.

Copy link
Member

@tannergooding tannergooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tannergooding
Copy link
Member

CC. @jeffhandley, can we do a bar check for this? Generic math is a preview feature, but it would be nice for this to work correctly

@pgovind
Copy link

pgovind commented Sep 16, 2021

+1 on backporting this, especially considering that it's behind a preview attribute

@jeffhandley
Copy link
Member

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
Copy link
Member

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
Copy link
Member

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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Member

Can we include tests please?

@tannergooding
Copy link
Member

@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).

@tannergooding tannergooding merged commit 7691aa8 into dotnet:main Sep 20, 2021
@tannergooding
Copy link
Member

/backport to release/6.0

@github-actions
Copy link
Contributor

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1254170359

@tannergooding
Copy link
Member

/backport to release/6.0-rc2

@github-actions
Copy link
Contributor

Started backporting to release/6.0-rc2: https://github.com/dotnet/runtime/actions/runs/1254861149

@7rakir 7rakir deleted the Fix-decimal-point-parsing-in-IParseable-TryParse branch September 21, 2021 18:32
@ghost ghost locked as resolved and limited conversation to collaborators Nov 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Numerics community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants