CoverageChecker 0.9.0

dotnet add package CoverageChecker --version 0.9.0
                    
NuGet\Install-Package CoverageChecker -Version 0.9.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CoverageChecker" Version="0.9.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CoverageChecker" Version="0.9.0" />
                    
Directory.Packages.props
<PackageReference Include="CoverageChecker" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CoverageChecker --version 0.9.0
                    
#r "nuget: CoverageChecker, 0.9.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CoverageChecker@0.9.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CoverageChecker&version=0.9.0
                    
Install as a Cake Addin
#tool nuget:?package=CoverageChecker&version=0.9.0
                    
Install as a Cake Tool

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.
The AnalyseDeltaCoverage method interacts with the underlying Git repository and may throw a GitException if Git is not installed, not on the PATH, 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

  • Coverage property: A Coverage object containing only the filtered changed lines.
  • HasChangedLines property: Whether any changed lines were found in the coverage report.

Coverage Object

  • Files property: A collection of FileCoverage objects.
  • 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

  • Lines property: A collection of LineCoverage objects.
  • 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

  • Line property: The line number.
  • IsCovered property: Whether the line is covered.
  • Branches property: The number of branches in the line.
  • CoveredBranches property: The number of covered branches in the line.
  • ClassName property: The name of the class the line is part of.
  • MethodName property: The name of the method the line is part of.
  • MethodSignature property: 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 171 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 388 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