Exemplo n.º 1
0
        private SyntaxNode AddDescription(SyntaxNode rootNode, MemberDeclarationSyntax memberDeclaration,
                                          string description, CancellationToken cancellation)
        {
            cancellation.ThrowIfCancellationRequested();

            var summaryTag = memberDeclaration
                             .GetLeadingTrivia()
                             .Select(t => t.GetStructure())
                             .OfType <DocumentationCommentTriviaSyntax>()
                             .SelectMany(d => d.ChildNodes())
                             .OfType <XmlElementSyntax>()
                             .First(n => XmlCommentSummaryTag.Equals(n.StartTag?.Name?.ToString(), StringComparison.Ordinal));

            var xmlDescription = new[]
            {
                XmlText(
                    XmlTextNewLine(Environment.NewLine, true)
                    ),
                XmlText(
                    XmlTextNewLine(description + Environment.NewLine, true)
                    )
            };
            var newContent    = new SyntaxList <XmlNodeSyntax>(xmlDescription);
            var newSummaryTag = summaryTag
                                .WithContent(newContent)
                                .WithAdditionalAnnotations(Formatter.Annotation);

            return(rootNode.ReplaceNode(summaryTag, newSummaryTag));
        }
Exemplo n.º 2
0
 private XmlElementSyntax GetSummaryTag(DocumentationCommentTriviaSyntax xmlComment) =>
 xmlComment
 .ChildNodes()
 .OfType <XmlElementSyntax>()
 .FirstOrDefault(n => XmlCommentSummaryTag.Equals(n.StartTag?.Name?.ToString(), StringComparison.Ordinal));