vs-threading icon indicating copy to clipboard operation
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.

Open t-bzhan opened this issue 5 years ago • 1 comments

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"

t-bzhan avatar May 24 '20 09:05 t-bzhan

Will this be addressed somehow? Ignoring a task return value should not be possible IMHO.

HenningOI avatar Apr 10 '25 15:04 HenningOI