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

EventCallback.InvokeAsync is not caught by VSTHRD110

Open jasekiw opened this issue 4 years ago • 1 comments

Bug description

In Blazor if an EventCallback is defined in a parameter and then invoked, VSTHRD110 does not warn if await is not called on InvokeAsync().

Repro steps

[Parameter]
public EventCallback Click { get; set; }
private void HandleClick()
{
    Click.InvokeAsync();
}

Expected behavior

The warning should show

Actual behavior

No warning is shown.

  • Version used: 17.0.63
  • Application (if applicable): Blazor - .net 6

jasekiw avatar Oct 11 '21 17:10 jasekiw

Thanks for reporting. Looking at the signature of InvokeAsync I see it returns Task, so I would expect this to work.

Do you have the vs-threading analyzers installed in your Blazor project? Can you provide a repro?

I created a Blazor app and pasted in your code and at first no diagnostic was generated. Then I installed the Microsoft.VisualStudio.Threading.Analyzers package and the diagnostic appeared right away:

image

AArnott avatar Oct 26 '21 01:10 AArnott