DotCov 1.0.0
dotnet add package DotCov --version 1.0.0
NuGet\Install-Package DotCov -Version 1.0.0
<PackageReference Include="DotCov" Version="1.0.0" />
<PackageVersion Include="DotCov" Version="1.0.0" />
<PackageReference Include="DotCov" />
paket add DotCov --version 1.0.0
#r "nuget: DotCov, 1.0.0"
#:package DotCov@1.0.0
#addin nuget:?package=DotCov&version=1.0.0
#tool nuget:?package=DotCov&version=1.0.0
DotCov
Read Cobertura XML from your own code — parse, merge, threshold, and diff coverage reports. Zero package references, Native-AOT clean, and streaming rather than DOM-loading.
Getting started
dotnet add package DotCov
using DotCov;
using DotCov.Formatters;
var inputs = ReportResolver.Resolve("TestResults/"); // file or directory
var report = CoberturaParser.Parse(inputs)
.Exclude(ExclusionRules.WellKnown);
Console.WriteLine(TableFormatter.Format(report));
var gate = report.Evaluate(minLinePercent: 80, minBranchPercent: 60);
if (!gate.IsPass)
{
Console.Error.WriteLine(gate); // "NODATA: line n/a (min 80%) - …"
return 1;
}
ReportResolver.Resolve takes a file or a directory; a directory is searched for
**/*cobertura*.xml (pass a ReportPattern to change that) and Parse merges every
match, so a sharded test matrix needs no merge step. An existing directory with no match yields
no inputs and therefore an empty report; a missing path throws.
Two things the API insists on
Rates are double?. null means unanswerable — not 0.0, not 1.0. An empty report has
no rate, and treating that as 0% would fail a build that simply measured nothing.
A threshold check has four outcomes, not two. Evaluate returns a GateResult whose
Outcome is Pass, Fail, NoData, or Disabled; IsPass covers Pass alone. Branch on the
structured flags (LineBelowThreshold, BranchBelowThreshold, IsInconclusive) rather than
parsing Reason.
What else is in the box
// Compare two reports — added / removed / modified, per-file deltas, line-level flips
var diff = CoverageDiff.Compare(
CoberturaParser.Parse(ReportInput.FromFile("before.xml")),
CoberturaParser.Parse(ReportInput.FromFile("after.xml")));
foreach (var r in diff.Regressions)
Console.WriteLine($"{r.Path}: {r.Before:P1} → {r.After:P1}");
// Async streaming, cancellable
await using var stream = File.OpenRead("coverage.cobertura.xml");
var report = await CoberturaParser.ParseAsync(stream, ct: cancellationToken);
// Per-method detail — complexity and line hits, the input behind the CRAP gate
var methods = CoberturaParser.ParseMethods(ReportResolver.Resolve("TestResults/"));
// methods.Methods, methods.Warnings, methods.SourceRoots
TableFormatter, MarkdownFormatter, and JsonFormatter render a report for a terminal, a PR
comment, or a pipeline. Every numeric rendering is invariant-formatted: 62.0% on every host,
never 62,0%. CoverageSnapshot wraps a report with commit, branch, project, timestamp, and a
SHA-256 of the source file.
Parsing and safety
CoberturaParser walks the document with XmlReader — no XDocument.Load, no full-DOM
allocation, bounded memory. DTDs are prohibited and XmlResolver is null, so there is no XXE or
entity-expansion surface, and each file is capped at 50,000,000 characters by default. Raise or
remove the cap with the maxChars overloads (0 disables it).
The package has no PackageReferences at all and builds with the trim/AOT analyzers on and
warnings as errors, so AOT-cleanliness is enforced by the compiler rather than by convention.
Every public type carries XML docs — read them in IntelliSense or in the source.
Also in this family
DotCov.Tool — the dotcov CLI ·
DotCov.Fallout — Fallout build component
Feedback
Documentation · Issues · MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on DotCov:
| Package | Downloads |
|---|---|
|
DotCov.Nuke
NUKE build extension for Cobertura coverage reporting and CI gating. Installation: nuke :add-package DotCov.Nuke Usage in Build.cs: class Build : NukeBuild, ICoverageReport { } Run: nuke ReportCoverage --coverage-min-line 80 --coverage-exclude-generated true |
|
|
DotCov.Fallout
Fallout build component that merges Cobertura reports, writes a job summary, and fails the build below your line and branch coverage thresholds. Add ICoverageReport and go. |
GitHub repositories
This package is not used by any popular GitHub repositories.