diff --git a/ChangeLog.md b/ChangeLog.md index 0f8f0a1952..f279354439 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Fix analyzer [RCS1246](https://josefpihrt.github.io/docs/roslynator/analyzers/RCS1246) ([PR](https://github.com/dotnet/roslynator/pull/1460)) + ## [4.12.2] - 2024-04-23 ### Fixed diff --git a/src/Common/CSharp/Analysis/UseElementAccessAnalysis.cs b/src/Common/CSharp/Analysis/UseElementAccessAnalysis.cs index b96ac44334..a8f93f4103 100644 --- a/src/Common/CSharp/Analysis/UseElementAccessAnalysis.cs +++ b/src/Common/CSharp/Analysis/UseElementAccessAnalysis.cs @@ -77,6 +77,9 @@ public static bool IsFixableLast( if (((CSharpCompilation)semanticModel.Compilation).LanguageVersion < LanguageVersion.CSharp8) return false; + if (semanticModel.Compilation.GetTypeByMetadataName("System.Index") is null) + return false; + IMethodSymbol methodSymbol = semanticModel.GetReducedExtensionMethodInfo(invocationInfo.InvocationExpression, cancellationToken).Symbol; if (methodSymbol is null)