diff --git a/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg004.md b/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg004.md index 5553031f64..8a758c1235 100644 --- a/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg004.md +++ b/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg004.md @@ -22,26 +22,13 @@ This diagnostic is emitted by the Request Delegate Generator when an endpoint co The Request Delegate Generator runs at compile-time and needs to be able to statically analyze route handlers in an application. Anonymous types are generated with an unspeakable type name and are not statically analyzable. The following endpoint will produce the diagnostic. -```razor -var app = WebApplication.Create(); - -app.MapGet("/v1/todos", () => new { Id = 1, Task = "Write tests" }); - -app.Run(); -``` +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1" highlight="13"::: ## How to fix violations Declare the route handler with a concrete type as the return type. -```razor -var app = WebApplication.Create(); -app.MapGet("/v1/todos", () => new Todo(1, "Write tests"); - -app.Run(); - -record Todo(int Id, string Task); -``` +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1f" highlight="13"::: ## When to suppress warnings