You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Analyzer rule VSTHRD002 is unable to detect synchronous wait call in in asynchronous function that returns IAsyncEnumerable.
Repro steps
Use below code snippet:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace vsthreadtest
{
class Program
{
static async Task Main(string[] args)
{
await foreach(var i in FooAsync())
{
Console.WriteLine(i);
}
}
public static async IAsyncEnumerable<int> FooAsync()
{
await Task.Delay(TimeSpan.FromSeconds(5));
foreach (int i in Enumerable.Range(1, 10))
{
Task.Delay(TimeSpan.FromSeconds(5)).Wait();
yield return i;
}
}
public static IEnumerable<int> Foo()
{
foreach (int i in Enumerable.Range(1, 10))
{
Task.Delay(TimeSpan.FromSeconds(5)).Wait();
yield return i;
}
}
}
}
Expected behavior
All the Task.Delay(TimeSpan.FromSeconds(5)).Wait() calls will be detected.
Actual behavior
Task.Delay(TimeSpan.FromSeconds(5)).Wait() in FooAsync is not detected by VSTHRD002.
.
Version used: "Microsoft.VisualStudio.Threading.Analyzers 16.6.13"
Application (if applicable):
Additional context
I only test the behavior of application targeted "netcoreapp3.1".
The text was updated successfully, but these errors were encountered:
AArnott
changed the title
VSTHRD002: Analyzer unable to detect synchronous wait call in asynchronous function that returns IAsyncEnumerable
VSTHRD103: Analyzer unable to detect synchronous wait call in asynchronous function that returns IAsyncEnumerable
Oct 29, 2020
Bug description
Analyzer rule VSTHRD002 is unable to detect synchronous wait call in in asynchronous function that returns IAsyncEnumerable.
Repro steps
Use below code snippet:
Expected behavior
All the Task.Delay(TimeSpan.FromSeconds(5)).Wait() calls will be detected.
Actual behavior
Task.Delay(TimeSpan.FromSeconds(5)).Wait() in FooAsync is not detected by VSTHRD002.
.
Additional context
I only test the behavior of application targeted "netcoreapp3.1".
The text was updated successfully, but these errors were encountered: