Add support for ValueTask

This commit is contained in:
2024-10-18 13:33:14 +02:00
parent ecee8433a0
commit 83822510f1
2 changed files with 9 additions and 3 deletions
@@ -262,13 +262,19 @@ public class UseRoutesGenerator : IIncrementalGenerator
return returnTypeSymbol?.ToDisplayString() switch
{
"System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>" => @$"
builder.Map{type}(""{pattern}"", (Delegate)((HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
builder.Map{type}(""{pattern}"", (HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
{{
var cancellationToken = httpContext.RequestAborted;
return route.{methodDeclarationSyntax.Identifier}({variables});
}})){routeFilterSb};",
}}){routeFilterSb};",
"Microsoft.AspNetCore.Http.IResult" => @$"
builder.Map{type}(""{pattern}"", (HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
{{
var cancellationToken = httpContext.RequestAborted;
return route.{methodDeclarationSyntax.Identifier}({variables});
}}){routeFilterSb};",
"System.Threading.Tasks.ValueTask<Microsoft.AspNetCore.Http.IResult>" => @$"
builder.Map{type}(""{pattern}"", (HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
{{
var cancellationToken = httpContext.RequestAborted;
return route.{methodDeclarationSyntax.Identifier}({variables});