| title | BL0004: Component parameter should be public |
|---|---|
| description | Learn about analysis rule BL0004: Component parameter should be public |
| author | guardrex |
| monikerRange | >= aspnetcore-3.1 |
| ms.author | riande |
| ms.date | 10/21/2021 |
| uid | diagnostics/bl0004 |
| Value | |
|---|---|
| Rule ID | BL0004 |
| Category | Usage |
| Fix is breaking or non-breaking | Breaking |
A property on a type deriving from xref:Microsoft.AspNetCore.Components.ComponentBase annotated with [Parameter] is not public.
Component parameters are required to be public and must have a public setter.
@code
{
[Parameter] int Parameter1 { get; set; }
}- Make the property and its setter public.
@code
{
[Parameter] public int Parameter1 { get; set; }
}- If making the property non-public is not possible, consider implementing
SetParametersAsyncmanually.
Do not suppress a warning from this rule.