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

Assembly marked as ExcludeFromCodeCoverage is not excluded #290

Closed
SefaOray opened this issue Jan 10, 2019 · 15 comments · Fixed by #589
Closed

Assembly marked as ExcludeFromCodeCoverage is not excluded #290

SefaOray opened this issue Jan 10, 2019 · 15 comments · Fixed by #589
Labels
feature-request New feature request

Comments

@SefaOray
Copy link

Description
When an assembly decorated with ExcludeFromCodeCoverage attribute, it is not excluded from coverage report.

Repro steps
Example code:

using System.Diagnostics.CodeAnalysis;
using System

[assembly: ExcludeFromCodeCoverage]
namespace ExampleNs
{
    public class ExampleClass:
    {
        public Guid Id { get; set; }
    }
}

Expected behavior
Assembly is excluded from the coverage report

Actual behavior
Assembly is included in the coverage report

Known workarounds
Passing the assembly with --exclude "[Assembly]*" works

Related information
Cross platform .NET Core code coverage tool version 1.3.0.0
Visual Studio Version: Visual Studio Professional 2017
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Test project build with .Net Core 2.1

@tonerdo tonerdo added the as-designed Expected behaviour label Jan 10, 2019
@tonerdo
Copy link
Collaborator

tonerdo commented Jan 10, 2019

@SefaOray exclusion attributes don't work on assemblies by design. The --exclude property is provided for achieving the same.

@sshukurov
Copy link

@tonerdo could you please clarify? I have the same issue here, and ExcludeFromCodeCoverage must work on assemblies https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute.

@tonerdo
Copy link
Collaborator

tonerdo commented Jan 15, 2019

exclusion attributes don't work on assemblies by design

@sshukurov by this I mean that Coverlet doesn't check for attributes on assemblies. It does however, have an exclude option that supports specifying assemblies

@sshukurov
Copy link

sshukurov commented Jan 15, 2019

@tonerdo it's a pity. I want to define all my exclusions in code, so that different code coverage tools can reuse them.

@zmhh
Copy link

zmhh commented May 16, 2019

Agree that ExcludeFromCodeCoverage should work for assemblies unless there is a reason not to.

@olivier-spinelli
Copy link

This should be supported. May this issue be reopened? (And eventually handled... this should not be too complicated to implement.)

@bhales42
Copy link

bhales42 commented Oct 1, 2019

This would be useful. I usually execute unit tests and coverage multiple ways: IDE, command line, etc. Declaring this in an assembly attribute would apply to all methods.

@MarcoRossignoli MarcoRossignoli added feature-request New feature request up-for-grabs Good issue for contributors and removed as-designed Expected behaviour labels Oct 2, 2019
@MarcoRossignoli
Copy link
Collaborator

@tonerdo I re-opened this issue, I think we should support this behaviour because it's a default for most coverage tools.
If you don't agree please let me know.
@petli what do you think?

@MarcoRossignoli MarcoRossignoli added discussion Generic discussion on something and removed up-for-grabs Good issue for contributors labels Oct 2, 2019
@MarcoRossignoli MarcoRossignoli removed the discussion Generic discussion on something label Oct 12, 2019
@MarcoRossignoli
Copy link
Collaborator

Guys if someone of you can trust the feature we'll be more confident.
Will be testable with nightly build tomorrow you can follow this steps https://github.com/tonerdo/coverlet/blob/master/Documentation/ConsumeNightlyBuild.md

@simonness
Copy link

@MarcoRossignoli @tonerdo this is exactly what we need :) Is there an ETA for when this fix will be released?

@MarcoRossignoli
Copy link
Collaborator

@simonness can you try with nightly to confirm the fix?

Is there an ETA for when this fix will be released?

We don't have a strict release plan at the moment(we're working on it) my idea is one release every quarter(if there are bug we'll release immediatly), so I think for the end of the year, last release 23 Sep https://github.com/tonerdo/coverlet/blob/master/Documentation/ReleasePlan.md#proposed-next-versions

@ghost
Copy link

ghost commented Jul 29, 2020

I still see the same issue in VS 2019 with collector v.1.3.0. Can someone help?

@MarcoRossignoli
Copy link
Collaborator

@Pedramrezaei can you open a new issue?Do you want to skip all assembly?

@flytrapper
Copy link

When you look at the attribute (link below) it specifies it is valid on assemblies, yet it doesn't change the output. Is this an error in documentation?

https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.codeanalysis.excludefromcodecoverageattribute?view=net-5.0

@sbojarczak
Copy link

sbojarczak commented Mar 9, 2023

guys, does it work already? if yes, from which version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature request
Projects
None yet
10 participants