예제 #1
0
        public static bool ArgumentIsVariablePredicate(ArgumentSyntax argument)
        {
            if (argument.Expression is IdentifierNameSyntax identifier)
            {
                var argumentName = identifier.Identifier.Text;

                var variableName = VariableNameExtractor.ExtractVariabeName(argument);

                return(variableName == argumentName);
            }
            return(false);
        }
            private static bool ArgumentInvokesDistinctMethod(SeparatedSyntaxList <ArgumentSyntax> arguments)
            {
                if (!arguments.Any())
                {
                    return(false);
                }

                if (arguments.First().Expression is InvocationExpressionSyntax invocation)
                {
                    var visitor = new FluentAssertionsCSharpSyntaxVisitor(new MemberValidator(nameof(Enumerable.Distinct)));
                    invocation.Accept(visitor);

                    return(visitor.IsValid(invocation) && VariableNameExtractor.ExtractVariabeName(arguments.First()) == VariableNameExtractor.ExtractVariabeName(invocation));
                }
                return(false);
            }