Skip to content

Attribute exclusion does not work if attribute name does not end with "Attribute" #883

@bddckr

Description

@bddckr

I came across the same issue as #604 and added TestSDKAutoGeneratedCode to my ExcludeByAttribute usage (I'm using the MSBuild integration).

However, it looks like coverlet assumes all attributes' type names will end with Attribute:

return excludeAttributeNames.Any(a =>
customAttribute.AttributeType.Name.Equals(a.EndsWith("Attribute") ? a : $"{a}Attribute"));

That isn't the case for TestSDKAutoGeneratedCode:
https://github.com/microsoft/vstest/blob/50b5b33261f7593eb92ae221dae1b9c74234207e/src/Microsoft.TestPlatform.ObjectModel/CodeCoverage/TestSDKAutoGeneratedCode.cs#L10

I believe the fix would be to do something like this, to keep the original functionality:

return excludeAttributeNames.Any(a =>
    a.EndsWith("Attribute")
        ? customAttribute.AttributeType.Name.Equals(a)
        : customAttribute.AttributeType.Name.Equals($"{a}Attribute"));

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions