当前位置: 首页>>代码示例>>C#>>正文


C# SyntaxNode.GetDocumentationCommentTriviaSyntax方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.SyntaxNode.GetDocumentationCommentTriviaSyntax方法的典型用法代码示例。如果您正苦于以下问题:C# SyntaxNode.GetDocumentationCommentTriviaSyntax方法的具体用法?C# SyntaxNode.GetDocumentationCommentTriviaSyntax怎么用?C# SyntaxNode.GetDocumentationCommentTriviaSyntax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.SyntaxNode的用法示例。


在下文中一共展示了SyntaxNode.GetDocumentationCommentTriviaSyntax方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandleDeclaration

        private void HandleDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, params Location[] locations)
        {
            var documentation = node.GetDocumentationCommentTriviaSyntax();
            if (documentation == null)
            {
                // missing documentation is reported by SA1600, SA1601, and SA1602
                return;
            }

            if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null)
            {
                // Ignore nodes with an <inheritdoc/> tag.
                return;
            }

            var valueXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.ValueXmlTag);
            this.HandleXmlElement(context, valueXmlElement, locations);
        }
开发者ID:robinsedlaczek,项目名称:StyleCopAnalyzers,代码行数:18,代码来源:PropertyDocumentationSummaryBase.cs

示例2: HandleMemberDeclaration

        private static void HandleMemberDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, TypeParameterListSyntax typeParameterList)
        {
            if (typeParameterList == null)
            {
                // The member does not have a type parameter list
                return;
            }

            var documentation = node.GetDocumentationCommentTriviaSyntax();

            if (documentation == null)
            {
                // Don't report if the documentation is missing
                return;
            }

            if (documentation.Content.GetFirstXmlElement(XmlCommentHelper.InheritdocXmlTag) != null)
            {
                // Ignore nodes with an <inheritdoc/> tag.
                return;
            }

            var xmlParameterNames = documentation.Content.GetXmlElements(XmlCommentHelper.TypeParamXmlTag)
                .Select(XmlCommentHelper.GetFirstAttributeOrDefault<XmlNameAttributeSyntax>)
                .Where(x => x != null)
                .ToImmutableArray();

            foreach (var parameter in typeParameterList.Parameters)
            {
                if (!xmlParameterNames.Any(x => x.Identifier.Identifier.ValueText == parameter.Identifier.ValueText))
                {
                    context.ReportDiagnostic(Diagnostic.Create(Descriptor, parameter.Identifier.GetLocation(), parameter.Identifier.ValueText));
                }
            }
        }
开发者ID:endjin,项目名称:StyleCopAnalyzers,代码行数:35,代码来源:SA1618GenericTypeParametersMustBeDocumented.cs

示例3: HandleDeclaration

        private void HandleDeclaration(SyntaxNodeAnalysisContext context, SyntaxNode node, params Location[] locations)
        {
            var documentation = node.GetDocumentationCommentTriviaSyntax();
            if (documentation == null)
            {
                // missing documentation is reported by SA1600, SA1601, and SA1602
                return;
            }

            XElement completeDocumentation = null;
            var relevantXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.SummaryXmlTag);
            if (relevantXmlElement == null)
            {
                relevantXmlElement = documentation.Content.GetFirstXmlElement(XmlCommentHelper.IncludeXmlTag);
                if (relevantXmlElement != null)
                {
                    var declaration = context.SemanticModel.GetDeclaredSymbol(node, context.CancellationToken);
                    if (declaration == null)
                    {
                        return;
                    }

                    var rawDocumentation = declaration.GetDocumentationCommentXml(expandIncludes: true, cancellationToken: context.CancellationToken);
                    completeDocumentation = XElement.Parse(rawDocumentation, LoadOptions.None);
                }
            }

            this.HandleXmlElement(context, documentation, relevantXmlElement, completeDocumentation, locations);
        }
开发者ID:neugenes,项目名称:StyleCopAnalyzers,代码行数:29,代码来源:ElementDocumentationSummaryBase.cs


注:本文中的Microsoft.CodeAnalysis.SyntaxNode.GetDocumentationCommentTriviaSyntax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。