Бэкенд отмены задачи
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
@@ -120,7 +121,8 @@ namespace {Namespace}
|
||||
|
||||
|
||||
bool isAsync = method.ReturnType.Name == "Task";
|
||||
bool isVoid = method.ReturnType.Name == "Void" || method.ReturnType.ToString() == "Task";
|
||||
bool isVoid = method.ReturnType.Name == "Void" ||
|
||||
method.ReturnType.ToString() == "System.Threading.Tasks.Task";
|
||||
bool isParametrized = method.Parameters.Length == 1 && !isAsync ||
|
||||
method.Parameters.Length == 2 && isAsync;
|
||||
|
||||
@@ -135,9 +137,16 @@ namespace {Namespace}
|
||||
var prefix = isAsync ? "await " : "";
|
||||
var postfix = !isAsync ? (isVoid ? ".Wait()" : ".GetAwaiter().GetResult()") : "";
|
||||
var parameterLink = isParametrized ? ", " + method.Parameters.First().Name : string.Empty;
|
||||
var caller = isVoid ? $"CallAsync({index}{parameterLink})" :
|
||||
isAsync ? $"GetResultAsync<{ExtractTaskType(method.ReturnType)}>({index}{parameterLink})" :
|
||||
$"GetResultAsync<{ToFullString(method.ReturnType)}>({index}{parameterLink})";
|
||||
var tokenInsert = isAsync
|
||||
? isParametrized
|
||||
? ", cancellationToken : " + method.Parameters[1].Name
|
||||
: ", cancellationToken : " + method.Parameters[0].Name
|
||||
: String.Empty;
|
||||
var caller = isVoid
|
||||
? $"CallAsync({index}{parameterLink}{tokenInsert})"
|
||||
: isAsync
|
||||
? $"GetResultAsync<{ExtractTaskType(method.ReturnType)}>({index}{parameterLink}{tokenInsert})"
|
||||
: $"GetResultAsync<{ToFullString(method.ReturnType)}>({index}{parameterLink}{tokenInsert})";
|
||||
|
||||
if (!isVoid)
|
||||
prefix = "return " + prefix;
|
||||
@@ -195,7 +204,6 @@ namespace {namespaceName}
|
||||
";
|
||||
|
||||
|
||||
|
||||
// Add the source code to the compilation.
|
||||
context.AddSource($"{className}.g.cs", SourceText.From(code, Encoding.UTF8));
|
||||
|
||||
@@ -250,7 +258,7 @@ namespace mROA.Codegen
|
||||
";
|
||||
context.AddSource($"CoCodegenMethodRepository.g.cs", SourceText.From(coCodegenRepoCode, Encoding.UTF8));
|
||||
}
|
||||
|
||||
|
||||
if (frontendContextRepo.Count != 0)
|
||||
{
|
||||
var fronendRepoCode = @$"// <auto-generated/>
|
||||
@@ -324,7 +332,7 @@ namespace mROA.Codegen
|
||||
|
||||
GenerateCode(context, context.Compilation, interfaces.ToImmutableArray());
|
||||
}
|
||||
|
||||
|
||||
private bool ContainsSOIAttribute(SyntaxList<AttributeListSyntax> attributes, GeneratorExecutionContext context,
|
||||
InterfaceDeclarationSyntax interfaceDeclarationSyntax)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user