vs-threading
vs-threading copied to clipboard
VSTHRD110: Analyzer unable to detect pass-through asynchronous method that is not awaited when it is used as an Action parameter.
Bug description
Analyzer rule VSTHRD110 is not able to detect the pass-through asynchronous methods that is not awaited when it is used as an Action parameter.
Repro steps
Use below code snippet:
using System;
using System.Threading.Tasks;
namespace vsthreadtest
{
class Program
{
static void Main(string[] args)
{
Bar(() => FooAsync());
Bar1();
}
public static Task FooAsync()
{
return Task.Delay(TimeSpan.FromSeconds(5));
}
public static void Bar(Action action)
{
action();
}
public static void Bar1()
{
FooAsync();
}
}
}
Only FooAsync usage in Bar1 is detected by VSTHRD110.
Expected behavior
FooAsync Usage in Bar should also be detected.
Actual behavior
Only FooAsync usage in Bar1 is detected by VSTHRD110.
- Version used: "Microsoft.VisualStudio.Threading.Analyzers 16.6.13"
- Application (if applicable):
Additional context
I only test the behavior of application targeted "netcoreapp3.1"
Will this be addressed somehow? Ignoring a task return value should not be possible IMHO.