@@ -504,13 +504,13 @@ private MemberDeclarationSyntax GenerateInvokeInnerMethod(
504
504
{
505
505
var resultTask = IdentifierName ( "resultTask" ) ;
506
506
507
+
507
508
// C# var resultTask = this.target.{Method}({params});
508
509
var args = SeparatedList (
509
- fields . OfType < MethodParameterFieldDescription > ( )
510
- . OrderBy ( p => p . ParameterOrdinal )
511
- . Select ( p => SymbolEqualityComparer . Default . Equals ( LibraryTypes . CancellationToken , p . Parameter . Type )
510
+ method . Method . Parameters
511
+ . Select ( p => SymbolEqualityComparer . Default . Equals ( LibraryTypes . CancellationToken , p . Type )
512
512
? Argument ( IdentifierName ( "cancellationToken" ) )
513
- : Argument ( IdentifierName ( p . FieldName ) ) ) ) ;
513
+ : Argument ( IdentifierName ( $ "arg { p . Ordinal } " ) ) ) ) ;
514
514
515
515
var isExtension = method . Key . ProxyBase . IsExtension ;
516
516
var getTarget = InvocationExpression (
@@ -691,11 +691,19 @@ private MemberDeclarationSyntax GenerateDisposeMethod(
691
691
}
692
692
693
693
private MemberDeclarationSyntax GenerateGetArgumentCount ( InvokableMethodDescription methodDescription )
694
- => methodDescription . Method . Parameters . Length is var count and not 0 ?
694
+ {
695
+ var count = methodDescription . Method . Parameters . Length ;
696
+ if ( methodDescription . IsCancellable )
697
+ {
698
+ count -= 1 ;
699
+ }
700
+
701
+ return count is not 0 ?
695
702
MethodDeclaration ( PredefinedType ( Token ( SyntaxKind . IntKeyword ) ) , "GetArgumentCount" )
696
703
. WithExpressionBody ( ArrowExpressionClause ( LiteralExpression ( SyntaxKind . NumericLiteralExpression , Literal ( count ) ) ) )
697
704
. WithModifiers ( TokenList ( Token ( SyntaxKind . PublicKeyword ) , Token ( SyntaxKind . OverrideKeyword ) ) )
698
705
. WithSemicolonToken ( Token ( SyntaxKind . SemicolonToken ) ) : null ;
706
+ }
699
707
700
708
private MemberDeclarationSyntax GenerateGetActivityName ( InvokableMethodDescription methodDescription )
701
709
{
@@ -895,6 +903,11 @@ private List<InvokerFieldDescription> GetFieldDescriptions(InvokableMethodDescri
895
903
896
904
foreach ( var parameter in method . Method . Parameters )
897
905
{
906
+ if ( SymbolEqualityComparer . Default . Equals ( LibraryTypes . CancellationToken , parameter . Type ) )
907
+ {
908
+ continue ;
909
+ }
910
+
898
911
fields . Add ( new MethodParameterFieldDescription ( method . CodeGenerator , parameter , $ "arg{ fieldId } ", fieldId , method . TypeParameterSubstitutions ) ) ;
899
912
fieldId ++ ;
900
913
}
0 commit comments