Skip to content

Add MetadataStringOrArrayStjConverter - #7356

Merged
Nigusu-Allehu merged 4 commits into
devfrom
dev-nyenework-stj-metadata-string-or-array-converter
Jun 1, 2026
Merged

Nigusu-Allehu merged 4 commits into
devfrom
dev-nyenework-stj-metadata-string-or-array-converter

Conversation

@Nigusu-Allehu

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

Copy link
Copy Markdown
Member

Bug

Fixes: NuGet/Home#14879

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.

MetadataStringOrArrayStjConverter deserializes a JSON string or array of strings into an IReadOnlyList maintaining full behavioral parity with the NSJ MetadataStringOrArrayConverter.

Intentional divergence from NSJ: Null elements within an array (e.g., ["owner1", null, "owner2"]) are filtered out rather than preserved. The NSJ converter passed them through as null values in the list

  • one the type of ownerlist is IReadonlyList not IReadonlyList<string?>
  • two it does not make sense to pass in an owner list of string with one of them being null. It does not communicate any information about the owners.

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 force-pushed the dev-nyenework-stj-metadata-string-or-array-converter branch from 95512c1 to 64aa684 Compare May 6, 2026 22:34

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 new System.Text.Json converter to support PackageSearchMetadata-style metadata fields that can be either a JSON string or an array of strings, as part of the NSJ → STJ migration in NuGet.Protocol.

Changes:

  • Introduces MetadataStringOrArrayStjConverter for deserializing string-or-array fields into an IReadOnlyList<>.
  • Adds unit tests that compare STJ vs NSJ behavior for the converter across valid and invalid inputs.

Reviewed changes

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

File Description
src/NuGet.Core/NuGet.Protocol/Converters/MetadataStringOrArrayStjConverter.cs Adds the new STJ converter implementation for string-or-array metadata fields.
test/NuGet.Core.Tests/NuGet.Protocol.Tests/Converters/MetadataStringOrArrayStjConverterTests.cs Adds parity tests comparing STJ and NSJ deserialization behavior.

@dotnet-policy-service dotnet-policy-service Bot added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label May 14, 2026
@Nigusu-Allehu Nigusu-Allehu reopened this May 26, 2026
@dotnet-policy-service dotnet-policy-service Bot removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label May 26, 2026

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

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

@Nigusu-Allehu
Nigusu-Allehu marked this pull request as ready for review May 27, 2026 01:06
@Nigusu-Allehu
Nigusu-Allehu requested a review from a team as a code owner May 27, 2026 01:06
jebriede
jebriede previously approved these changes May 29, 2026

@jebriede jebriede 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.

Approving with one suggestion!

@Nigusu-Allehu
Nigusu-Allehu dismissed stale reviews from jebriede and jeffkl via 1779c02 May 29, 2026 01:49
@Nigusu-Allehu
Nigusu-Allehu requested review from jebriede and jeffkl May 29, 2026 01:50
@Nigusu-Allehu
Nigusu-Allehu merged commit 400e8a2 into dev Jun 1, 2026
17 of 18 checks passed
@Nigusu-Allehu
Nigusu-Allehu deleted the dev-nyenework-stj-metadata-string-or-array-converter branch June 1, 2026 16:56
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 MetadataStringOrArrayConverter

4 participants