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.

Lambdas in a method marked ExcludeForCodeCoverage are showing up in report

See original GitHub issue

Issue: Code that is in a function that has the [ExcludeFromCodeCoverage] attribute but contains a lambda is getting picked up in the coverage when it should not be due to the attribute.

image

Toolset:

  • .NET Core: 3.1
  • Coverlet.Collector: 1.2.0
  • ReportGenerator: 4.4.6
  • Command: dotnet test --collect:"XPlat Code Coverage" --settings code-coverage.runsettings

code-coverage.runsettings

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <ExcludeByAttribute>Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverageAttribute</ExcludeByAttribute>
          <SingleHit>false</SingleHit>
          <UseSourceLink>true</UseSourceLink>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
acgrittcommented, Feb 10, 2020

The nightly build does fix the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambdas in a method marked ExcludeForCodeCoverage ...
Issue: Code that is in a function that has the [ExcludeFromCodeCoverage] attribute but contains a lambda is getting picked up in the coverage ......
Read more >
C# - Exclude lambda expression from code coverage
I have marked the event with [ExcludeFromCodeCoverage] and that seems to exclude the event which in this case is what I wanted.
Read more >
Add Test Coverage to your Serverless Applications
This detailed report will show our code (line-by-line) with execution counts and highlights showing us uncovered statements, branches, and ...
Read more >
SonarQube for .Net project, code coverage not excluding file ...
Coding example for the question SonarQube for .Net project, code coverage not excluding file marked with "ExcludeFromCodeCoverage"-C#.
Read more >
C# static code analysis: Methods without side effects ...
All<TSource> method should be used to determine if all elements satisfy a condition and not to change their state. Exceptions. This rule doesn't...
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