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

Analyzer doesn't pick up errors in .razor files that have code

Open wadebaird opened this issue 1 month ago • 1 comments

Bug description

When I have code in a razor file using the "@code {... }" syntax, VSTHRD200 doesn't get raised. I am assuming it might be the same for all VSTHRD* issues.

Repro steps

See the attached solution

Expected behavior

These warnings / errors that appear in CodeBehindRazor.cs should appear for CodeInRazor.razor

Warning (active) VSTHRD200 Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html) BlazorAppVSTHRDRepro BlazorAppVSTHRDRepro\Pages\CodeBehindRazor.razor.cs 5 Warning (active) VSTHRD200 Use "Async" suffix in names of methods that return an awaitable type (https://microsoft.github.io/vs-threading/analyzers/VSTHRD200.html) BlazorAppVSTHRDRepro BlazorAppVSTHRDRepro\Pages\CodeBehindRazor.razor.cs 10

Actual behavior

No warnings / errors in CodeInRazor.razor

  • Version used: 17.14.15
  • Application (if applicable): Visual Studio

Additional context

Add any other context about the problem here.

BlazorAppVSTHRDRepro.zip

wadebaird avatar Nov 13 '25 22:11 wadebaird

Thanks for reporting. Just to set expectations, for the product team, supporting razor files isn't on our priority list. Nor do we have much or any expertise with razor-specific concerns. We'd accept a PR, but I don't think we'll come up with one ourselves.

AArnott avatar Nov 15 '25 14:11 AArnott