/// <summary>
        /// Analyzes node.
        /// </summary>
        /// <param name="context">The context.</param>
        private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
        {
            FieldDeclarationSyntax node = context.Node as FieldDeclarationSyntax;

            // Only const field.
            if (!node.Modifiers.Any(SyntaxKind.ConstKeyword))
            {
                return;
            }

            if (Configuration.IsEnabledForPublicMembersOnly && PrivateMemberChecker.IsPrivateMember(node))
            {
                return;
            }

            DocumentationCommentTriviaSyntax commentTriviaSyntax = node
                                                                   .GetLeadingTrivia()
                                                                   .Select(o => o.GetStructure())
                                                                   .OfType <DocumentationCommentTriviaSyntax>()
                                                                   .FirstOrDefault();

            if (commentTriviaSyntax != null && CommentHelper.HasComment(commentTriviaSyntax))
            {
                return;
            }

            VariableDeclaratorSyntax field = node.DescendantNodes().OfType <VariableDeclaratorSyntax>().First();

            context.ReportDiagnostic(Diagnostic.Create(Rule, field.GetLocation()));
        }
        /// <summary>
        /// Analyzes node.
        /// </summary>
        /// <param name="context">The context.</param>
        private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
        {
            InterfaceDeclarationSyntax node = context.Node as InterfaceDeclarationSyntax;

            DocumentationCommentTriviaSyntax commentTriviaSyntax = node
                                                                   .GetLeadingTrivia()
                                                                   .Select(o => o.GetStructure())
                                                                   .OfType <DocumentationCommentTriviaSyntax>()
                                                                   .FirstOrDefault();

            if (commentTriviaSyntax != null && CommentHelper.HasComment(commentTriviaSyntax))
            {
                return;
            }

            context.ReportDiagnostic(Diagnostic.Create(Rule, node.Identifier.GetLocation()));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Analyzes node.
        /// </summary>
        /// <param name="context">The context.</param>
        private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
        {
            MethodDeclarationSyntax node = context.Node as MethodDeclarationSyntax;

            if (Configuration.IsEnabledForPublishMembersOnly && PrivateMemberVerifier.IsPrivateMember(node))
            {
                return;
            }

            DocumentationCommentTriviaSyntax commentTriviaSyntax = node
                                                                   .GetLeadingTrivia()
                                                                   .Select(o => o.GetStructure())
                                                                   .OfType <DocumentationCommentTriviaSyntax>()
                                                                   .FirstOrDefault();

            if (commentTriviaSyntax != null && CommentHelper.HasComment(commentTriviaSyntax))
            {
                return;
            }

            context.ReportDiagnostic(Diagnostic.Create(Rule, node.Identifier.GetLocation()));
        }