Table of Contents

CoverletTestSessionHandler Class

Definition

Exposes the legacy coverage session handler for compatibility with existing integrations.

public class CoverletTestSessionHandler : ITestSessionLifetimeHandler, ITestHostExtension, IExtension
Inheritance
CoverletTestSessionHandler
Implements

Examples

Identify an existing legacy session-handler registration during a migration. The enabled check currently returns true, but the public session callbacks throw NotImplementedException and the explicit interface callbacks recurse; this diagnostic deliberately does not execute them. Replace legacy registration with AddCoverletExtensionProvider to use the active collection path.

using System;
using System.Threading.Tasks;
using Coverlet.MTP.InProcDataCollection;

namespace CoverageTools.Migration;

public static class LegacyHandlerAudit
{
    public static async Task PrintAsync(CoverletTestSessionHandler handler)
    {
        bool enabled = await handler.IsEnabledAsync();
        Console.WriteLine($"{handler.DisplayName}: enabled={enabled}");
        Console.WriteLine("Replace this legacy registration before executing test sessions.");
    }
}

Remarks

This handler is not a working collection path. Public session callbacks throw NotImplementedException, and explicit interface callbacks recursively dispatch to themselves. Use CoverletExtensionProvider to register the active coverage integration.

Constructors

Name Description
CoverletTestSessionHandler()

Initializes the legacy handler with default settings.

CoverletTestSessionHandler(IConfiguration?, string)

Initializes the legacy handler by parsing configuration for a test module.

Properties

Name Description
Description

Gets the handler's advertised purpose; this does not imply implemented session callbacks.

DisplayName

Gets the handler name displayed by MTP.

Uid

Gets the identifier of the legacy handler.

Version

Gets the extension assembly version, falling back to 1.0.0 when unavailable.

Methods

Name Description
IsEnabledAsync()

Reports that the legacy handler is enabled, independently of configuration.

OnTestSessionFinishingAsync(ITestSessionContext)

Exposes the unimplemented legacy session-finish callback.

OnTestSessionStartingAsync(ITestSessionContext)

Exposes the unimplemented legacy session-start callback.