CoverageChecker 0.9.0
dotnet add package CoverageChecker --version 0.9.0
NuGet\Install-Package CoverageChecker -Version 0.9.0
<PackageReference Include="CoverageChecker" Version="0.9.0" />
<PackageVersion Include="CoverageChecker" Version="0.9.0" />
<PackageReference Include="CoverageChecker" />
paket add CoverageChecker --version 0.9.0
#r "nuget: CoverageChecker, 0.9.0"
#:package CoverageChecker@0.9.0
#addin nuget:?package=CoverageChecker&version=0.9.0
#tool nuget:?package=CoverageChecker&version=0.9.0
Coverage Checker Library
The Coverage Checker library is a .NET library for extracting code coverage metrics from various code coverage formats. It is intended to be used as a development dependency if you need to extract code coverage metrics as part of a .NET project.
For general information about the Coverage Checker project, see the repository's main README file.
Installation
To use the Coverage Checker library in your .NET project, add the CoverageChecker NuGet package to your project:
dotnet add package CoverageChecker
Usage
The CoverageAnalyser class is the entry point for extracting code coverage metrics from a coverage file.
The following example shows how to use the CoverageAnalyser class to extract code coverage metrics from specific
coverage files while filtering the results to only include specific source files:
using CoverageChecker;
CoverageAnalyserOptions options = new()
{
CoverageFormat = CoverageFormat.Auto,
Directory = ".",
GlobPatterns = ["**/coverage.xml"],
Include = ["src/**"], // Only analyze source files under src/
Exclude = ["**/Generated/**"] // Exclude any files in a "Generated" directory
};
CoverageAnalyser coverageAnalyser = new(options);
Coverage coverage = coverageAnalyser.AnalyseCoverage();
// Analyse only changed lines compared to origin/main
DeltaResult delta = coverageAnalyser.AnalyseDeltaCoverage("origin/main", coverage);
By using CoverageFormat.Auto, the library will attempt to detect whether each coverage file is in Cobertura or
SonarQube format. You can also specify a specific format if it is known.
Note: Delta coverage analysis requires Git to be installed and available on the system
PATH.
TheAnalyseDeltaCoveragemethod interacts with the underlying Git repository and may throw aGitExceptionif Git is not installed, not on thePATH, the current directory is not a Git repository, or if Git commands fail.
Options
The CoverageAnalyserOptions class has the following properties:
CoverageFormat: The format of the coverage file. Options:Auto,SonarQube,Cobertura. Default:Auto.Directory: The directory to search for the coverage file(s) within.GlobPatterns: The glob patterns to use to search for the coverage report file(s). Default:**/*.xml.Include: Optional glob patterns of source files to include in the analysis.- Patterns are matched relative to the Git repository root (or current directory fallback).
- Supports the
!prefix for negative patterns (e.g.,!**/*Tests.cs). - If specified, only source files matching at least one include pattern will be processed.
Exclude: Optional glob patterns of source files to exclude from the analysis.- Matches are removed from the set of included files.
- Useful for skipping generated code or third-party libraries.
The CoverageAnalyser class can be initialized with either an instance of CoverageAnalyserOptions or with an options instance and a Matcher.
Results
The CoverageAnalyser class returns a Coverage object, which contains all the code coverage metrics. The Coverage
object can contain multiple FileCoverage objects, which can each contain multiple LineCoverage objects.
DeltaResult Object
Coverageproperty: ACoverageobject containing only the filtered changed lines.HasChangedLinesproperty: Whether any changed lines were found in the coverage report.
Coverage Object
Filesproperty: A collection ofFileCoverageobjects.CalculateOverallCoverage(coverageType)method: Calculates the overall code coverage of the specified type for all files.CalculatePackageCoverage(packageName, coverageType)method: Calculates the code coverage of the specified type for all files that are part of the specified package.
FileCoverage Object
Linesproperty: A collection ofLineCoverageobjects.CalculateFileCoverage(coverageType)method: Calculates the code coverage of the specified type for the file.CalculateClassCoverage(className, coverageType)method: Calculates the code coverage of the specified type for all lines that are part of the specified class.CalculateMethodCoverage(methodName, coverageType)method: Calculates the code coverage of the specified type for all lines that are part of the specified method.
LineCoverage Object
Lineproperty: The line number.IsCoveredproperty: Whether the line is covered.Branchesproperty: The number of branches in the line.CoveredBranchesproperty: The number of covered branches in the line.ClassNameproperty: The name of the class the line is part of.MethodNameproperty: The name of the method the line is part of.MethodSignatureproperty: The method signature of the method the line is part of.CalculateLineCoverage(coverageType)method: Calculates the code coverage of the specified type for the line.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Extensions.FileSystemGlobbing (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
-
net8.0
- Microsoft.Extensions.FileSystemGlobbing (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
-
net9.0
- Microsoft.Extensions.FileSystemGlobbing (>= 8.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.9.0 | 124 | 2/15/2026 |
| 0.8.0 | 118 | 1/11/2026 |
| 0.7.0 | 186 | 10/4/2025 |
| 0.6.6 | 172 | 9/28/2025 |
| 0.6.5 | 171 | 11/24/2024 |
| 0.6.4 | 168 | 11/13/2024 |
| 0.6.3 | 172 | 11/10/2024 |
| 0.6.2 | 163 | 11/10/2024 |
| 0.6.1 | 168 | 10/25/2024 |
| 0.6.0 | 180 | 10/20/2024 |
| 0.5.1 | 164 | 9/29/2024 |
| 0.5.0 | 168 | 9/29/2024 |
| 0.4.0 | 187 | 9/7/2024 |
| 0.3.1 | 390 | 7/12/2024 |
| 0.3.0 | 186 | 7/7/2024 |
| 0.2.2 | 172 | 6/14/2024 |
| 0.2.1 | 185 | 6/13/2024 |
| 0.2.0 | 170 | 6/9/2024 |
| 0.1.0 | 178 | 6/8/2024 |