Bug description
A Task returning method containing a non-Task returning lambda containing a synchronous wait does not trip any of the VSTHRD analyzers
Repro steps
public static class Example
{
// VSTHRD002
public static void VoidVoidExample()
{
var action = () => Task.Run(() => { }).Wait();
}
// VSTHRD002 and VSTHRD103
public static void VoidTaskExample()
{
var funcTask = () =>
{
Task.Run(() => { }).Wait();
return Task.CompletedTask;
};
}
// VSTHRD103
public static Task TaskTaskExampleAsync()
{
var funcTask = () =>
{
Task.Run(() => { }).Wait();
return Task.CompletedTask;
};
return Task.CompletedTask;
}
// No violations
public static Task TaskVoidExampleAsync()
{
var action = () => Task.Run(() => { }).Wait();
return Task.CompletedTask;
}
}
Expected behavior
At least one of the analyzers should be tripped by TaskVoidExampleAsync()
Actual behavior
No errors are reported
Edit: simplified example and added syntax highlighting.
Bug description
A Task returning method containing a non-Task returning lambda containing a synchronous wait does not trip any of the VSTHRD analyzers
Repro steps
Expected behavior
At least one of the analyzers should be tripped by TaskVoidExampleAsync()
Actual behavior
No errors are reported
Edit: simplified example and added syntax highlighting.