Visitar URL original
Read global.json as the dotnet Host Does When Selecting the SDK Line by ptr727 · Pull Request #4129 · ptr727/ProjectTemplate · GitHub
Skip to content

Read global.json as the dotnet Host Does When Selecting the SDK Line - #4129

Merged
ptr727 merged 10 commits into
developfrom
dotnet-sdk-json5
Nov 13, 2026
Merged

ptr727 merged 10 commits into
developfrom
dotnet-sdk-json5

Conversation

@ptr727

@ptr727 ptr727 commented Nov 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

Answers a Copilot finding on the develop -> main promotion #4126. The dotnet-sdk action decided between the caller's global.json and the 10.x fallback with jq -e '.sdk.version'. A global.json holding a comment is valid to the dotnet host and to setup-dotnet, but jq cannot parse it, so such a file selecting 11.0 got 10.x.

The selection step now reads global.json as both the dotnet host and setup-dotnet do. Comments are the one extension both accept (the host's json_parser.cpp parses with kParseCommentsFlag only), so it drops comments outside strings, parses the rest as strict JSON, and passes global-json-file where an sdk.version is present. A file with no sdk.version still gets the fallback, and a file nothing can read falls back with a warning.

Verification

  • test_release_guards.DotnetSdkLineCase runs the step's script, from a file under bash, against a selecting file, a test-runner-only file, a commented file of each kind, a BOM, a URL inside a string, a trailing comma, and an unreadable file whose warning names the caller's line. Each new case was watched failing against the code it guards.
  • Full suite: 4078 tests, OK (11 skipped). All seven Docker linters and repo_gate.py composite-actions pass.

Open Findings From the Local Pass

None. Every finding listed for earlier pushes is fixed, the last in 8b058f91 (a case with a UTF-8 BOM), and the pass over that head raised none.

🤖 Generated with Claude Code

ptr727 and others added 2 commits November 12, 2026 18:48
The dotnet-sdk action falls back to 10.x only where jq reads global.json
and finds no sdk.version. A file jq cannot parse, such as one holding a
comment, is valid JSON5 to setup-dotnet and the dotnet host, so it now goes
to setup-dotnet, which installs the line it selects, with a notice naming
why.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dotnet-sdk action drops comments and trailing commas outside strings,
as the dotnet host accepts them, then parses the rest as strict JSON. A
commented file selects its line, one with no sdk.version still gets the
fallback, and one nothing can read falls back with a warning.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings November 13, 2026 03:01
@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Nov 13, 2026
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head eb6aba151d0a74b488ae62413f69a2438fa18e04, the content this pull request carries at that commit against develop, and it recorded 3 findings.

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.

🟡 Changes recommended

The action still has two active correctness issues: it strips trailing commas that the dotnet host rejects and allows read or decoding failures to abort before the documented fallback is written.

2 open issues
What changed in this PR

This PR updates the shared .NET SDK composite action to select SDK versions from commented global.json files while retaining fallback behavior.

Changes:

  • Replaces jq-based selection with a Python-based global.json reader.
  • Adds coverage for comments, URLs in strings, missing SDK versions, malformed content, and unreadable files.
  • Preserves workflow ordering checks for SDK setup after checkout.
File Description
tests/​test_release_guards.py Expands release-guard coverage for SDK selection, parsing, fallback behavior, and shared-action workflow ordering.
.github/​actions/​dotnet-sdk/​action.yml Implements Python-based global.json parsing and emits either the selected SDK configuration or the fallback version.

Review effort: Lite

Comment thread .github/actions/dotnet-sdk/action.yml Resolved
Comment thread .github/actions/dotnet-sdk/action.yml Resolved
ptr727 and others added 2 commits November 12, 2026 19:08
The dotnet host parses global.json with comments allowed and nothing else
(kParseCommentsFlag in corehost json_parser.cpp), so the selection step
no longer drops trailing commas, and a root that is not an object fails
the step rather than falling back silently.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.69%. Comparing base (7c3b7ee) to head (86ac191).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4129   +/-   ##
========================================
  Coverage    76.69%   76.69%           
========================================
  Files           40       40           
  Lines        14146    14146           
========================================
  Hits         10849    10849           
  Misses        3297     3297           
Flag Coverage Δ
python-3.13 76.69% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head f8b8a2b8f60dcd2d26d78d9f7867d40476c4bb40, the content this pull request carries at that commit against develop, and it recorded 1 finding.

ptr727 and others added 2 commits November 12, 2026 19:19
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head badbc734e866b71c2b8f5f28b129190186039581, the content this pull request carries at that commit against develop, and it recorded 1 finding.

ptr727 and others added 2 commits November 12, 2026 19:25
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Git Bash collapses the step's doubled backslashes in a -c argument, so the
test writes the script to a file as its siblings do. The skip asks bash
whether python3 runs, since a found WindowsApps alias does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 9c31310aff6a9c3849d320e2926b3ae3dd47015e, the content this pull request carries at that commit against develop, and it recorded 1 finding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 8b058f91ce446d995c7b8f587d91c80f1b9df0da, the content this pull request carries at that commit against develop, and it recorded 0 findings.

The selection step reads global.json with errors="replace", matching
setup-dotnet's UTF-8 read, so a file whose comment holds a Latin-1 byte
selects its line rather than failing the step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 86ac191610e2c3458c6e10845bcba1fb743ab471, the content this pull request carries at that commit against develop, and it recorded 0 findings.

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@ptr727

ptr727 commented Nov 13, 2026

Copy link
Copy Markdown
Owner Author

/review

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Action not completed

Pull request is closed.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@ptr727
ptr727 merged commit a45be93 into develop Nov 13, 2026
13 checks passed
@ptr727
ptr727 deleted the dotnet-sdk-json5 branch November 13, 2026 04:00
ptr727 added a commit that referenced this pull request Nov 13, 2026
## Summary

Promotes the .NET SDK line work and two changes from other hub sessions
from `develop` to `main`.

- #4110:
- The Linux host installer's default dotnet set is the fleet's SDK line
plus the newest line the feed carries, so a host whose feed has moved
past 10.0 still builds fleet .NET repositories.
- Each installer names the line itself (`DOTNET_FLEET_LINE` on Linux,
`$DOTNET_MAJOR` on Windows) so it still runs fetched on its own, and a
test holds both to the `global.json` baseline.
- The hub's setup-dotnet steps go through a new
`.github/actions/dotnet-sdk`, which installs the line the caller's
`global.json` selects. It falls back to `10.x` for a caller carrying no
`sdk.version` yet.
- #4127: the shared SDK step's ordering comment states the required
order plainly, answering a Copilot finding on this promotion.
- #4129: the `dotnet-sdk` action reads `global.json` as the dotnet host
and setup-dotnet do, so a commented file selects its line, answering a
Copilot finding on this promotion.
- #4130: a `global.json` whose `sdk` is null gets the fallback line, as
the dotnet host treats it, answering a Copilot thread on this promotion.
- #4116: the agent setup runs past a failed tool upgrade, and a held
`cswap` is skipped.
- #4125: `carry.py` carries a registry entry not yet promoted to `main`
when run from a `develop` checkout.

Closes #4106
Closes #4107

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants