vs-threading icon indicating copy to clipboard operation
vs-threading copied to clipboard

VSTHRD103 mis-fires when async version is not accessible (ie., not public)

Open TahirAhmadov opened this issue 3 years ago • 0 comments

Bug description

When calling an available (eg. public) sync method, and the target object has a method which is not available (eg. protected) and is "async" (returns task-like, has same signature, and ends with "Async"), it suggests to use it.

Repro steps

class Foo
{
  string? _text;
  public void Bind(string text) => this._text = text;
  protected async Task BindAsync(string text) { this.Bind(text); await this.HandleBoundAsync(); }
  protected async Task HandleBoundAsync() { ... }
}
var foo = new Foo();
foo.Bind("abc"); // VSTHRD103

Expected behavior

Should not fire

Actual behavior

Fired

  • Version used: 17.2.32
  • Application (if applicable):

Additional context

TahirAhmadov avatar Aug 09 '22 18:08 TahirAhmadov