question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Assembly marked as ExcludeFromCodeCoverage is not excluded

See original GitHub issue

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 ® Test Execution Command Line Tool Version 15.9.0 Test project build with .Net Core 2.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15

github_iconTop GitHub Comments

7reactions
MarcoRossignolicommented, Oct 2, 2019

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

6reactions
sshukurovcommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to specify ExcludeFromCodeCoverage at assembly ...
This works in at least .NET 6 and .NET Standard 2.1. It definitely doesn't work in .NET Standard 2.0 as the [ExcludeFromCodeCoverage] attribute ......
Read more >
ExcludeFromCodeCoverageAttri...
Initializes a new instance of the ExcludeFromCodeCoverageAttribute class. Properties. Justification. Gets or sets the justification for excluding the member ...
Read more >
Code Coverage doesn't take into account the ...
Currently I have a class under test where the whole class is marked with [ExcludeFromCodeCoverage]. i do have a couple of unit tests...
Read more >
C# static code analysis: "ExcludeFromCodeCoverage" ...
The ExcludeFromCodeCoverageAttribute is used to exclude portions of code from code ... It is a bad practice to retain code that is not...
Read more >
How to exclude code from code coverage
The easiest way to exclude code from code coverage analysis is to use ExcludeFromCodeCoverage attribute. This attribute tells tooling that class ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found