Skip to content
This repository was archived by the owner on Oct 2, 2022. It is now read-only.

Commit dbad6eb

Browse files
bkoelmanbkoelman
authored andcommitted
Call async version of Roslyn Formatter API
1 parent 5fa3ce7 commit dbad6eb

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

src/CodeContractNullability/CodeContractNullability/BaseCodeFixProvider.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ private async Task<Document> WithAttributeAsync([NotNull] INamedTypeSymbol attri
141141
cancellationToken).ConfigureAwait(false);
142142

143143
// Simplify and reformat all annotated nodes.
144-
Document simplified = await SimplifyAsync(documentWithImport, cancellationToken).ConfigureAwait(false);
145-
SyntaxNode formatted = await FormatAsync(simplified, cancellationToken).ConfigureAwait(false);
146-
return simplified.WithSyntaxRoot(formatted);
144+
Document simplified =
145+
await Simplifier.ReduceAsync(documentWithImport, null, cancellationToken).ConfigureAwait(false);
146+
Document formatted = await Formatter.FormatAsync(simplified, null, cancellationToken).ConfigureAwait(false);
147+
return formatted;
147148
}
148149

149150
private void RegisterCodeFixFor([NotNull] Func<CancellationToken, Task<Document>> applyFixAction,
@@ -152,22 +153,5 @@ private void RegisterCodeFixFor([NotNull] Func<CancellationToken, Task<Document>
152153
CodeAction codeAction = CodeAction.Create(description, applyFixAction, description);
153154
context.RegisterCodeFix(codeAction, diagnostic);
154155
}
155-
156-
[NotNull]
157-
[ItemNotNull]
158-
private static async Task<Document> SimplifyAsync([NotNull] Document document,
159-
CancellationToken cancellationToken)
160-
{
161-
return await Simplifier.ReduceAsync(document, cancellationToken: cancellationToken).ConfigureAwait(false);
162-
}
163-
164-
[NotNull]
165-
[ItemNotNull]
166-
private static async Task<SyntaxNode> FormatAsync([NotNull] Document document,
167-
CancellationToken cancellationToken)
168-
{
169-
SyntaxNode root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
170-
return Formatter.Format(root, document.Project.Solution.Workspace);
171-
}
172156
}
173157
}

0 commit comments

Comments
 (0)