Add UTF-8 Parse/TryParse/TryFormat polyfills for BigInteger and Complex - #609
Merged
Merged
Conversation
Adds the .NET 11 UTF-8 BigInteger Parse/TryParse/TryFormat and Complex TryParse overloads. Complex UTF-8 Parse is skipped because it would collide with BigInteger.Parse as static extension members. Introduces the FeatureNumerics constant, set when System.Numerics is referenced.
This was referenced Sep 19, 2026
This was referenced Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Polyfills the UTF-8 members that .NET 11 adds to
BigIntegerandComplex(dotnet/runtime#117745, from the Performance Improvements in .NET 11 post). Signatures were checked against the 11.0 RC1 ref pack, and the 7.0/8.0/9.0/10.0 ref packs were checked for when each member first appeared.BigInteger (all targets below net11, needs
FeatureMemory)Parse(ReadOnlySpan<byte>, NumberStyles = Integer, IFormatProvider? = null)Parse(ReadOnlySpan<byte>, IFormatProvider?)TryParse(ReadOnlySpan<byte>, out BigInteger)TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, out BigInteger)TryParse(ReadOnlySpan<byte>, IFormatProvider?, out BigInteger)TryFormat(Span<byte>, out int, ReadOnlySpan<char> = default, IFormatProvider? = null)Complex (net7.0–net10.0)
TryParse(ReadOnlySpan<byte>, NumberStyles, IFormatProvider?, out Complex)TryParse(ReadOnlySpan<byte>, IFormatProvider?, out Complex)Below net7,
Complexhas no stringParseto delegate to. The UTF-8TryFormatalready exists from net8.Complex.Parse(ReadOnlySpan<byte>, ...)is not polyfilled. Static extension members compile to plain static methods onPolyfill, so it would collide withBigInteger.Parse(ReadOnlySpan<byte>, ...)(CS0111). This matches howIPAddress.Parseis skipped next toGuid.Parse, and is documented with a//Note:.All members decode the UTF-8 bytes to a string and delegate to the existing overloads. Results match the BCL, but they allocate a string.
New
FeatureNumericsconstantOn .NET Framework,
BigInteger/Complexlive inSystem.Numerics.dll. SDK-style projects reference it implicitly, but old-style projects may not.Polyfill.targetsnow setsFeatureNumericswhenSystem.NumericsorSystem.Runtime.Numericsis in@(ReferencePath), and always sets it for netcoreapp, net5+ and netstandard. It is registered inIdentifiers.sharedIdentifiers,BuildApiTestandSplitterTests, and listed inCLAUDE.md.Verification