| title | BL0007: Component parameter '{0}' should be auto property |
|---|---|
| description | Learn about analysis rule BL0007: Component parameter '{0}' should be auto property |
| author | guardrex |
| monikerRange | >= aspnetcore-3.1 |
| ms.author | riande |
| ms.date | 04/07/2025 |
| uid | diagnostics/bl0007 |
| Value | |
|---|---|
| Rule ID | BL0007 |
| Category | Usage |
| Fix is breaking or non-breaking | Non-breaking |
A component parameter, which is a public C# property of a component class with the [Parameter] attribute, isn't an automatically-implemented property (auto property).
A component parameter is a framework-managed communication channel between a parent and a child component. Developers shouldn't read or write to the parameter in a get (getter) or set (setter) accessor, either from inside or outside the component.
Possible side effects of interacting directly with a component parameter include infinite rendering loops, unexpected extra renderings, and parameter value overwrites.
Implement the component parameter as an auto property and override xref:Microsoft.AspNetCore.Components.ComponentBase.OnParametersSet%2A or xref:Microsoft.AspNetCore.Components.ComponentBase.OnParametersSetAsync%2A in the component class to read or transform the parameter's value. For more information, see the OnParametersSet{Async} lifecycle method.
Do not suppress a warning from this rule.