コード例 #1
0
        public override SyntaxNode Visit(SyntaxNode node)
        {
            if (node is InvocationExpressionSyntax) //Fix for default arguments
            {
                var invocationExpression = node as InvocationExpressionSyntax;

                if (invocationExpression.ArgumentList != null &&
                    invocationExpression.ArgumentList.Arguments.Any(j => j.NameColon != null))
                {
                    var symbolInfo       = _semanticModel.GetSymbolInfo(invocationExpression);
                    var expressionSymbol = _semanticModel.GetSymbolInfo(invocationExpression.Expression);

                    var symbol = symbolInfo.Symbol ?? symbolInfo.CandidateSymbols.FirstOrDefault(); // Resolution error

                    var methodSymbol = symbol.OriginalDefinition.As <IMethodSymbol>().UnReduce();

                    var arguments = ProcessArguments(
                        invocationExpression,
                        methodSymbol,
                        (x, i) =>
                        TypeProcessor.GetTypeInfo(invocationExpression.ArgumentList.Arguments[i].Expression)
                        .ConvertedType is IArrayTypeSymbol,
                        (x, i) =>
                        invocationExpression.ArgumentList.Arguments[i].NameColon == null
                                ? null
                                : invocationExpression.ArgumentList.Arguments[i].NameColon.Name.ToString(),
                        invocationExpression.ArgumentList.Arguments.ToArray()
                        ).ToList();

                    invocationExpression =
                        invocationExpression.WithArgumentList(
                            SyntaxFactory.ArgumentList(SyntaxFactory.SeparatedList(arguments)));

                    return(base.Visit(invocationExpression));
                }
            }
            return(base.Visit(node));
        }