Skip to content

Add STJ path in AutoCompleteResourceV2Feed#7422

Merged
Nigusu-Allehu merged 6 commits into
devfrom
dev-nyenework-autocompletev2-stj
Jun 2, 2026
Merged

Add STJ path in AutoCompleteResourceV2Feed#7422
Nigusu-Allehu merged 6 commits into
devfrom
dev-nyenework-autocompletev2-stj

Conversation

@Nigusu-Allehu
Copy link
Copy Markdown
Member

@Nigusu-Allehu Nigusu-Allehu commented May 27, 2026

Bug

Fixes: NuGet/Home#14895

Description

Adds a feature-flagged System.Text.Json deserialization path for V2 feed autocomplete results in AutoCompleteResourceV2Feed. The existing NSJ path is unchanged.

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 changed the title Dev nyenework autocompletev2 stj Add STJ path in AutoCompleteResourceV2Feed May 27, 2026
@Nigusu-Allehu Nigusu-Allehu requested a review from Copilot May 27, 2026 22:38
@Nigusu-Allehu Nigusu-Allehu self-assigned this May 27, 2026
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

Adds a System.Text.Json deserialization path to AutoCompleteResourceV2Feed.GetResults, gated behind the existing NuGet.UseSystemTextJsonDeserialization feature switch / NUGET_USE_SYSTEM_TEXT_JSON_DESERIALIZATION env var, mirroring the pattern already used by AutoCompleteResourceV3, ServiceIndexResourceV3Provider, and RepositorySignatureResourceProvider. The V2 autocomplete endpoints return a top‑level JSON string[], so string[] is added to the shared JsonContext source-generation context and the existing tests are parameterized to cover both code paths.

Changes:

  • Adds an internal constructor on AutoCompleteResourceV2Feed accepting an IEnvironmentVariableReader and branches GetResults between STJ and Newtonsoft.Json based on the feature flag/env var.
  • Registers [JsonSerializable(typeof(string[]))] on JsonContext.
  • Converts the three AutoCompleteResourceV2FeedTests cases to [Theory] with "true"/"false" data, constructing the resource directly with a mocked env reader.

Reviewed changes

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

File Description
src/NuGet.Core/NuGet.Protocol/LegacyFeed/AutoCompleteResourceV2Feed.cs Adds STJ branch in GetResults and an internal constructor taking IEnvironmentVariableReader.
src/NuGet.Core/NuGet.Protocol/Utility/JsonContext.cs Adds string[] to the STJ source-generation context for V2 autocomplete responses.
test/NuGet.Core.Tests/NuGet.Protocol.Tests/AutoCompleteResourceV2FeedTests.cs Parameterizes existing tests over the STJ/NSJ feature switch using a mocked env reader.

Comment thread test/NuGet.Core.Tests/NuGet.Protocol.Tests/AutoCompleteResourceV2FeedTests.cs Outdated
Nigusu-Allehu and others added 6 commits May 28, 2026 09:03
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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 3 out of 3 changed files in this pull request and generated no new comments.

@Nigusu-Allehu Nigusu-Allehu marked this pull request as ready for review May 28, 2026 22:44
@Nigusu-Allehu Nigusu-Allehu requested a review from a team as a code owner May 28, 2026 22:44
Copy link
Copy Markdown
Member

@nkolev92 nkolev92 left a comment

Choose a reason for hiding this comment

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

one question that may or may not lead to a code change :D

Approving in case my hunch is wrong.

Comment thread src/NuGet.Core/NuGet.Protocol/Utility/JsonContext.cs
@Nigusu-Allehu Nigusu-Allehu merged commit 8d504c7 into dev Jun 2, 2026
18 of 19 checks passed
@Nigusu-Allehu Nigusu-Allehu deleted the dev-nyenework-autocompletev2-stj branch June 2, 2026 23:25
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.

Migrate AutoCompleteResourceV2Feed deserialization to System.Text.Json

4 participants