Skip to content

Add SafeBoolStjConverter - #7359

Merged
Nigusu-Allehu merged 2 commits into
devfrom
dev-nyenework-stj-safe-bool-converter
May 5, 2026
Merged

Nigusu-Allehu merged 2 commits into
devfrom
dev-nyenework-stj-safe-bool-converter

Conversation

@Nigusu-Allehu

@Nigusu-Allehu Nigusu-Allehu commented May 4, 2026 •

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14884
Related: NuGet/Home#14846

Description

This is a focused slice of #7301, split per-converter to make reviewing
easier.

Converters are being migrated first so that the upcoming Registration resource migrations don't become bloated PRs.

SafeBoolStjConverter safely deserializes booleans from various token types. used by PackageSearchMetadata.RequireLicenseAcceptance.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc.

@Nigusu-Allehu Nigusu-Allehu self-assigned this May 4, 2026
@Nigusu-Allehu
Nigusu-Allehu marked this pull request as ready for review May 4, 2026 00:37
@Nigusu-Allehu
Nigusu-Allehu requested a review from a team as a code owner May 4, 2026 00:37

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

Adds a System.Text.Json boolean converter to support the ongoing NSJ → STJ migration for NuGet.Protocol metadata deserialization (specifically PackageSearchMetadata.RequireLicenseAcceptance).

Changes:

  • Add SafeBoolStjConverter (JsonConverter<bool>) that safely parses booleans from multiple JSON token types.
  • Add unit tests validating STJ behavior matches the existing Newtonsoft.Json SafeBoolConverter across a range of inputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/NuGet.Core/NuGet.Protocol/Converters/SafeBoolStjConverter.cs Introduces the STJ converter implementation for “safe bool” deserialization.
test/NuGet.Core.Tests/NuGet.Protocol.Tests/Converters/SafeBoolStjConverterTests.cs Adds parity tests comparing STJ vs NSJ deserialization results.

nkolev92
nkolev92 previously approved these changes May 4, 2026
jeffkl
jeffkl previously approved these changes May 5, 2026
@Nigusu-Allehu
Nigusu-Allehu dismissed stale reviews from jeffkl and nkolev92 via 6159ae2 May 5, 2026 17:24
@Nigusu-Allehu
Nigusu-Allehu requested a review from jeffkl May 5, 2026 17:25
@Nigusu-Allehu
Nigusu-Allehu merged commit d4a4c7c into dev May 5, 2026
17 of 18 checks passed
@Nigusu-Allehu
Nigusu-Allehu deleted the dev-nyenework-stj-safe-bool-converter branch May 5, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add System.Text.Json equivalent of SafeBoolConverter

4 participants