/// <summary> /// Gets the changes necessary to format a specified documentation comment node. /// </summary> /// <param name="node">The documentation comment node to format.</param> /// <param name="options">The options that control formatting behavior.</param> /// <param name="cancellationToken">The cancellation token to observe.</param> /// <returns>The changes that will format the XML documentation comment.</returns> /// <exception cref="ArgumentNullException"><paramref name="node"/> is /// <see langword="null"/>.</exception> /// <exception cref="ArgumentNullException"><paramref name="options"/> is /// <see langword="null"/>.</exception> public static IList <TextChange> Format(DocumentationCommentTriviaSyntax node, OptionSet options, CancellationToken cancellationToken = default) { if (node == null) { throw new ArgumentNullException(nameof(node)); } if (options == null) { throw new ArgumentNullException(nameof(options)); } var formatter = new DocXmlFormatter(options); formatter.Format(node, cancellationToken); return(formatter._changes); }
/// <summary> /// Determines the changes necessary to format the XML documentation comments that overlap a /// specified span of a specified document. /// </summary> /// <param name="document">The document to format the XML documentation comments in.</param> /// <param name="span">The span to format in the document. XML documentation comments that /// overlap the span will be formatted.</param> /// <param name="options">The options that control formatting behavior. If /// <paramref name="options"/> is <see langword="null"/> then the options from the /// workspace are used.</param> /// <param name="cancellationToken">The cancellation token to observe.</param> /// <returns>The changes that will format the XML documentation comments.</returns> /// <exception cref="ArgumentNullException"><paramref name="document"/> is /// <see langword="null"/>.</exception> public static async Task <IList <TextChange> > FormatAsync(Document document, TextSpan span, OptionSet options = null, CancellationToken cancellationToken = default) { if (document == null) { throw new ArgumentNullException(nameof(document)); } if (options == null) { options = document.Project.Solution.Workspace.Options; } var formatter = new DocXmlFormatter(options); var rootNode = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false); foreach (var node in DocXmlFinder.FindNodes(rootNode, span)) { formatter.Format(node, cancellationToken); } return(formatter._changes); }