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

VSTest integration: Is ExcludeByAttribute supported? #917

Closed
StefanOssendorf opened this issue Jul 30, 2020 · 2 comments
Closed

VSTest integration: Is ExcludeByAttribute supported? #917

StefanOssendorf opened this issue Jul 30, 2020 · 2 comments
Labels
Solved The issue is solved and can be closed

Comments

@StefanOssendorf
Copy link

Hey guys,

is the option ExcludeByAttribute supported by the VSTest integreation?
The documentation does not list it as supported but the example file below includes the option.

I am asking because I have weird results when using it. When I add <ExcludeByAttribute>GeneratedCodeAttribute,CompilerGeneratedAttribute</ExcludeByAttribute> in my settings file not only code with the attributes get removed but also the coverage ignores complete methods from tested classes without the attributes.
Unfortunately I am not able to reproduce it with a new project and I can't share the code (work) :-/.

Perhaps I can share the generated cobertura files if that's enough and I get permission to do so.

Thanks in advance

@MarcoRossignoli MarcoRossignoli added bug Something isn't working documentation labels Aug 17, 2020
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Aug 17, 2020

Hi @StefanOssendorf sorry for late response I was on vacation.

is the option ExcludeByAttribute supported by the VSTest integreation?

Yes ExcludeByAttribute is supported and we have to update guide. Param ref https://github.com/coverlet-coverage/coverlet/blob/master/src/coverlet.collector/DataCollection/CoverletSettings.cs#L44

I am asking because I have weird results when using it. When I add GeneratedCodeAttribute,CompilerGeneratedAttribute in my settings file not only code with the attributes get removed but also the coverage ignores complete methods from tested classes without the attributes.

This happens because you cannot use CompilerGeneratedAttribute because every async/await code you use in your code will be trimmed out because that statements generates a state machine class(Roslyn compiler does it) with that attributes on top of class. So you don't see that code in coverage.

Take a look here #794 (comment)

@StefanOssendorf
Copy link
Author

Sorry for my way too late response.
Yeah the CompilerGeneratedAttribute makes sense. Should have seen that.
Thanks for the link to 497. The skip autoproperties option is awesome. 👍🏻

@MarcoRossignoli MarcoRossignoli added Solved The issue is solved and can be closed and removed bug Something isn't working documentation labels Jan 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Solved The issue is solved and can be closed
Projects
None yet
Development

No branches or pull requests

2 participants