Skip to content

.NET: Add advisory changed-line coverage check - #10516

Open
Vincent Biret (baywet) wants to merge 4 commits into
mainfrom
ci/dotnet-change-coverage
Open

Vincent Biret (baywet) wants to merge 4 commits into
mainfrom
ci/dotnet-change-coverage

Conversation

@baywet

@baywet Vincent Biret (baywet) commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Motivation & Context

The existing .NET coverage threshold protects core assemblies in aggregate, but it does not tell authors whether the executable lines they changed are at least as well tested as the implementation overall.

Description & Review Guide

  • What are the major changes? Add a repository skill for running the .NET unit suite, merging Cobertura reports, and comparing changed executable C# lines with all tracked implementation lines measured by the same run. Use the same PowerShell comparison in a PR-only job fed by the existing Linux coverage artifact.
  • What is the impact of these changes? The job reports percentages and uncovered locations without affecting the existing required check. Missing coverage for a changed source file is reported as inconclusive rather than as a pass.
  • What do you want reviewers to focus on? The comparison denominator, path and line matching, and the separation between the advisory result and the existing coverage gate.

Verified the comparison with pwsh -NoProfile -File against Git/Cobertura fixtures and an actual CI coverage artifact. git diff --check passed. actionlint .github/workflows/dotnet-build-and-test.yml reported only the same two findings as main, for existing GitHub Actions features.

dotnet test --solution $solution -f net11.0 -c Release -p:CopilotSkipCliDownload=true --coverage --coverage-output-format cobertura --coverage-settings (Join-Path $PWD 'tests/coverage.runsettings') --results-directory $results --ignore-exit-code 8 passed against the filtered unit solution: 11,850 passed, 84 skipped, and none failed. dotnet tool exec dotnet-reportgenerator-globaltool@5.6.1 -- "-reports:$results/**/*.cobertura.xml" "-targetdir:$merged" '-reporttypes:Cobertura' merged all 34 reports. The comparison reported no changed implementation lines for this PR, as expected.

Related Issue

Related to #3391. This is an advisory changed-line check, not the required whole-solution regression gate described in that issue, so it leaves the issue open.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Comparison script, workflow, repository skill, test fixtures, and PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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 advisory is skipped when dotnet-test fails, preventing changed-line coverage comparisons even when usable coverage artifacts have already been uploaded.

1 open issue
What changed in this PR

Adds advisory changed-line coverage reporting for .NET, complementing the existing coverage gate without implementing the blocking regression gate proposed in #3391.

Changes:

  • Compares changed executable C# lines with global coverage from the same report.
  • Adds a non-blocking PR job using the existing Linux coverage artifact.
  • Documents local coverage generation and result handling.
File Description
dotnet/​eng/​scripts/​Measure-DotnetChangeCoverage.ps1 Calculates coverage comparisons and reports uncovered or missing files.
dotnet/​AGENTS.md Directs contributors to check changed-line coverage.
.github/​workflows/​dotnet-build-and-test.yml Adds the advisory PR coverage job.
.github/​skills/​dotnet-change-coverage/​SKILL.md Documents coverage generation, comparison, and follow-up actions.

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

🔵 Needs a closer look

PowerShell 7.3 can leave failed Git calls unhandled, causing an unavailable base ref to produce a misleading no-changes result; the script and documentation need a PowerShell 7.4 minimum.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Require PowerShell 7.4 for native-command error handling

dotnet/​eng/​scripts/​Measure-DotnetChangeCoverage.ps1:1

In PowerShell 7.3, native-command error handling is experimental, so setting $PSNativeCommandUseErrorActionPreference does not stop failed Git calls unless the feature is enabled. An unavailable base ref can therefore produce a misleading “No added or modified .NET implementation lines” result instead of failing. Require PowerShell 7.4, where this feature is stable, and update the minimum version in .github/skills/dotnet-change-coverage/SKILL.md:15 to match.

1 resolved since last review

Review effort: Balanced

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@baywet

Copy link
Copy Markdown
Member Author

Addressed the PowerShell compatibility finding in 7c8a286. The script and skill now require PowerShell 7.4 or later. I verified that an invalid base ref fails with a nonzero exit code and does not report a no-change result.

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.

🟢 Approval recommended

No active review issues were identified for the advisory .NET changed-line coverage reporting change.

No open issues 🎉

Review effort: Balanced

@github-code-quality

github-code-quality Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage overview

Languages: C#

C# / code-coverage/dotnet

main 20222f0 ci/dotnet-change-cov... 4e84c61 +/-
91% 91% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated December 03, 2026 14:52 UTC

This branch was previously deployed

1 inactive deployment
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.

2 participants