Wrong coverage for "await foreach" when method is generic
See original GitHub issueI’m using coverlet.msbuild v3.1.0 (and tried also with the current nightly build) and there is an uncovered statement reported.
I tried to reproduce it but I didn’t managed to get an reproduction. Any ideas what the problem could be and how I can provide an reproduction?
public class AsyncForeachReproduction
{
private static async IAsyncEnumerable<int> RangeAsync(int start, int count)
{
for (int i = 0; i < count; i++)
{
await Task.Delay(i);
yield return start + i;
}
}
public async Task Execute()
{
await foreach (var a in RangeAsync(1, 5))
{
Console.WriteLine(a);
await Task.CompletedTask;
}
await Task.CompletedTask;
}
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:8
Top Results From Across the Web
Using async/await with a forEach loop
I'm trying to loop through an array of files and await on the contents of each file. import fs from 'fs-promise' async function...
Read more >The anatomy of async iterators (aka await, foreach, yield)
Here I'm going to discuss the mechanisms and concepts relating to async iterators in C# - with the hope of both demystifying them...
Read more >Async return types (C#)
Learn about the return types that async methods can have in C# with code examples for each type.
Read more >The Simplest Guide to Using Async/Await with forEach() in ...
Using async/await with forEach() does not need to be a nightmare! Here are 4 solutions to your problem.
Read more >Async streams in C# – Deep Dive
This article explores C# async streams in detail: from the basics and the reasoning behind them, to real-world examples of using and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I started working on this issue.
The code in the repro and the code that is failing are a lot different from compiler perspective, state machine are built in a different way because different object structure are involved(different nesting, visibility, different relationship between objects…different optimization)…you should create the same classes, mock those and retry.
Try to compare those with ILSpy and you’ll see that the emitted IL is different.