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

Ensure that integer parsing correctly handles non-zero fractional data #106506

Merged
merged 1 commit into from
Aug 20, 2024

Conversation

tannergooding
Copy link
Member

This resolves #94971

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Aug 15, 2024
@tannergooding tannergooding added area-System.Runtime and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Aug 15, 2024
@tannergooding
Copy link
Member Author

CC. @stephentoub.

This is fixing a regression introduced in .NET 8, so we likely want to backport into .NET 8 and .NET 9 RC2


// Test trailing non zeros

yield return new object[] { "-9223372036854775808.1", NumberStyles.Number, CultureInfo.InvariantCulture, typeof(OverflowException) };
Copy link
Member Author

Choose a reason for hiding this comment

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

Just noting for reviewers that this Parse_Invalid_TestData is reused by the other integer types as part of their parsing validation logic.

For example:

foreach (object[] widerTests in Int32Tests.Parse_Invalid_TestData())
{
yield return widerTests;
}

and

foreach (object[] objs in Int32Tests.Parse_Invalid_TestData())
{
if ((Type)objs[3] == typeof(OverflowException) &&
(((NumberStyles)objs[1] & NumberStyles.AllowBinarySpecifier) != 0 || // TODO https://github.com/dotnet/runtime/issues/83619: Remove once BigInteger supports binary parsing
!BigInteger.TryParse((string)objs[0], (NumberStyles)objs[1], null, out BigInteger bi) ||
(bi >= long.MinValue && bi <= long.MaxValue)))
{
continue;
}
yield return objs;
}

@tannergooding tannergooding merged commit c47fc5f into dotnet:main Aug 20, 2024
145 of 147 checks passed
@tannergooding tannergooding deleted the fix-94971 branch August 20, 2024 15:26
@tannergooding
Copy link
Member Author

/backport to release/9.0

Copy link
Contributor

Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10474544009

@tannergooding
Copy link
Member Author

/backport to release/8.0-staging

Copy link
Contributor

Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/10474548878

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

short.Parse regression in .NET 8.0 from 7.0
2 participants