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

Commit 0d96d82

Browse files
bkoelmanbkoelman
authored andcommitted
Fix: Pass along workspace options
1 parent dbad6eb commit 0d96d82

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/CodeContractNullability/CodeContractNullability/BaseCodeFixProvider.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Microsoft.CodeAnalysis.CSharp.Syntax;
1010
using Microsoft.CodeAnalysis.Editing;
1111
using Microsoft.CodeAnalysis.Formatting;
12+
using Microsoft.CodeAnalysis.Options;
1213
using Microsoft.CodeAnalysis.Simplification;
1314

1415
namespace CodeContractNullability
@@ -125,6 +126,8 @@ private static string GetDisplayNameFor([NotNull] INamedTypeSymbol attribute)
125126
private async Task<Document> WithAttributeAsync([NotNull] INamedTypeSymbol attribute,
126127
[NotNull] Document document, [NotNull] SyntaxNode syntaxNode, CancellationToken cancellationToken)
127128
{
129+
OptionSet options = document.Project.Solution.Workspace.Options;
130+
128131
DocumentEditor editor = await DocumentEditor.CreateAsync(document, cancellationToken).ConfigureAwait(false);
129132

130133
// Add NotNull/CanBeNull/ItemNotNull/ItemCanBeNull attribute.
@@ -137,13 +140,14 @@ private async Task<Document> WithAttributeAsync([NotNull] INamedTypeSymbol attri
137140
// Add namespace import.
138141
Document documentWithImport =
139142
await
140-
ImportAdder.AddImportsAsync(documentWithAttribute, NamespaceImportAnnotation, null,
143+
ImportAdder.AddImportsAsync(documentWithAttribute, NamespaceImportAnnotation, options,
141144
cancellationToken).ConfigureAwait(false);
142145

143146
// Simplify and reformat all annotated nodes.
144147
Document simplified =
145-
await Simplifier.ReduceAsync(documentWithImport, null, cancellationToken).ConfigureAwait(false);
146-
Document formatted = await Formatter.FormatAsync(simplified, null, cancellationToken).ConfigureAwait(false);
148+
await Simplifier.ReduceAsync(documentWithImport, options, cancellationToken).ConfigureAwait(false);
149+
Document formatted =
150+
await Formatter.FormatAsync(simplified, options, cancellationToken).ConfigureAwait(false);
147151
return formatted;
148152
}
149153

0 commit comments

Comments
 (0)