Skip to content

Allow whitespace after leading numeric signs and parentheses - #134672

Merged
tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-allow-whitespace-after-leading-sign
Sep 25, 2026
Merged

tannergooding merged 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-allow-whitespace-after-leading-sign

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Summary

  • Accept whitespace after a permitted leading sign or opening parenthesis when NumberStyles.AllowLeadingWhite is set, matching the corresponding trailing-whitespace behavior.
  • Keep ordinary integer parsing on its fast path and retry the shared parser for whitespace after a sign; align hexadecimal floating-point parsing and update AllowLeadingWhite documentation.
  • Add regression coverage for numeric types, custom signs, parentheses, UTF-8, and partial parsing with consumed lengths. Without AllowLeadingWhite, the same inputs remain invalid.

Validation

  • build.cmd clr+libs -rc checked -lc Release -- succeeded with no warnings or errors.
  • System.Runtime numeric-type tests: 36,311 total, 0 failed, 71 skipped (platform conditions).
  • System.Runtime.Numerics tests: 8,635 total, 0 failed.
  • Eleven Int32 regression cases failed on unfixed upstream and passed with this fix.

Exploratory local timings found no consistent common-case JIT regression. ReadyToRun int.Parse with leading whitespace measured roughly 5.9 ns before vs. 6.4 ns after, but the difference did not persist in JIT-only runs and is sensitive to code layout. BenchmarkDotNet did not recognize the current .NET 11 runtime.

Resolves #101873

Note

This PR description was drafted by GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative numeric parsing inconsistencies / can't parse standard Windows format option

2 participants