diff --git a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.Analyzer.cs b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.Analyzer.cs index ae2331428e..3fd92de57d 100644 --- a/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.Analyzer.cs +++ b/src/NetAnalyzers/Core/Microsoft.NetCore.Analyzers/Performance/RecommendCaseInsensitiveStringComparison.Analyzer.cs @@ -203,22 +203,22 @@ private void AnalyzeCompilationStart(CompilationStartAnalysisContext context) return; } + // a.ToLower().Method() context.RegisterOperationAction(context => { - if (context.Operation is IInvocationOperation caseChangingInvocation) - { - AnalyzeInvocation(context, caseChangingInvocation, stringType, - containsStringMethod, startsWithStringMethod, compareToStringMethod, - indexOfStringMethod, indexOfStringInt32Method, indexOfStringInt32Int32Method); - } - else if (context.Operation is IBinaryOperation binaryOperation) - { - AnalyzeBinaryOperation(context, binaryOperation, stringType); - } - }, - OperationKind.Invocation, // a.ToLower().Method() - OperationKind.Binary // a.ToLower() == b.ToLower() - ); + IInvocationOperation caseChangingInvocation = (IInvocationOperation)context.Operation; + AnalyzeInvocation(context, caseChangingInvocation, stringType, + containsStringMethod, startsWithStringMethod, compareToStringMethod, + indexOfStringMethod, indexOfStringInt32Method, indexOfStringInt32Int32Method); + }, OperationKind.Invocation); + + // a.ToLower() == b.ToLower() + context.RegisterOperationAction(context => + { + IBinaryOperation binaryOperation = (IBinaryOperation)context.Operation; + AnalyzeBinaryOperation(context, binaryOperation, stringType); + + }, OperationKind.Binary); } private static void AnalyzeInvocation(OperationAnalysisContext context, IInvocationOperation caseChangingInvocation, INamedTypeSymbol stringType,