File tree Expand file tree Collapse file tree
src/NServiceBus.AzureFunctions.Analyzer Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11namespace NServiceBus . AzureFunctions . Analyzer
22{
3+ using System ;
34 using System . Collections . Immutable ;
45 using Microsoft . CodeAnalysis ;
56 using Microsoft . CodeAnalysis . CSharp ;
@@ -23,22 +24,31 @@ public override void Initialize(AnalysisContext context)
2324
2425 static void Analyze ( SyntaxNodeAnalysisContext context )
2526 {
27+ if ( ! ( context . Node is InvocationExpressionSyntax invocationExpression ) )
28+ {
29+ return ;
30+ }
31+
32+ if ( ! ( invocationExpression . Expression is MemberAccessExpressionSyntax memberAccessExpression ) )
33+ {
34+ return ;
35+ }
36+
37+ if ( memberAccessExpression . Name . Identifier . Text != "PurgeOnStartup" )
38+ {
39+ return ;
40+ }
41+
42+ var memberAccessSymbol = context . SemanticModel . GetSymbolInfo ( memberAccessExpression , context . CancellationToken ) ;
43+
44+ if ( ! ( memberAccessSymbol . Symbol is IMethodSymbol methodSymbol ) )
45+ {
46+ return ;
47+ }
2648
27- if ( context . Node is InvocationExpressionSyntax invocationExpression )
49+ if ( methodSymbol . ReceiverType . ToString ( ) == "NServiceBus.EndpointConfiguration" )
2850 {
29- if ( invocationExpression . Expression is MemberAccessExpressionSyntax memberAccessExpression )
30- {
31- if ( memberAccessExpression . Name . Identifier . Text == "PurgeOnStartup" )
32- {
33- if ( memberAccessExpression . Expression is MemberAccessExpressionSyntax parentMemberAccessExpression )
34- {
35- if ( parentMemberAccessExpression . Name . Identifier . Text == "AdvancedConfiguration" )
36- {
37- context . ReportDiagnostic ( AzureFunctionsDiagnostics . PurgeOnStartupNotAllowed , invocationExpression ) ;
38- }
39- }
40- }
41- }
51+ context . ReportDiagnostic ( AzureFunctionsDiagnostics . PurgeOnStartupNotAllowed , invocationExpression ) ;
4252 }
4353 }
4454 }
You can’t perform that action at this time.
0 commit comments