Skip to content

Use ThrowHelper in JsonElement.GetByte/GetSByte/GetInt16/GetUInt16#126559

Merged
danmoseley merged 4 commits intodotnet:mainfrom
prozolic:jsonelementget
Apr 20, 2026
Merged

Use ThrowHelper in JsonElement.GetByte/GetSByte/GetInt16/GetUInt16#126559
danmoseley merged 4 commits intodotnet:mainfrom
prozolic:jsonelementget

Conversation

@prozolic
Copy link
Copy Markdown
Contributor

@prozolic prozolic commented Apr 5, 2026

This PR replace inline throw new FormatException() statements in JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with ThrowHelper.ThrowFormatException calls, consistent with the pattern established in #61746.

Replace inline `throw new FormatException()` statements in
JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with
ThrowHelper.ThrowFormatException calls, consistent with the pattern
established in dotnet#61746.
Copilot AI review requested due to automatic review settings April 5, 2026 11:25
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Apr 5, 2026
@prozolic prozolic marked this pull request as ready for review April 5, 2026 11:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns JsonElement.GetSByte, GetByte, GetInt16, and GetUInt16 with the existing System.Text.Json throw-helper pattern by replacing inline throw new FormatException() statements with ThrowHelper.ThrowFormatException() calls, consistent with prior refactors (e.g., #61746).

Changes:

  • Refactors GetSByte() to throw via ThrowHelper.ThrowFormatException() when TryGetSByte() fails.
  • Refactors GetByte(), GetInt16(), and GetUInt16() similarly to centralize FormatException throwing.

Copilot AI review requested due to automatic review settings April 19, 2026 09:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@danmoseley
Copy link
Copy Markdown
Member

thanks

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

Labels

area-System.Text.Json community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants