Skip to content

Migrate global.json SDK reader to System.Text.Json - #7755

Merged
zivkan merged 4 commits into
NuGet:devfrom
baronfel:baronfel-aot-global-json-reader
Oct 12, 2026
Merged

zivkan merged 4 commits into
NuGet:devfrom
baronfel:baronfel-aot-global-json-reader

Conversation

@baronfel

@baronfel baronfel commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

Migrates the MSBuild SDK resolver's global.json reader from Newtonsoft.Json to the shared streaming System.Text.Json reader.

The new reader preserves the existing resolver behavior, including file caching, UTF-8 BOM handling, caller-owned stream lifetime, last-duplicate-wins semantics, comments and trailing commas, and ignoring non-string SDK version values. Malformed JSON diagnostics now use the normal System.Text.Json exception message.

The NativeAOT compatibility project now roots Microsoft.Build.NuGetSdkResolver so the resolver is included in trimming and AOT analysis. Its executable test program is unchanged.

This follows #7717, the first reader migration, and is extracted from #7601, the overall SDK resolver/MSBuild NativeAOT work.

This is the second of six PRs incrementally converting NuGet.Client's remaining readers and writers to STJ.

Validation:

  • GlobalJsonReader tests on net10.0: 42 passed
  • GlobalJsonReader tests on net472: 42 passed
  • Release win-x64 self-contained NativeAOT publish: passed
  • Published NativeAOT executable: passed
  • Whitespace verification: passed

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.

@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label Oct 6, 2026
@baronfel
baronfel marked this pull request as ready for review October 6, 2026 22:33
@baronfel
baronfel requested a review from a team as a code owner October 6, 2026 22:33
@baronfel
baronfel requested review from nkolev92 and zivkan October 6, 2026 22:33
baronfel and others added 4 commits October 8, 2026 12:21
Use the shared UTF-8 reader directly and preserve localized parse reasons and one-based locations.

Co-authored-by: Copilot App <[email protected]>
@baronfel
baronfel force-pushed the baronfel-aot-global-json-reader branch from bc277e9 to ac662d4 Compare October 8, 2026 17:52
@baronfel
baronfel requested a review from zivkan October 8, 2026 20:47
@zivkan
zivkan merged commit 9d88850 into NuGet:dev Oct 12, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants