Beispiel #1
0
        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;
            }
        }
Beispiel #2
0
        private bool HasTestAttribute(IEnumerable <BaseTypeDeclarationSyntax> baseTypes)
        {
            if (baseTypes.Any(baseType => AnalyzerUtil.IsTestAttribute(baseType.AttributeLists)))
            {
                return(true);
            }

            return(false);
        }
Beispiel #3
0
 private bool IsAllParentsValid(SyntaxNode node)
 {
     return(node.Ancestors(false).OfType <BaseTypeDeclarationSyntax>()
            .All(ancestor => IsPublicType(ancestor.Modifiers) &&
                 !AnalyzerUtil.IsTestAttribute(ancestor.AttributeLists)));
 }