-
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
Ensure that integer parsing correctly handles non-zero fractional data #106506
Conversation
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) }; |
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.
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:
runtime/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/SByteTests.cs
Lines 266 to 269 in b4d4333
foreach (object[] widerTests in Int32Tests.Parse_Invalid_TestData()) | |
{ | |
yield return widerTests; | |
} |
and
runtime/src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Int64Tests.cs
Lines 303 to 313 in b4d4333
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; | |
} |
/backport to release/9.0 |
Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10474544009 |
/backport to release/8.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/10474548878 |
This resolves #94971