razor
razor copied to clipboard
`IDE` diagnostics/codefixes don't work in razor files
Version used: VS 2022 v17.3 Preview 4
To reproduce:
- Create blazor server app
- Go to
FetchData.razor - In
OnInitializedAsyncmethod addif (forecasts is object) {}:
protected override async Task OnInitializedAsync()
{
forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
if (forecasts is object)
{
}
}
Expected behavior:
IDE0150 Null check can be simplified & a corresponding codefix
Actual behavior: No diagnostic even on rebuild
We currently only allow specific code fixes, so its not surprising that they don't show up. The diagnostic probably should, but is probably not running on the generated file because it is marked as auto generated. We need some way to tell Roslyn to avoid this behaviour.