Visitar URL original
Fix merging of code coverage reports by evgenyfedorov2 · Pull Request #7891 · dotnet/extensions · GitHub
Skip to content

Fix merging of code coverage reports - #7891

Merged
evgenyfedorov2 merged 2 commits into
dotnet:mainfrom
evgenyfedorov2:evgenyfedorov2-code-coverage-issues
Nov 2, 2026
Merged

evgenyfedorov2 merged 2 commits into
dotnet:mainfrom
evgenyfedorov2:evgenyfedorov2-code-coverage-issues

Conversation

@evgenyfedorov2

@evgenyfedorov2 evgenyfedorov2 commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Fixes #4124

dotnet-coverage merge loses branch data for lines that are partially covered in both the Windows and Ubuntu reports, so the branch coverage of the merged report was wrong. For example, Microsoft.Extensions.TimeProvider.Testing showed 100% while both reports have 97.5%. The per-project check also used the numbers from dotnet-coverage, while the Code Coverage tab shows the numbers from ReportGenerator, so the two didn't match.

Now ReportGenerator merges the two reports and writes both the HTML report and a merged Cobertura file. The publish step and the per-project check both use that file, so they show the same numbers.

With the correct numbers, 15 projects that passed before are below their MinCodeCoverage, so I lowered it to match. Five of them were at 100, so for those a drop in coverage will now be a warning instead of a build failure.

Microsoft Reviewers: Open in CodeFlow

dotnet-coverage merge loses branch data for lines that are partially
covered in both the Windows and Ubuntu reports, so the branch coverage
of the merged report was wrong. The per-project check also used the
numbers from dotnet-coverage, while the Code Coverage tab shows the
numbers from ReportGenerator, so the two didn't match.

Merge the reports with ReportGenerator, which writes both the HTML
report and a merged Cobertura file, and use that file for publishing
and for the per-project check.

Lower MinCodeCoverage for the projects that are below it with the
correct numbers.

Fixes dotnet#4124
@evgenyfedorov2
evgenyfedorov2 requested review from a team as code owners October 27, 2026 17:02
Copilot AI balanced review requested due to automatic review settings October 27, 2026 17:02

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

Human review should confirm the revised thresholds against cross-platform pipeline reports before accepting the relaxation of five blocking coverage gates.

No open issues 🎉

What changed in this PR

Addresses #4124 by using ReportGenerator to merge Windows and Ubuntu coverage reports, preserving branch coverage and aligning published results with per-project checks.

Changes:

  • Generate HTML and merged Cobertura output in one ReportGenerator step.
  • Use the merged Cobertura file for both publishing and threshold validation.
  • Lower 15 project thresholds to reflect corrected coverage; five previously blocking gates become warnings.
File Description
src/​Libraries/​Microsoft.Extensions.TimeProvider.Testing/​Microsoft.Extensions.TimeProvider.Testing.csproj Lower minimum coverage from 100% to 97%.
src/​Libraries/​Microsoft.Extensions.Http.Diagnostics/​Microsoft.Extensions.Http.Diagnostics.csproj Lower minimum coverage from 94% to 91%.
src/​Libraries/​Microsoft.Extensions.Diagnostics.Probes/​Microsoft.Extensions.Diagnostics.Probes.csproj Lower minimum coverage from 76% to 71%.
src/​Libraries/​Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization/​Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.csproj Lower minimum coverage from 100% to 92%.
src/​Libraries/​Microsoft.Extensions.Diagnostics.HealthChecks.Common/​Microsoft.Extensions.Diagnostics.HealthChecks.Common.csproj Lower minimum coverage from 98% to 96%.
src/​Libraries/​Microsoft.Extensions.Diagnostics.ExceptionSummarization/​Microsoft.Extensions.Diagnostics.ExceptionSummarization.csproj Lower minimum coverage from 100% to 97%.
src/​Libraries/​Microsoft.Extensions.DataIngestion.Abstractions/​Microsoft.Extensions.DataIngestion.Abstractions.csproj Lower minimum coverage from 75% to 71%.
src/​Libraries/​Microsoft.Extensions.Compliance.Redaction/​Microsoft.Extensions.Compliance.Redaction.csproj Lower minimum coverage from 100% to 94%.
src/​Libraries/​Microsoft.Extensions.Compliance.Abstractions/​Microsoft.Extensions.Compliance.Abstractions.csproj Lower minimum coverage from 100% to 99%.
src/​Libraries/​Microsoft.Extensions.Caching.Hybrid/​Microsoft.Extensions.Caching.Hybrid.csproj Lower minimum coverage from 82% to 81%.
src/​Libraries/​Microsoft.AspNetCore.Diagnostics.Middleware/​Microsoft.AspNetCore.Diagnostics.Middleware.csproj Lower minimum coverage from 98% to 94%.
src/​Generators/​Microsoft.Gen.Metrics/​Microsoft.Gen.Metrics.csproj Lower minimum coverage from 99% to 97%.
src/​Generators/​Microsoft.Gen.Logging/​Microsoft.Gen.Logging.csproj Lower minimum coverage from 99% to 98%.
src/​Generators/​Microsoft.Gen.ComplianceReports/​Microsoft.Gen.ComplianceReports.csproj Lower minimum coverage from 98% to 96%.
src/​Generators/​Microsoft.Gen.BuildMetadata/​Microsoft.Gen.BuildMetadata.csproj Lower minimum coverage from 97% to 94%.
eng/​pipelines/​templates/​VerifyCoverageReport.yml Merge with ReportGenerator and share its Cobertura output across publishing and validation.

Review effort: Balanced

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.AI Line 89 87.21 🔻
Microsoft.Extensions.AI Branch 89 79.21 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.82 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 60.26 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0.75 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.06 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.28 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Branch 99 92.86 🔻
Microsoft.Extensions.Diagnostics.Testing Line 99 98.22 🔻
Microsoft.Extensions.Diagnostics.Testing Branch 99 93.71 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 62.21 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 64.06 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 41.14 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 45.1 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 64.49 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Branch 75 74.08 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 60 🔻
Microsoft.Extensions.Telemetry Line 93 90.46 🔻
Microsoft.Extensions.Telemetry Branch 93 86.78 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 32.15 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 26.31 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.AI.Evaluation.NLP 0 74
Microsoft.Extensions.DataIngestion 75 77
Microsoft.Extensions.DataIngestion.Markdig 75 88
Microsoft.Extensions.Http.Resilience 97 99
Microsoft.Gen.MetadataExtractor 57 72
Microsoft.Gen.MetricsReports 67 69

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1651157&view=codecoverage-tab

@amadeuszl amadeuszl 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.

lgtm

@evgenyfedorov2
evgenyfedorov2 merged commit 8641467 into dotnet:main Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Code coverage issues

4 participants