Runtime: [ExcludeFromCodeCoverageAttribute] should be applicable to assemblies

Created on 17 Oct 2017  路  12Comments  路  Source: dotnet/runtime

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
api-approved area-System.Diagnostics

All 12 comments

@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.

Video

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)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iCodeWebApps picture iCodeWebApps  路  3Comments

bencz picture bencz  路  3Comments

matty-hall picture matty-hall  路  3Comments

chunseoklee picture chunseoklee  路  3Comments

jchannon picture jchannon  路  3Comments