dotnet / dotnet/core

How to exclude a lambdas from Code Coverage?

Open
#4,361 8 comments 0 reactions 0 assignees View on GitHub
Dominant language
PowerShell
Stars
22k
Forks
4.9k
Avg merge
5d 5h
Merged PRs (30d)
29

Description

I'm using the Visual Studio Code Coverage tools on some Unittests against a couple of DotNet Core projects (Asp.net core and Azure Function).

I have a couple of methods excluded from code coverage via the ExcludeFromCodeCoverage attribute. These methods have lambda expressions which code coverage still wants to include.

Is there a way to to exclude the lambda inside these methods from code coverage?

For example: it says that x == "test" is not covered.
```
[ExcludeFromCodeCoverage]
public IActionResult About()
{
var list = new List();
list.Where(x => x == "test").FirstOrDefault();

return View();
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.