diff --git a/src/EcoCode.Core/Analyzers/EC87.UseListIndexer.cs b/src/EcoCode.Core/Analyzers/EC87.UseListIndexer.cs index d17f5464..f90e47d3 100644 --- a/src/EcoCode.Core/Analyzers/EC87.UseListIndexer.cs +++ b/src/EcoCode.Core/Analyzers/EC87.UseListIndexer.cs @@ -38,9 +38,8 @@ public override void Initialize(AnalysisContext context) private static void AnalyzeInvocationExpression(SyntaxNodeAnalysisContext context) { var invocationExpr = (InvocationExpressionSyntax)context.Node; - var memberAccess = (MemberAccessExpressionSyntax)invocationExpr.Expression; - - if (context.SemanticModel.GetSymbolInfo(invocationExpr).Symbol is not IMethodSymbol method || + if (invocationExpr.Expression is not MemberAccessExpressionSyntax memberAccess || + context.SemanticModel.GetSymbolInfo(invocationExpr).Symbol is not IMethodSymbol method || !method.IsExtensionMethod || !SymbolEqualityComparer.Default.Equals(method.ContainingType, context.Compilation.GetTypeByMetadataName(typeof(Enumerable).FullName))) {