protected virtual Diagnostic AnalyzeStatement(SemanticModel semanticModel, LocalDeclarationStatementSyntax statement) { var symbolInfo = semanticModel.GetSymbolInfo(statement.Declaration.Type); if (symbolInfo.Symbol?.Name != nameof(Action)) { return(null); } foreach (var variable in statement.Declaration.Variables) { if (variable.Initializer == null) { continue; } if (!(variable.Initializer.Value is ParenthesizedLambdaExpressionSyntax lambda)) { continue; } if (lambda.AsyncKeyword.IsKind(SyntaxKind.AsyncKeyword)) { return(Diagnostic.Create(descriptor: Rule, location: statement.GetLocation())); } } return(null); }
public override void VisitLocalDeclarationStatement(LocalDeclarationStatementSyntax node) { if (entryNode is AnonymousFunctionExpressionSyntax && embeddedNode is AnonymousFunctionExpressionSyntax) { return; } if (_weComeFromMethod && _weInAnonymousMethod) { return; } InsertLLOCMap(node.GetLocation()); foreach (var variable in node.Declaration.Variables) { InsertLLOCMap(variable.GetLocation()); } base.VisitLocalDeclarationStatement(node); }