@@ -30,18 +30,12 @@ private sealed class RoslynChecker : IChecker
3030 public void CheckForNoExitProperty ( SonarSyntaxNodeReportingContext c , PropertyDeclarationSyntax property , IPropertySymbol propertySymbol ) =>
3131 CheckForNoExit ( c ,
3232 propertySymbol ,
33- property . ExpressionBody ,
34- property . AccessorList ,
35- property . Identifier . GetLocation ( ) ,
3633 "property's recursion" ,
3734 "property accessor's recursion" ) ;
3835
3936 public void CheckForNoExitIndexer ( SonarSyntaxNodeReportingContext c , IndexerDeclarationSyntax indexer , IPropertySymbol propertySymbol ) =>
4037 CheckForNoExit ( c ,
4138 propertySymbol ,
42- indexer . ExpressionBody ,
43- indexer . AccessorList ,
44- indexer . ThisKeyword . GetLocation ( ) ,
4539 "indexer's recursion" ,
4640 "indexer accessor's recursion" ) ;
4741
@@ -71,12 +65,26 @@ public void CheckForNoExitMethod(SonarSyntaxNodeReportingContext c, SyntaxNode b
7165
7266 private static void CheckForNoExit ( SonarSyntaxNodeReportingContext c ,
7367 IPropertySymbol propertySymbol ,
74- ArrowExpressionClauseSyntax expressionBody ,
75- AccessorListSyntax accessorList ,
76- Location location ,
7768 string arrowExpressionMessageArg ,
7869 string accessorMessageArg )
7970 {
71+ ArrowExpressionClauseSyntax expressionBody = null ;
72+ AccessorListSyntax accessorList = null ;
73+ Location location = null ;
74+
75+ if ( c . Node is PropertyDeclarationSyntax propertyDeclaration )
76+ {
77+ expressionBody = propertyDeclaration . ExpressionBody ;
78+ accessorList = propertyDeclaration . AccessorList ;
79+ location = propertyDeclaration . Identifier . GetLocation ( ) ;
80+ }
81+ else if ( c . Node is IndexerDeclarationSyntax indexerDeclaration )
82+ {
83+ expressionBody = indexerDeclaration . ExpressionBody ;
84+ accessorList = indexerDeclaration . AccessorList ;
85+ location = indexerDeclaration . ThisKeyword . GetLocation ( ) ;
86+ }
87+
8088 if ( expressionBody ? . Expression is not null )
8189 {
8290 var cfg = ControlFlowGraph . Create ( expressionBody , c . SemanticModel , c . Cancel ) ;
0 commit comments