From 3caa5d1ec80e0cc9ade3d1af2d44fe605cf8f924 Mon Sep 17 00:00:00 2001 From: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com> Date: Wed, 4 Oct 2023 19:44:33 +0200 Subject: [PATCH] add RDG012 example --- .../diagnostics/rdg012.md | 22 ++++--------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg012.md b/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg012.md index c67e1fbdd8..95bb9b334d 100644 --- a/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg012.md +++ b/aspnetcore/fundamentals/aot/request-delegate-generator/diagnostics/rdg012.md @@ -20,32 +20,18 @@ This diagnostic is emitted by the Request Delegate Generator when an endpoint co ### Rule description -The Request Delegate Generator only supports +Endpoints that use an inaccessible type (`private` or `protected`) are not supported. +The endpoints within `MapEndpoints` produce this diagnostic because of the `Todo` type has the `private` accessibility modifiers. -```csharp -var app = WebApplication.Create(); +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1" highlight="9-20, 22"::: -app.MapPost("/vl/todos", (Todo todo) - => Results.Created(todo)); - -app.Run(); - -private record Todo(int Id, string Task); -``` ## How to fix violations When applicable, set the target parameter type with a friendly accessibility. -```csharp -var app = WebApplication.Create(); -app.MapPost("/vl/todos", (Todo todo) - => Results.Created(todo)); +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/aot/diagnostics/Rdg12/Program.cs" id="snippet_1f" highlight="9-20, 22"::: -app.Run(); - -public record Todo(int Id, string Task); -``` ## When to suppress warnings