Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

ExcludeFromCodeCoverage not working
paulo
#1 Posted : Monday, May 18, 2020 2:43:40 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 4/27/2020(UTC)
Posts: 6
Location: Brazil

Thanks: 1 times
Hi,

I'm using ExcludeFromCodeCoverage over method and continue showing in NCrunchMetrics

Code:
[ExcludeFromCodeCoverage]
[HttpPost("executemigration")]
[AllowAnonymous]
public async Task<IActionResult> executemigration()
{
await _mongoDbContext.EnsureIndex();
return Ok();
}
Remco
#2 Posted : Monday, May 18, 2020 11:05:11 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,064

Thanks: 788 times
Was thanked: 1026 time(s) in 976 post(s)
Hi, thanks for sharing this issue.

ExcludeFromCodeCoverage doesn't work here because at a physical level, the attribute doesn't get applied to the compiler-generated IL structure that comprises the async code block.

It is possible for us to fix this. However, we can't find a way of doing so that doesn't massively impact performance of the instrumentation .. such that the fix is worse than the problem.

VSTest has the same issue. I'm not aware of this attribute working in such a scenario with any other runner either.

I recommend using code coverage suppression comments instead.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.025 seconds.