Edit

Share via


BL0007: Component parameter '{0}' should be auto property

Value
Rule ID BL0007
Category Usage
Fix is breaking or non-breaking Non-breaking

Cause

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).

Rule description

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.

How to fix violations

Implement the component parameter as an auto property and override OnParametersSet or OnParametersSetAsync in the component class to read or transform the parameter's value. For more information, see the OnParametersSet{Async} lifecycle method.

When to suppress warnings

Do not suppress a warning from this rule.