Skip to content

Reset charsConsumed when BigInteger partial parsing fails - #132278

Merged
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-tryparsepartial-chars-consumed
Aug 14, 2026
Merged

Reset charsConsumed when BigInteger partial parsing fails#132278
tannergooding merged 2 commits into
dotnet:mainfrom
tannergooding:tannergooding-tryparsepartial-chars-consumed

Conversation

@tannergooding

Copy link
Copy Markdown
Member

BigInteger.TryParsePartial can scan an input successfully but later reject it during NumberToBigInteger, leaving charsConsumed non-zero even though the parse returned false. Reset the consumed count when that conversion fails so callers do not advance after an unsuccessful partial parse.

Add coverage for fractional inputs and an overflowing exponent, including trailing invalid characters.

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 14:25
@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes BigInteger.TryParsePartial to avoid reporting a non-zero consumed count when parsing ultimately fails during NumberToBigInteger conversion, ensuring callers don’t advance their input on unsuccessful partial parses.

Changes:

  • Reset elementsConsumed to 0 when NumberToBigInteger returns a non-OK ParsingStatus in TryParseBigIntegerNumber.
  • Add new TryParsePartial invalid test cases covering fractional inputs and an overflowing exponent (including trailing invalid characters).
Show a summary per file
File Description
src/libraries/System.Runtime.Numerics/src/System/Number.BigInteger.cs Resets elementsConsumed on conversion failure so partial parsing reports 0 consumed when returning failure.
src/libraries/System.Runtime.Numerics/tests/BigInteger/parse.cs Extends TryParsePartial_Invalid_TestData with cases intended to cover “scan succeeds, conversion fails” scenarios.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread src/libraries/System.Runtime.Numerics/tests/BigInteger/parse.cs Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 13, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@tannergooding
tannergooding merged commit d12602d into dotnet:main Aug 14, 2026
78 checks passed
@tannergooding
tannergooding deleted the tannergooding-tryparsepartial-chars-consumed branch August 14, 2026 13:23
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.

3 participants