private void AnalyzeClassSyntaxNode(SyntaxNodeAnalysisContext context) { var node = (ClassDeclarationSyntax)context.Node; if (AnalyzerUtil.IsTestAttribute(node.AttributeLists)) { return; } if (!IsPublicType(node.Modifiers)) { return; } var xmlTrivia = GetXmlTrivia(node); if (xmlTrivia == null) { context.ReportDiagnostic(Diagnostic.Create(NoCommentRule, node.Identifier.GetLocation(), node.Identifier.Text)); return; } if (!HasXmlNameTag(xmlTrivia, summaryTag)) { context.ReportDiagnostic(Diagnostic.Create(NoSummaryRule, node.Identifier.GetLocation(), node.Identifier.Text)); return; } if (!HasXmlNameTag(xmlTrivia, codeTag)) { context.ReportDiagnostic(Diagnostic.Create(NoCodeRule, node.Identifier.GetLocation(), node.Identifier.Text)); return; } }
private bool HasTestAttribute(IEnumerable <BaseTypeDeclarationSyntax> baseTypes) { if (baseTypes.Any(baseType => AnalyzerUtil.IsTestAttribute(baseType.AttributeLists))) { return(true); } return(false); }
private bool IsAllParentsValid(SyntaxNode node) { return(node.Ancestors(false).OfType <BaseTypeDeclarationSyntax>() .All(ancestor => IsPublicType(ancestor.Modifiers) && !AnalyzerUtil.IsTestAttribute(ancestor.AttributeLists))); }