Skip to content

Use PreReleaseVersionLabel to detect servicing branches in CodeCheck.ps1 - #68051

Merged
wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/codecheck-api-prerelease
Jul 27, 2026
Merged

wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/codecheck-api-prerelease

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jul 27, 2026 •

Copy link
Copy Markdown
Member

Fixes #50635

CodeCheck.ps1 tried to exclude rc1/rc2 branches from the PublicAPI.Unshipped.txt check by testing whether $targetBranch (e.g. release/11.0) contained rc1/rc2 as a substring. But that information lives in PreReleaseVersionLabel, not the branch name, so the check never matched — release/11.0 was incorrectly flagged as a servicing branch throughout its entire rc1/rc2 lifetime, well before it actually reached rtm/servicing.

Fix: read the target branch's actual PreReleaseVersionLabel from its eng/Versions.props (via git show origin/$targetBranch:eng/Versions.props) and only flag Unshipped.txt changes once the label is rtm or servicing — the same source of truth used elsewhere (e.g. IsServicingBuild). Fails closed if the ref/file can't be read or the label is missing/unrecognized.

Validated with PowerShell 7 against real refs (origin/main → alpha, origin/release/8.0 → servicing) and simulated failure cases.

🤖 Generated with Copilot CLI

Previously, CodeCheck.ps1 used a branch-name heuristic (`release*` and not
`*preview*`/`*rc1*`/`*rc2*`) to decide whether PublicAPI.Unshipped.txt
changes should be flagged as an error. A branch like "release/11.0" is
created well before it reaches rtm/servicing status, so this heuristic
produced false positives for any pre-release stage it didn't explicitly
enumerate (e.g. rc3+).

Replace it with a check against the target branch's actual
PreReleaseVersionLabel (read from its eng/Versions.props via git show),
only flagging Unshipped.txt changes once the label is 'rtm' or
'servicing'. Fails closed if the ref/property can't be read or the label
is unrecognized.

Fixes dotnet#50635

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 27, 2026 18:05
@wtgodbe
wtgodbe requested a review from a team as a code owner July 27, 2026 18:05

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.

Pull request overview

Updates the API baseline checks in eng/scripts/CodeCheck.ps1 to determine whether PublicAPI.Unshipped.txt changes should be treated as errors based on the target branch’s PreReleaseVersionLabel from eng/Versions.props, rather than relying on branch-name heuristics that misclassify late RC stages.

Changes:

  • Reads origin/<targetBranch>:eng/Versions.props and parses PreReleaseVersionLabel, validating it against expected labels.
  • Treats PublicAPI.Unshipped.txt edits as errors only when the label is rtm or servicing.
  • Removes the previous release* / preview / rc1 / rc2 branch-name-based detection logic.

@wtgodbe
wtgodbe merged commit b13fa46 into dotnet:main Jul 27, 2026
28 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-rc1 milestone Jul 28, 2026
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.

Improve CodeCheck.ps1 experience for API changes during RCs

2 participants