Skip to content

Latest commit

 

History

History
35 lines (24 loc) · 1.72 KB

File metadata and controls

35 lines (24 loc) · 1.72 KB
title description author monikerRange ms.author ms.date uid
RDG006: Invalid constructor parameters
Learn about analysis rule RDG006: Invalid constructor parameters
captainsafia
>= aspnetcore-8.0
safia
9/29/2023
fundamentals/aot/request-delegate-generator/diagnostics/rdg006

RDG006: Invalid constructor parameters

Value
Rule ID RDG006
Fix is breaking or non-breaking Non-breaking

Cause

This diagnostic is emitted by the Request Delegate Generator when an endpoint contains a route handler with a parameter annotated with the [AsParameters] attribute that contains an invalid constructor.

Rule description

Types that are used for surrogate binding via the [AsParameters] attribute must contain a public parameterized constructor where all parameters to the constructor match the public properties declared on the type. The TodoRequest type produces this diagnostic because there is no matching constructor parameter for the Todo property.

:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg6/Program.cs" id="snippet_1" highlight="14,18-22":::

How to fix violations

Ensure that all properties on the type have a matching parameter on the constructor.

:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg6/Program.cs" id="snippet_1f" highlight="14,18-22":::

When to suppress warnings

This warning should not be suppressed. Suppressing the warning leads to a runtime exception associated with the same warning.