99using Microsoft . CodeAnalysis . CSharp . Syntax ;
1010using Microsoft . CodeAnalysis . Editing ;
1111using Microsoft . CodeAnalysis . Formatting ;
12+ using Microsoft . CodeAnalysis . Options ;
1213using Microsoft . CodeAnalysis . Simplification ;
1314
1415namespace 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