From 0f74c565b752d3743c99d10b0eba7c7d5df52ad9 Mon Sep 17 00:00:00 2001 From: Zsolt Kolbay <121798625+zsolt-kolbay-sonarsource@users.noreply.github.com> Date: Fri, 3 Mar 2023 15:49:19 +0100 Subject: [PATCH] Replace SyntaxWalker with SafeSyntaxWalker (#6852) --- .../Rules/PrivateStaticMethodUsedOnlyByNestedClass.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/analyzers/src/SonarAnalyzer.CSharp/Rules/PrivateStaticMethodUsedOnlyByNestedClass.cs b/analyzers/src/SonarAnalyzer.CSharp/Rules/PrivateStaticMethodUsedOnlyByNestedClass.cs index bfb3748020a..bd886ec8212 100644 --- a/analyzers/src/SonarAnalyzer.CSharp/Rules/PrivateStaticMethodUsedOnlyByNestedClass.cs +++ b/analyzers/src/SonarAnalyzer.CSharp/Rules/PrivateStaticMethodUsedOnlyByNestedClass.cs @@ -134,7 +134,7 @@ private static TypeDeclarationSyntax LowestCommonAncestorOrSelf(IEnumerable methods, TypeDeclarationSyntax outerType, SemanticModel model) { var collector = new PotentialMethodReferenceCollector(methods); - collector.Visit(outerType); + collector.SafeVisit(outerType); return collector.PotentialMethodReferences .Where(x => !OnlyUsedByOuterType(x)) @@ -181,7 +181,7 @@ private sealed record MethodUsedByTypes(MethodDeclarationSyntax Method, TypeDecl /// Performance gains: by only using the syntax tree to find matches we can eliminate certain methods (which are only used by the type which has declared it) /// without using the more costly symbolic lookup. /// - private sealed class PotentialMethodReferenceCollector : CSharpSyntaxWalker + private sealed class PotentialMethodReferenceCollector : SafeCSharpSyntaxWalker { private readonly ISet methodsToFind; private readonly Dictionary> potentialMethodReferences;