Back to Aspnetcore

RDG009: Invalid nested AsParameters

aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg009.md

latest1.3 KB
Original Source

RDG009: Invalid nested AsParameters

<!-- UPDATE 9.0 Activate after release and INCLUDE is updated [!INCLUDE[](~/includes/not-latest-version.md)] -->
Value
Rule IDRDG009
Fix is breaking or non-breakingNon-breaking

Cause

This diagnostic is emitted by the Request Delegate Generator when an endpoint contains invalid nested [AsParameters].

Rule description

Types that are used for surrogate binding via the [AsParameters] attribute must not contain nested types that are also annotated with the [AsParameters] attribute:

:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg9/Program.cs" id="snippet_1f" highlight="19,31":::

How to fix violations

Remove the nested AsParameters attribute:

:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg9/Program.cs" id="snippet_1" highlight="17,29":::

When to suppress warnings

This warning can not be suppressed.