Given the code:
public class MyClass { public static void MyMethod(IEndpointRouteBuilder app) { app.MapPost("/test-param", (MyDto param) => { }); app.MapPost("/test-return", () => new MyDto()); } private class MyDto { } }
RDG generates code that fails to compile because MyDto
is a private type. The lines that cause the compilation failure by referencing the private type are basically the same lines that fail with an undefined TUser
in #47338 which is the equivalent issue about generic types.
We can skip generating MapPost
and similar methods when we see a private type in the delegate signature and suggest using internal types instead. I don't think we really have an alternative unless we could somehow generate our Map
extension methods directly in the same class/struct the user is calling it from. I don't know of any plans for that.
GeneratedRouteBuilderExtensions.g.cs(73,111): error CS0122: 'MyClass.MyDto' is inaccessible due to its protection level
GeneratedRouteBuilderExtensions.g.cs(88,109): error CS0122: 'MyClass.MyDto' is inaccessible due to its protection level
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4