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

Uncovered branch at the of "finally" block when "await" appears within it #1233

Closed
alexthornton1 opened this issue Oct 4, 2021 · 2 comments · Fixed by #1245
Closed

Uncovered branch at the of "finally" block when "await" appears within it #1233

alexthornton1 opened this issue Oct 4, 2021 · 2 comments · Fixed by #1245
Assignees
Labels
bug Something isn't working with repro Issue with repro

Comments

@alexthornton1
Copy link
Contributor

alexthornton1 commented Oct 4, 2021

I wrote a method in which there was an await statement in a finally block. The code was fully covered, but Coverlet reported an uncovered branch at the end of the finally block. I had a few things going on in that method -- ConfigureAwait was used in multiple places, there were multiple await statements in the finally block, including one in an if statement -- but I was able to narrow the problem down to something much simpler.

Suppose that we have these methods:
image

Suppose, also, that we have one test that calls into them, which should fully cover them, since there's no (user-written) branching logic in the code under test:
image

If I run that test under Coverlet 3.1.0 (in .NET 5 or .NET 6 RC 1), here's what I see:
image

The missing branch coverage is here (which turns out to be the curly brace closing the finally block):
image

This is the IL instruction that's left uncovered:
image

I will attach a repro solution, as well.

Many thanks!

@alexthornton1
Copy link
Contributor Author

Repro:
AwaitInFinally.zip

@daveMueller daveMueller added untriaged To be investigated with repro Issue with repro labels Oct 5, 2021
@daveMueller daveMueller added bug Something isn't working and removed untriaged To be investigated labels Oct 31, 2021
@daveMueller
Copy link
Collaborator

I'll work on that.

@daveMueller daveMueller self-assigned this Oct 31, 2021
daveMueller added a commit to daveMueller/coverlet that referenced this issue Nov 1, 2021
daveMueller added a commit to daveMueller/coverlet that referenced this issue Nov 2, 2021
daveMueller added a commit to daveMueller/coverlet that referenced this issue Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working with repro Issue with repro
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants