-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
NativeAOTarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdg
Milestone
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
If a Map*()
method references a constant for the route pattern, an RDG001 error is emitted for the endpoint and no code is generated.
Unable to statically resolve route pattern for endpoint. Compile-time endpoint generation will skip this endpoint and the endpoint will be generated at runtime. For more information, please see https://aka.ms/aot-known-issues
I checked the known issues and this specific problem doesn't appear to be listed.
For example, this code references constants for the paths so that they can be reused with configuring OAuth:
private const string DeniedPath = "/denied";
private const string SignInPath = "/sign-in";
private const string SignOutPath = "/sign-out";
public static IEndpointRouteBuilder MapAuthenticationRoutes(this IEndpointRouteBuilder builder)
{
builder.MapGet(DeniedPath, () => Results.Redirect(RootPath + "?denied=true"))
.ExcludeFromDescription();
builder.MapGet(SignOutPath, () => Results.Redirect(RootPath))
.ExcludeFromDescription();
builder.MapPost(SignInPath, () => Results.Challenge(new() { RedirectUri = RootPath }, new[] { GitHubAuthenticationDefaults.AuthenticationScheme }))
.ExcludeFromDescription();
builder.MapPost(SignOutPath, () => Results.SignOut(new() { RedirectUri = RootPath }, new[] { CookieAuthenticationDefaults.AuthenticationScheme }))
.ExcludeFromDescription()
.RequireAuthorization();
return builder;
}
Expected Behavior
The source generator acquires the static value of the constant to obtain the route template.
Steps To Reproduce
- Clone martincostello/dotnet-minimal-api-integration-testing@774c5a4
- Add the following to
src/TodoApp/TodoApp.csproj
:<EnableRequestDelegateGenerator>true</EnableRequestDelegateGenerator>
- Build the TodoApp project
Exceptions (if any)
No response
.NET Version
8.0.100-preview.4.23260.5
Anything else?
No response
Metadata
Metadata
Assignees
Labels
NativeAOTarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdg