@@ -98,15 +98,7 @@ void OnOperationBlockStart(OperationBlockStartAnalysisContext blockStartContext)
98
98
}
99
99
100
100
// Don't run any other check for this method if it isn't a valid analysis context
101
- if ( ! ShouldAnalyze ( methodSymbol , wellKnownTypeProvider , skippedAttributes ,
102
- blockStartContext . Options , isWebProject , blockStartContext . CancellationToken ) )
103
- {
104
- return ;
105
- }
106
-
107
- // Don't report methods which have a single throw statement
108
- // with NotImplementedException or NotSupportedException
109
- if ( blockStartContext . IsMethodNotImplementedOrSupported ( ) )
101
+ if ( ! ShouldAnalyze ( methodSymbol , wellKnownTypeProvider , skippedAttributes , isWebProject , blockStartContext ) )
110
102
{
111
103
return ;
112
104
}
@@ -191,9 +183,10 @@ private static bool ShouldAnalyze(
191
183
IMethodSymbol methodSymbol ,
192
184
WellKnownTypeProvider wellKnownTypeProvider ,
193
185
ImmutableArray < INamedTypeSymbol > skippedAttributes ,
194
- AnalyzerOptions options ,
195
186
bool isWebProject ,
196
- CancellationToken cancellationToken )
187
+ #pragma warning disable RS1012 // Start action has no registered actions
188
+ OperationBlockStartAnalysisContext blockStartContext )
189
+ #pragma warning restore RS1012 // Start action has no registered actions
197
190
{
198
191
// Modifiers that we don't care about
199
192
if ( methodSymbol . IsStatic || methodSymbol . IsOverride || methodSymbol . IsVirtual ||
@@ -208,15 +201,31 @@ private static bool ShouldAnalyze(
208
201
return false ;
209
202
}
210
203
211
- // Do not analyze public APIs for web projects
212
- // See https://github.com/dotnet/roslyn-analyzers/issues/3835 for details.
213
- if ( isWebProject && methodSymbol . IsExternallyVisible ( ) )
204
+ // Don't report methods which have a single throw statement
205
+ // with NotImplementedException or NotSupportedException
206
+ if ( blockStartContext . IsMethodNotImplementedOrSupported ( ) )
214
207
{
215
208
return false ;
216
209
}
217
210
218
- // CA1000 says one shouldn't declare static members on generic types. So don't flag such cases.
219
- if ( methodSymbol . ContainingType . IsGenericType && methodSymbol . IsExternallyVisible ( ) )
211
+ if ( methodSymbol . IsExternallyVisible ( ) )
212
+ {
213
+ // Do not analyze public APIs for web projects
214
+ // See https://github.com/dotnet/roslyn-analyzers/issues/3835 for details.
215
+ if ( isWebProject )
216
+ {
217
+ return false ;
218
+ }
219
+
220
+ // CA1000 says one shouldn't declare static members on generic types. So don't flag such cases.
221
+ if ( methodSymbol . ContainingType . IsGenericType )
222
+ {
223
+ return false ;
224
+ }
225
+ }
226
+
227
+ // We consider that auto-property have the intent to always be instance members so we want to workaround this issue.
228
+ if ( methodSymbol . IsAutoPropertyAccessor ( ) )
220
229
{
221
230
return false ;
222
231
}
@@ -248,14 +257,14 @@ private static bool ShouldAnalyze(
248
257
return false ;
249
258
}
250
259
251
- if ( ! options . MatchesConfiguredVisibility ( Rule , methodSymbol , wellKnownTypeProvider . Compilation , cancellationToken ,
252
- defaultRequiredVisibility : SymbolVisibilityGroup . All ) )
260
+ var hasCorrectVisibility = blockStartContext . Options . MatchesConfiguredVisibility ( Rule , methodSymbol , wellKnownTypeProvider . Compilation ,
261
+ blockStartContext . CancellationToken , defaultRequiredVisibility : SymbolVisibilityGroup . All ) ;
262
+ if ( ! hasCorrectVisibility )
253
263
{
254
264
return false ;
255
265
}
256
266
257
- // We consider that auto-property have the intent to always be instance members so we want to workaround this issue.
258
- return ! methodSymbol . IsAutoPropertyAccessor ( ) ;
267
+ return true ;
259
268
}
260
269
261
270
private static bool IsExplicitlyVisibleFromCom ( IMethodSymbol methodSymbol , WellKnownTypeProvider wellKnownTypeProvider )
0 commit comments