Rdg004 update /8
parent
869e92f42c
commit
a1af54a2a8
|
@ -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.
|
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
|
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1" highlight="13":::
|
||||||
var app = WebApplication.Create();
|
|
||||||
|
|
||||||
app.MapGet("/v1/todos", () => new { Id = 1, Task = "Write tests" });
|
|
||||||
|
|
||||||
app.Run();
|
|
||||||
```
|
|
||||||
|
|
||||||
## How to fix violations
|
## How to fix violations
|
||||||
|
|
||||||
Declare the route handler with a concrete type as the return type.
|
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");
|
:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg4/Program.cs" id="snippet_1f" highlight="13":::
|
||||||
|
|
||||||
app.Run();
|
|
||||||
|
|
||||||
record Todo(int Id, string Task);
|
|
||||||
```
|
|
||||||
|
|
||||||
## When to suppress warnings
|
## When to suppress warnings
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue