Sitelet https://github.com/coverlet-coverage/coverlet/issues/1828
Skip to content

Coverlet Tracker Missing CompilerGeneratedAttribute #1828

Description

@Werebunny

Describe the bug
The generated coverage tracker is no longer (or never actually was) marked with the CompilerGeneratedAttribute.

To Reproduce
Here's a sample test that'll fail. Replace 'typeof(ToolSet)' with your own and use whatever test framework you wish:

[Fact]
internal static void FindCoverletTrackerIssue()
{
    Type tracker = Assembly
        .GetAssembly(typeof(ToolSet))
        .GetTypes()
        .Single(t =>
            t.Namespace?.StartsWith(
                "Coverlet.Core.Instrumentation.Tracker",
                StringComparison.Ordinal
            ) ?? false
        );
    tracker.IsDefined(typeof(CompilerGeneratedAttribute), false).Assert().Is(true);
}

Expected behavior
This test should pass. Setting 'true' for inherited attributes doesn't change the result.

Actual behavior
The test fails. In fact, the generated static class "Coverlet.Core.Instrumentation.Tracker.{assemblyName}_{guid}" contains no defined custom attributes.

Configuration (please complete the following information):
Coverlet version: 8.0.0 (bug also found on 6.0.4) via dotnet test --collect:"XPlat Code Coverage"
Library .NET versions: .NET 10 and .NET Standard 2.0
Test .NET versions: .NET 10, .NET 9 and .NET 4.8
OS: Mac and Windows Server 2025

Additional context
The CompilerGeneratedAttribute was supposedly added as part of #1229 due to issue #1191.
It is not clear to me that this change ever actually added the CompilerGeneratedAttribute to the resulting created Tracker however.

❗ Please also read Known Issues

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SolvedThe issue is solved and can be closedbugSomething isn't workingcoverlet-core

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions