Add STJ path for PluginCacheEntry#7421
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a System.Text.Json (STJ) serialization/deserialization path for plugin operation-claims cache entries, gated by the existing NuGet feature switch/environment variable, to align PluginCacheEntry with the broader NuGet.Protocol STJ migration.
Changes:
- Added STJ-based read/write logic to
PluginCacheEntry, controlled byNuGetFeatureFlagsswitch/env var. - Introduced a source-generated
JsonSerializerContextforIReadOnlyList<OperationClaim>. - Expanded unit tests to run both Newtonsoft/STJ paths and validate cross-compatibility between the two formats.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/NuGet.Core.Tests/NuGet.Protocol.Tests/Plugins/PluginCacheEntryTests.cs | Parameterizes tests to exercise both serializer paths and adds cross-deserialization compatibility coverage. |
| src/NuGet.Core/NuGet.Protocol/Plugins/PluginCacheJsonContext.cs | Adds STJ source-generation context for plugin cache payload (IReadOnlyList<OperationClaim>). |
| src/NuGet.Core/NuGet.Protocol/Plugins/PluginCacheEntry.cs | Adds STJ-based cache file serialization/deserialization behind existing feature gating and injects env-var reader for tests. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| var serializer = new JsonSerializer(); | ||
| using (var sr = new StreamReader(content)) | ||
| using (var jsonTextReader = new JsonTextReader(sr)) | ||
| if (NuGetFeatureFlags.UseSystemTextJsonDeserializationFeatureSwitch |
There was a problem hiding this comment.
Given that this is just internal, NuGet generated, nuget read, I think we may be able to remove the non STJ path.
There was a problem hiding this comment.
doesn't LoadFromFile() expose this method because it is a public API and uses this method as a utility method.
There was a problem hiding this comment.
I am assuming your point is rather about cache file. But we still have a public API
Bug
Fixes:
Description
Add STJ deserialization path for
PluginCacheEntryAdds a feature-flagged
System.Text.Jsondeserialization path for plugin operation claims cache file read/write inPluginCacheEntry. The existing NSJ path is unchanged.PR Checklist