提交 045badc5 编写于 作者: C Cyrus Najmabadi

Pass options

上级 2a5e5ced
......@@ -12,6 +12,7 @@
using Microsoft.CodeAnalysis.Formatting;
using Microsoft.CodeAnalysis.Formatting.Rules;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Options;
using Microsoft.CodeAnalysis.Shared.Extensions;
using Microsoft.CodeAnalysis.Simplification;
using Microsoft.CodeAnalysis.Text;
......@@ -31,12 +32,14 @@ public async Task<Document> AddSourceToAsync(Document document, Compilation symb
var newSemanticModel = await document.GetSemanticModelAsync(cancellationToken).ConfigureAwait(false);
var rootNamespace = newSemanticModel.GetEnclosingNamespace(0, cancellationToken);
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
// Add the interface of the symbol to the top of the root namespace
document = await CodeGenerator.AddNamespaceOrTypeDeclarationAsync(
document.Project.Solution,
rootNamespace,
CreateCodeGenerationSymbol(document, symbol),
CreateCodeGenerationOptions(newSemanticModel.SyntaxTree.GetLocation(new TextSpan())),
CreateCodeGenerationOptions(newSemanticModel.SyntaxTree.GetLocation(new TextSpan()), options),
cancellationToken).ConfigureAwait(false);
document = await AddNullableRegionsAsync(document, cancellationToken).ConfigureAwait(false);
......@@ -97,14 +100,15 @@ private static INamespaceOrTypeSymbol CreateCodeGenerationSymbol(Document docume
new[] { wrappedType });
}
private static CodeGenerationOptions CreateCodeGenerationOptions(Location contextLocation)
private static CodeGenerationOptions CreateCodeGenerationOptions(Location contextLocation, OptionSet options)
{
return new CodeGenerationOptions(
contextLocation: contextLocation,
generateMethodBodies: false,
generateDocumentationComments: true,
mergeAttributes: false,
autoInsertionLocation: false);
autoInsertionLocation: false,
options: options);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册