/// <summary> /// Adds documentation header async. /// </summary> /// <param name="document">The document.</param> /// <param name="root">The root.</param> /// <param name="declarationSyntax">The declaration syntax.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>A Document.</returns> private async Task <Document> AddDocumentationHeaderAsync(Document document, SyntaxNode root, FieldDeclarationSyntax declarationSyntax, CancellationToken cancellationToken) { SyntaxTriviaList leadingTrivia = declarationSyntax.GetLeadingTrivia(); VariableDeclaratorSyntax field = declarationSyntax.DescendantNodes().OfType <VariableDeclaratorSyntax>().First(); string comment = CommentHelper.CreateFieldComment(field.Identifier.ValueText); DocumentationCommentTriviaSyntax commentTrivia = await Task.Run(() => DocumentationHeaderHelper.CreateOnlySummaryDocumentationCommentTrivia(comment), cancellationToken); SyntaxTriviaList newLeadingTrivia = leadingTrivia.Insert(leadingTrivia.Count - 1, SyntaxFactory.Trivia(commentTrivia)); FieldDeclarationSyntax newDeclaration = declarationSyntax.WithLeadingTrivia(newLeadingTrivia); SyntaxNode newRoot = root.ReplaceNode(declarationSyntax, newDeclaration); return(document.WithSyntaxRoot(newRoot)); }