mirror of
https://github.com/AlexMacocian/Net.Sdk.Web.Extensions.git
synced 2026-07-22 16:59:30 +00:00
Cast async Tasks to Delegate and let the framework handle awaiting it
This commit is contained in:
@@ -262,11 +262,11 @@ public class UseRoutesGenerator : IIncrementalGenerator
|
||||
return returnTypeSymbol?.ToDisplayString() switch
|
||||
{
|
||||
"System.Threading.Tasks.Task<Microsoft.AspNetCore.Http.IResult>" => @$"
|
||||
builder.Map{type}(""{pattern}"", async (HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
|
||||
builder.Map{type}(""{pattern}"", (Delegate)((HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
|
||||
{{
|
||||
var cancellationToken = httpContext.RequestAborted;
|
||||
return await route.{methodDeclarationSyntax.Identifier}({variables});
|
||||
}}){routeFilterSb};",
|
||||
return route.{methodDeclarationSyntax.Identifier}({variables});
|
||||
}})){routeFilterSb};",
|
||||
"Microsoft.AspNetCore.Http.IResult" => @$"
|
||||
builder.Map{type}(""{pattern}"", (HttpContext httpContext, {classDeclarationSyntax.Identifier} route{(parameters.Length > 0 ? $", {parameters}" : "")}) =>
|
||||
{{
|
||||
|
||||
Reference in New Issue
Block a user