Following up on https://github.com/Microsoft/vstest/issues/1050, https://github.com/Microsoft/testfx/issues/248, https://github.com/dotnet/corefx/issues/14488.
As of now System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute has the following signature:
[AttributeUsageAttribute
(AttributeTargets.Class |
AttributeTargets.Struct |
AttributeTargets.Constructor |
AttributeTargets.Method |
AttributeTargets.Property |
AttributeTargets.Event,
Inherited = false, AllowMultiple = false)]
public sealed class ExcludeFromCodeCoverageAttribute : Attribute
what doesn't allow to apply it to assemblies.
I'd like to have the code like this in every tests project's AssemblyInfo.cs:
[assembly: ExcludeFromCodeCoverage]
I talked to @pvlakshm, a PM on the VS Unit Testing Framework, we agreed this would be a good enhancement which they would pick-up and address once the following API change has been made:
[AttributeUsageAttribute
(AttributeTargets.Assembly | // <--
AttributeTargets.Class |
AttributeTargets.Struct |
AttributeTargets.Constructor |
AttributeTargets.Method |
AttributeTargets.Property |
AttributeTargets.Event,
Inherited = false, AllowMultiple = false)]
public sealed class ExcludeFromCodeCoverageAttribute : Attribute
@karelz hi, what can be done to put some wind in the sails of this issue?
See API review process (it's due some minor updates I guess).
First, it has to go through area owners triage / first-level review - @joperezr @wtgodbe. Needs to be checked for feasibility, compat impact, etc. Then submitted for final API review which happens on Tuesdays.
This proposal looks reasonable and useful. Marking it as ready for review.
we agreed this would be a good enhancement which they would pick-up and address once the following API change has been made
Also, OpenCover will work with it immediately (as it did with the private implementation in CoreFX and does now with the private ExcludeFromCodeCoverageAssembly attribute, or indeed any attribute whose name matches *.ExcludeFromCodeCoverage*) and I think NCover will similarly just light up.
As long as we're working with the code coverage tool providers to make it's honored, I sounds good (and it seems we are).
It may be niche to want to exclude a whole assembly, but I've been in that niche!
and it seems we are
We are, indeed.
@joperezr you marked this as up-to-grabs. I can submit a pr, sees easy. But what else I should touch/update? Tests, spec?
@abatishchev I've already submitted dotnet/corefx#25414 for this, though I'm going to add in removing the ExcludeFromCodeCoverageAssemblyAttribute it makes obsolete too. It's just taking a bit of time to test since I need to a full build.
Awesome, thanks! Unfortunate GitHub doesn't send email notifications when metadata (like tags) or links are getting updated, I think that's how I missed this.
Well, maybe you can see what I'm getting wrong as per my comment here https://github.com/dotnet/corefx/pull/25414#issuecomment-346179312 馃槩
FYI: The API review discussion was recorded - see https://youtu.be/o5JFZtgaJLs?t=1084 (1 min duration)