aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg004.md
| Value | |
|---|---|
| Rule ID | RDG004 |
| 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 an anonymous return type.
The Request Delegate Generator runs at compile-time and needs to be able to statically analyze route handlers in an app. Anonymous types are generated with a type name only known to the complier and aren't statically analyzable. The following endpoint produces the diagnostic.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1" highlight="13":::
Declare the route handler with a concrete type as the return type.
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1f" highlight="13":::
This warning can be safely suppressed. When suppressed, the framework falls back to generating the request delegate at runtime.