Add STJ path in AutoCompleteResourceV2Feed#7422
Conversation
There was a problem hiding this comment.
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
AutoCompleteResourceV2Feedaccepting anIEnvironmentVariableReaderand branchesGetResultsbetween STJ and Newtonsoft.Json based on the feature flag/env var. - Registers
[JsonSerializable(typeof(string[]))]onJsonContext. - Converts the three
AutoCompleteResourceV2FeedTestscases 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. |
48d7d83 to
87405e8
Compare
nkolev92
left a comment
There was a problem hiding this comment.
one question that may or may not lead to a code change :D
Approving in case my hunch is wrong.
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