Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bddckr opened this issue Jun 21, 2020 · 3 comments · Fixed by #884
Closed

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

bddckr opened this issue Jun 21, 2020 · 3 comments · Fixed by #884
Labels
bug Something isn't working

Comments

@bddckr
Copy link
Contributor

bddckr commented Jun 21, 2020

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"));
@MarcoRossignoli MarcoRossignoli added the bug Something isn't working label Jun 22, 2020
@MarcoRossignoli
Copy link
Collaborator

Thank's for reporting this, feel free to provide a PR with some tests if you want(not obligated at all btw).

@bddckr
Copy link
Contributor Author

bddckr commented Jun 22, 2020

Thanks for checking in!

Will do, hopefully during the next 7 days.

@MarcoRossignoli
Copy link
Collaborator

No probs at all, at your pace!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants