aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg007.md
| Value | |
|---|---|
| Rule ID | RDG007 |
| Fix is breaking or non-breaking | Non-breaking |
This diagnostic is emitted by the Request Delegate Generator when an endpoint contains a route handler with a parameter annotated with the [AsParameters] attribute with no valid constructor.
Types that are used for surrogate binding via the AsParameters attribute must contain a public constructor. The TodoRequest type produces this diagnostic because there is no public constructor.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg7/Program.cs" id="snippet_1" highlight="13-14,23-25":::
Remove the non-public constructor, or add a new public constructor.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg7/Program.cs" id="snippet_1f" highlight="13-15,18-22":::
This warning can't be safely suppressed. When suppressed, results in the InvalidOperationException runtime exception.