本文整理汇总了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);
}
示例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));
}
}
}
示例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);
}