private static void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext context)
        {
            var invocation = (InvocationExpressionSyntax)context.Node;

            if (invocation.ContainsDiagnostics)
            {
                return;
            }

            if (invocation.SpanContainsDirectives())
            {
                return;
            }

            SemanticModel     semanticModel     = context.SemanticModel;
            CancellationToken cancellationToken = context.CancellationToken;

            CallExtensionMethodAsInstanceMethodAnalysisResult analysis = CallExtensionMethodAsInstanceMethodAnalysis.Analyze(invocation, semanticModel, allowAnyExpression: false, cancellationToken: cancellationToken);

            if (!analysis.Success)
            {
                return;
            }

            if (semanticModel
                .GetEnclosingNamedType(analysis.InvocationExpression.SpanStart, cancellationToken)?
                .Equals(analysis.MethodSymbol.ContainingType) != false)
            {
                return;
            }

            DiagnosticHelpers.ReportDiagnostic(context, DiagnosticDescriptors.CallExtensionMethodAsInstanceMethod, invocation);
        }
        private static void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext context)
        {
            var invocation = (InvocationExpressionSyntax)context.Node;

            if (UseBitwiseOperationInsteadOfCallingHasFlagAnalysis.IsFixable(invocation, context.SemanticModel, context.CancellationToken) &&
                !invocation.SpanContainsDirectives())
            {
                context.ReportDiagnostic(DiagnosticDescriptors.UseBitwiseOperationInsteadOfCallingHasFlag, invocation);
            }

            RemoveRedundantStringToCharArrayCallAnalysis.Analyze(context, invocation);

            SimplifyLinqMethodChainAnalysis.AnalyzeWhereAndAny(context);

            if (!invocation.ContainsDiagnostics)
            {
                if (!invocation.SpanContainsDirectives())
                {
                    CallExtensionMethodAsInstanceMethodAnalysisResult analysis = CallExtensionMethodAsInstanceMethodAnalysis.Analyze(invocation, context.SemanticModel, allowAnyExpression: false, cancellationToken: context.CancellationToken);

                    if (analysis.Success &&
                        context.SemanticModel
                        .GetEnclosingNamedType(analysis.InvocationExpression.SpanStart, context.CancellationToken)?
                        .Equals(analysis.MethodSymbol.ContainingType) == false)
                    {
                        context.ReportDiagnostic(DiagnosticDescriptors.CallExtensionMethodAsInstanceMethod, invocation);
                    }
                }

                SimpleMemberInvocationExpressionInfo invocationInfo = SyntaxInfo.SimpleMemberInvocationExpressionInfo(invocation);

                if (invocationInfo.Success)
                {
                    if (!invocation.SpanContainsDirectives())
                    {
                        UseRegexInstanceInsteadOfStaticMethodAnalysis.Analyze(context, invocationInfo);
                    }

                    string methodName = invocationInfo.NameText;

                    AvoidNullReferenceExceptionAnalyzer.Analyze(context, invocationInfo);

                    CallStringConcatInsteadOfStringJoinAnalysis.Analyze(context, invocationInfo);

                    int argumentCount = invocationInfo.Arguments.Count;

                    switch (argumentCount)
                    {
                    case 0:
                        {
                            switch (methodName)
                            {
                            case "Any":
                            {
                                UseCountOrLengthPropertyInsteadOfAnyMethodAnalysis.Analyze(context, invocationInfo);

                                SimplifyLinqMethodChainAnalysis.AnalyzeWhere(context, invocationInfo);
                                break;
                            }

                            case "Cast":
                            {
                                SimplifyLinqMethodChainAnalysis.AnalyzeWhereAndCast(context, invocationInfo);
                                RemoveRedundantCastAnalyzer.Analyze(context, invocationInfo);
                                break;
                            }

                            case "Count":
                            {
                                UseInsteadOfCountMethodAnalysis.Analyze(context, invocationInfo);
                                SimplifyLinqMethodChainAnalysis.AnalyzeWhere(context, invocationInfo);
                                break;
                            }

                            case "First":
                            {
                                if (!invocationInfo.Expression.IsKind(SyntaxKind.InvocationExpression) &&
                                    UseElementAccessInsteadOfFirstAnalysis.IsFixable(invocationInfo, context.SemanticModel, context.CancellationToken))
                                {
                                    context.ReportDiagnostic(DiagnosticDescriptors.UseElementAccessInsteadOfFirst, invocationInfo.Name);
                                }

                                SimplifyLinqMethodChainAnalysis.AnalyzeWhere(context, invocationInfo);
                                break;
                            }

                            case "ToString":
                            {
                                RemoveRedundantToStringCallAnalysis.Analyze(context, invocationInfo);
                                UseNameOfOperatorAnalyzer.Analyze(context, invocationInfo);
                                break;
                            }

                            case "ToLower":
                            case "ToLowerInvariant":
                            case "ToUpper":
                            case "ToUpperInvariant":
                            {
                                UseStringComparisonAnalysis.Analyze(context, invocationInfo);
                                break;
                            }

                            case "FirstOrDefault":
                            case "Last":
                            case "LastOrDefault":
                            case "LongCount":
                            case "Single":
                            case "SingleOrDefault":
                            {
                                SimplifyLinqMethodChainAnalysis.AnalyzeWhere(context, invocationInfo);
                                break;
                            }
                            }

                            break;
                        }

                    case 1:
                    {
                        switch (methodName)
                        {
                        case "All":
                        case "Any":
                        {
                            SimplifyLogicalNegationAnalyzer.Analyze(context, invocationInfo);
                            break;
                        }

                        case "ElementAt":
                        {
                            if (!invocationInfo.Expression.IsKind(SyntaxKind.InvocationExpression) &&
                                UseElementAccessInsteadOfElementAtAnalysis.IsFixable(invocationInfo, context.SemanticModel, context.CancellationToken))
                            {
                                context.ReportDiagnostic(DiagnosticDescriptors.UseElementAccessInsteadOfElementAt, invocationInfo.Name);
                            }

                            break;
                        }

                        case "FirstOrDefault":
                        {
                            SimplifyLinqMethodChainAnalysis.AnalyzeFirstOrDefault(context, invocationInfo);
                            CallFindInsteadOfFirstOrDefaultAnalysis.Analyze(context, invocationInfo);
                            break;
                        }

                        case "Where":
                        {
                            CombineEnumerableWhereMethodChainAnalysis.Analyze(context, invocationInfo);
                            break;
                        }
                        }

                        break;
                    }
                    }

                    switch (methodName)
                    {
                    case "Append":
                    case "AppendLine":
                    case "AppendFormat":
                    case "Insert":
                    {
                        OptimizeStringBuilderAppendCallAnalysis.Analyze(context, invocationInfo);
                        break;
                    }

                    case "Select":
                    {
                        if (argumentCount == 1 ||
                            argumentCount == 2)
                        {
                            CallCastInsteadOfSelectAnalysis.Analyze(context, invocationInfo);
                        }

                        break;
                    }

                    case "OrderBy":
                    case "OrderByDescending":
                    {
                        if (argumentCount == 1 ||
                            argumentCount == 2 ||
                            argumentCount == 3)
                        {
                            CallThenByInsteadOfOrderByAnalysis.Analyze(context, invocationInfo);
                        }

                        break;
                    }
                    }

                    if (UseMethodChainingAnalysis.IsFixable(invocationInfo, context.SemanticModel, context.CancellationToken))
                    {
                        context.ReportDiagnostic(DiagnosticDescriptors.UseMethodChaining, invocationInfo.InvocationExpression);
                    }
                }
            }
        }