Beispiel #1
0
        private static TNode ConvertAccessor <TNode>(TNode node, SimpleNameSyntax nameNode, SimpleNameSyntax newNameNode,
                                                     string cancellationTokenParamName, IBodyFunctionReferenceAnalyzationResult bodyFuncReferenceResult,
                                                     Func <InvocationExpressionSyntax, InvocationExpressionSyntax> alterFn = null) where TNode : SyntaxNode
        {
            var expressionNode = nameNode.GetAccessorExpression();
            var invocation     = InvocationExpression(
                expressionNode.IsKind(SyntaxKind.SimpleAssignmentExpression)
                                                ? newNameNode.WithoutTrivia().WithoutAnnotations()
                                                : expressionNode.ReplaceNode(nameNode, newNameNode).WithoutTrivia().WithoutAnnotations()
                )
                                 .WithTriviaFrom(expressionNode)
                                 .AddCancellationTokenArgumentIf(cancellationTokenParamName, bodyFuncReferenceResult)
                                 .WithAdditionalAnnotations(nameNode.GetAnnotations(Annotations.TaskReturned))
                                 .AddAssignedValueAsArgument(expressionNode);

            if (alterFn != null)
            {
                invocation = alterFn(invocation);
            }
            return(node.ReplaceNode(expressionNode, invocation));
        }