Skip to content

Commit f1cdbd2

Browse files
committed
Updates
1 parent 4fe8855 commit f1cdbd2

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

aspnetcore/diagnostics/bl0008.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ uid: diagnostics/bl0008
1717

1818
## Cause
1919

20-
A property has the [`[SupplyParameterFromForm]` attribute](xref:Microsoft.AspNetCore.Components.SupplyParameterFromFormAttribute) and is initialized with a non-default property initializer, where the initializer can be overwritten with `null` during form submission, causing the `EditForm` to fail with the following exception:
21-
22-
> :::no-loc text="InvalidOperationException: EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these.":::
20+
A property has the [`[SupplyParameterFromForm]` attribute](xref:Microsoft.AspNetCore.Components.SupplyParameterFromFormAttribute) and is initialized with a non-default property initializer.
2321

2422
## Rule description
2523

24+
The property initializer can be overwritten with `null` during form submission, causing the `EditForm` to fail with the following exception:
25+
26+
> :::no-loc text="InvalidOperationException: EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these.":::
27+
2628
The analyzer warns developers when this pattern is detected, while safely ignoring default value initializers (`null`, `null!`, `default`, `default!`) that don't cause the same issue.
2729

2830
Consider the following `Input` form model with a property initializer:
@@ -32,9 +34,9 @@ Consider the following `Input` form model with a property initializer:
3234
public InputModel Input { get; set; } = new();
3335
```
3436

35-
The analyzer reports the following warning:
37+
The analyzer reports the following warning, where the `{COMPONENT}` placeholder is the component type name:
3638

37-
> :::no-loc text="Property 'MyComponent.Input' has [SupplyParameterFromForm] and a property initializer. This can be overwritten with null during form posts.":::
39+
> :::no-loc text="Property '{COMPONENT}.Input' has [SupplyParameterFromForm] and a property initializer. This can be overwritten with null during form posts.":::
3840
3941
<span aria-hidden="true">✔️</span> Safe patterns that are ignored by analyzer:
4042

0 commit comments

Comments
 (0)