Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventCallback.InvokeAsync is not caught by VSTHRD110 #938

Open
jasekiw opened this issue Oct 11, 2021 · 1 comment
Open

EventCallback.InvokeAsync is not caught by VSTHRD110 #938

jasekiw opened this issue Oct 11, 2021 · 1 comment

Comments

@jasekiw
Copy link

jasekiw commented Oct 11, 2021

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 jasekiw changed the title VSTHRD110 does not catch EventCallback.InvokeAsync() Installing Nuget package Microsoft.VisualStudio.Threading.Analyzers breaks dotnet watch reload Oct 11, 2021
@jasekiw jasekiw changed the title Installing Nuget package Microsoft.VisualStudio.Threading.Analyzers breaks dotnet watch reload EventCallback.InvokeAsync is not caught by VSTHRD110 Oct 11, 2021
@AArnott
Copy link
Member

AArnott commented Oct 26, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants