[Breaking change]: Limiting the precision in numeric format strings from Int32.MaxValue to 999,999,999 #30352
Closed
1 of 2 tasks
Labels
binary incompatible
Existing binaries may encounter a breaking change in behavior.
breaking-change
Indicates a .NET Core breaking change
🏁 Release: .NET 7
Work items for the .NET 7 release
doc-idea
Indicates issues that are suggestions for new topics [org][type][category]
Pri1
High priority, do before Pri2 and Pri3
Description
The fix will likely be merged into .NET 7 RC1 with dotnet/runtime#72647.
in .NET 6, we updated the maximum precision for numeric format strings to be
Int32.MaxValue
, as documented here https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings and here https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/numeric-format-parsing-handles-higher-precision. Unfortunately, the implementation was buggy, and the easiest fix requires we pick a slightly smaller limit of999,999,999
. The original expansion toInt32.MaxValue
was pretty arbitrary as far as I can tell, and999,999,999
is more than big enough. This comment (dotnet/runtime#67891 (comment)) goes into a bit more detail on the logic of this choice.Version
.NET 7 RC1
Previous behavior
The previous behavior intended to throw a
FormatException
for any precision larger thanInt.MaxValue
. It did not throw that exception for many of such inputs due to the mentioned bug. The intended behavior was:New behavior
Now, we correctly throw a
FormatException
for any precision larger than999,999,999
.Type of breaking change
Reason for change
Described above.
Recommended action
This change should not have any substantial effect, as I don't think many are using precisions this large. Simply updating the documentation should be sufficient.
Feature area
Core .NET libraries
Affected APIs
Should be the same APIs as the previous change https://docs.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/numeric-format-parsing-handles-higher-precision
The text was updated successfully, but these errors were encountered: