vs-threading
vs-threading copied to clipboard
EventCallback.InvokeAsync is not caught by VSTHRD110
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
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:
