dotnet / dotnet/aspnetcore

[Blazor] Add more analyzers

Open
#44,690 6 comments 17 reactions 0 assignees View on GitHub
analyzer area-blazor enhancement Pillar: Dev Experience
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 5h
Merged PRs (30d)
276

Description

### Overview
There are a set of mistakes that are easy to make when using Blazor that could be caught with the help of Roslyn Analyzers. Some of these analyzers were prototyped in https://github.com/captainsafia/mshack2022. This issue will be used to determine which analyzers are worth productizing and track their implementation progress.

### Analyzer Ideas
- [ ] Warn when a Razor component writes to one of its parameter properties directly.*
* Should only apply to components extending `ComponentBase`.
* Should ignore mutations in the component's constructor or `SetParametersAsync()` method.
- [ ] #65233
* Important mostly in Server Prerendered/RCL scenarios.
* Might also want to consider warning when using .NET APIs that perform JS interop under the hood (e.g. protected browser storage APIs).
- [x] #65234
* This type of mistake can happen in any C# code but seems particularly prevalent in Blazor.
- [ ] Warn when the `[SupplyParameterFromQuery]` or `[EditorRequired]` attributes are used without the `[Parameter]` attribute.*
- [x] #65235
- [x] https://github.com/dotnet/aspnetcore/issues/38549

_\* prototyped_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.