@@ -67,7 +67,7 @@ void AnalyzeBlock(IOperation block)
6767 // If the throw is the top-level operation in the containing symbol, report a diagnostic on the
6868 // symbol as well. Note: consider reporting on the entire symbol, instead of just the name. And in
6969 // this case, do not report directly on the throw as well.
70- if ( IsTopLevel ( block , operation ) )
70+ if ( ShouldReportAsTopLevel ( block , operation ) )
7171 {
7272 foreach ( var location in context . OwningSymbol . Locations )
7373 {
@@ -84,7 +84,7 @@ void AnalyzeBlock(IOperation block)
8484 }
8585 }
8686
87- private static bool IsTopLevel ( IOperation block , IOperation operation )
87+ private static bool ShouldReportAsTopLevel ( IOperation block , IOperation operation )
8888 {
8989 if ( block is IBlockOperation { Operations : [ var child ] } )
9090 {
@@ -93,17 +93,20 @@ private static bool IsTopLevel(IOperation block, IOperation operation)
9393 return true ;
9494
9595 // Handle: => throw new NotImplementedException();
96- if ( child is IReturnOperation { ReturnedValue : IConversionOperation { Operand : var operand } } && operand == operation )
97- {
98- if ( operation . Syntax is ThrowExpressionSyntax throwExpression )
96+ if ( child is IReturnOperation
9997 {
100- // Exclude property declarations with expression bodies
101- if ( throwExpression . Parent is ArrowExpressionClauseSyntax { Parent : PropertyDeclarationSyntax } )
102- return false ;
103-
104- // Include expression-bodied methods and get accessors
105- return true ;
106- }
98+ ReturnedValue : IConversionOperation
99+ {
100+ Operand : var operand
101+ }
102+ } && operand == operation &&
103+ // Excluding property declarations with expression bodies
104+ // Because their location is an exact match with the throw operation
105+ // and we don't want to report the same location twice
106+ ! ( operation . Syntax . Parent is ArrowExpressionClauseSyntax { Parent : PropertyDeclarationSyntax } ) )
107+ {
108+ // Include expression-bodied methods and get accessors
109+ return true ;
107110 }
108111
109112 // Handle expression-bodied set accessors
0 commit comments