-
Notifications
You must be signed in to change notification settings - Fork 388
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
Partially covered await foreach
statement
#1104
Labels
tenet-coverage
Issue related to possible incorrect coverage
Comments
You can find the full reproduction code (and also for some other cases) in this repository: https://github.com/meggima/coverlet-reproductions |
This was referenced Mar 2, 2021
alexthornton1
added a commit
to alexthornton1/coverlet
that referenced
this issue
Mar 4, 2021
This commit attempts to fix code coverage for the "await foreach" loop introduced in C# 8. The presence of an "await foreach" loop causes four new kinds of branch patterns to be generated in the async state machine. Three of these are to be eliminated, while the fourth is actually the "should I stay in the loop or not?" branch and is best left in a code coverage report. CecilSymbolHelper now eliminates the three branch patterns that need to be eliminated. There are tests both in CecilSymbolHelperTests as well as a new set of coverage tests in CoverageTests.AsyncForeach.cs.
alexthornton1
added a commit
to alexthornton1/coverlet
that referenced
this issue
Mar 4, 2021
This commit attempts to fix code coverage for the "await foreach" loop introduced in C# 8. The presence of an "await foreach" loop causes four new kinds of branch patterns to be generated in the async state machine. Three of these are to be eliminated, while the fourth is actually the "should I stay in the loop or not?" branch and is best left in a code coverage report. CecilSymbolHelper now eliminates the three branch patterns that need to be eliminated. There are tests both in CecilSymbolHelperTests as well as a new set of coverage tests in CoverageTests.AsyncForeach.cs.
alexthornton1
added a commit
to alexthornton1/coverlet
that referenced
this issue
Mar 6, 2021
Fixes coverage for compiler-generated async iterators that arise from async methods that use the "yield" statement to return one element at a time asynchronously via an IAsyncEnumerable<T>. In combination with the previous commit that handles the "async foreach" loop, this should address issue coverlet-coverage#1104.
MarcoRossignoli
added
tenet-coverage
Issue related to possible incorrect coverage
and removed
untriaged
To be investigated
labels
Mar 6, 2021
assigned to @alexthornton1 |
MarcoRossignoli
pushed a commit
that referenced
this issue
Mar 6, 2021
Closed in #1107 |
pbmiguel
pushed a commit
to pbmiguel/coverlet
that referenced
this issue
Mar 17, 2021
…tors (issue coverlet-coverage#1104) (coverlet-coverage#1107) Coverage for "await foreach" loops and compiler-generated async iterators (issue coverlet-coverage#1104) (coverlet-coverage#1107)
If you change the AsyncEnumerable method in the original example like that (by adding attribute for cancellation Token support - code below), it will be still partially covered.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
In the following code the
await foreach
as well as thefor
and theyield
statements are marked as partially covered due to the hidden async/await logic of the compiler. Can this be reported as covered by coverlet?Reproduction class:
Test Case for it:
Reported coverage:
Coverlet version: 3.0.3
The text was updated successfully, but these errors were encountered: