microsoft / microsoft/vs-threading

VSTHRD110: Analyzer unable to detect pass-through asynchronous method that is not awaited when it is used as an Action parameter.

Open
#630 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

analyzers bug
Dominant language
C#
Stars
1k
Forks
160
Avg merge
1d 12h
Merged PRs (30d)
28

Description

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"

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the example with the netcoreapp3.1 target and compare the reported FooAsync call in Bar1 with the missing report in the Action lambda passed to Bar. Start by locating the VSTHRD110 analyzer entry point and its existing diagnostic coverage. Done means the pass-through asynchronous call used as an Action parameter is detected without regressing the existing case.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.