Back to Aspnetcore

BL0004: Component parameter should be public

aspnetcore/diagnostics/bl0004.md

latest1.0 KB
Original Source

BL0004: Component parameter should be public

Value
Rule IDBL0004
CategoryUsage
Fix is breaking or non-breakingBreaking

Cause

A property on a type deriving from xref:Microsoft.AspNetCore.Components.ComponentBase annotated with [Parameter] is not public.

Rule description

Component parameters are required to be public and must have a public setter.

razor
@code
{
    [Parameter] int Parameter1 { get; set; }
}

How to fix violations

  • Make the property and its setter public.
razor
@code
{
    [Parameter] public int Parameter1 { get; set; }
}

When to suppress warnings

Do not suppress a warning from this rule.