Table of Contents

CoverletMTPSettings Class

Definition

Describes coverage filters, reports and threshold settings for the MTP integration.

public class CoverletMTPSettings
Inheritance
CoverletMTPSettings

Examples

Print a coverage-settings snapshot to help diagnose filters and threshold expectations. This object describes requested values and its ToString output exposes the configured filters and threshold; constructing it does not configure the MTP runner. Apply actual run settings through the package command line or configuration file.

using System;
using Coverlet.MTP.Configuration;

namespace CoverageTools.Diagnostics;

public static class CoverageSettingsSnapshot
{
    public static void Print(string testModule)
    {
        var settings = new CoverletMTPSettings
        {
            TestModule = testModule,
            ReportFormats = new[] { "json", "cobertura" },
            IncludeFilters = new[] { "[Orders]*" },
            Threshold = 80
        };
        Console.WriteLine(settings.ToString());
        Console.WriteLine("Report formats: " + string.Join(", ", settings.ReportFormats));
    }
}

Properties

Name Description
DeterministicReport

Gets or sets whether deterministic coverage report output is requested.

DisableManagedInstrumentationRestore

Gets or sets whether restoring original instrumented modules through managed code is disabled.

DoesNotReturnAttributes

Gets or sets attribute names used to identify methods that do not return.

ExcludeAssembliesWithoutSources

Gets or sets the source-availability policy: MissingAll, MissingAny or None. The default is MissingAll.

ExcludeAttributes

Gets or sets attribute names that exclude annotated code from coverage.

ExcludeFilters

Gets or sets assembly/type filters excluded from coverage. New instances exclude coverlet.* assemblies.

ExcludeSourceFiles

Gets or sets source-file glob patterns excluded from coverage.

IncludeDirectories

Gets or sets additional directories to search for assemblies.

IncludeFilters

Gets or sets the assembly/type filters eligible for coverage.

IncludeTestAssembly

Gets or sets whether test-assembly instrumentation is requested where the execution model permits it.

IsFromConfigFile

Indicates whether this settings object was loaded from a configuration file. When true, defaults should not be applied - all values are user-defined. When false, built-in defaults should be applied for unspecified options.

MergeWith

Gets or sets the path to an existing coverage JSON result to merge, or null for no merge.

ReportFormats

Gets or sets the requested coverage report formats. A new settings instance requests Cobertura.

SingleHit

Gets or sets whether each instrumented location records only its first hit.

SkipAutoProps

Gets or sets whether automatically implemented properties are excluded from instrumentation.

TestModule

Gets or sets the path to the test assembly to instrument.

Threshold

Gets or sets the required coverage percentage, or null to disable threshold checking.

ThresholdType

Gets or sets the coverage dimensions checked against the threshold. New instances check line coverage.

UseSourceLink

Gets or sets whether reports use Source Link URLs in place of local source paths.

Methods

Name Description
ToString()

Formats instrumentation and threshold settings for diagnostics.