提交 8ce08ea8 编写于 作者: C Cyrus Najmabadi

Pass options

上级 1e47d1e3
......@@ -423,6 +423,7 @@ private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableAr
var root = await document.GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
var editor = new SyntaxEditor(root, workspace);
var generator = editor.Generator;
var options = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false);
if (fieldOrProperty.ContainingType == null)
{
......@@ -448,13 +449,13 @@ private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableAr
{
return CodeGenerator.AddPropertyDeclaration(
currentTypeDecl, property, workspace,
GetAddOptions<IPropertySymbol>(parameter, blockStatementOpt, typeDeclaration, cancellationToken));
GetAddOptions<IPropertySymbol>(parameter, blockStatementOpt, typeDeclaration, options, cancellationToken));
}
else if (fieldOrProperty is IFieldSymbol field)
{
return CodeGenerator.AddFieldDeclaration(
currentTypeDecl, field, workspace,
GetAddOptions<IFieldSymbol>(parameter, blockStatementOpt, typeDeclaration, cancellationToken));
GetAddOptions<IFieldSymbol>(parameter, blockStatementOpt, typeDeclaration, options, cancellationToken));
}
else
{
......@@ -484,7 +485,7 @@ private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableAr
private static CodeGenerationOptions? GetAddOptions<TSymbol>(
IParameterSymbol parameter, IBlockOperation? blockStatementOpt,
SyntaxNode typeDeclaration, CancellationToken cancellationToken)
SyntaxNode typeDeclaration, OptionSet options, CancellationToken cancellationToken)
where TSymbol : ISymbol
{
foreach (var (sibling, before) in GetSiblingParameters(parameter))
......@@ -502,19 +503,19 @@ private static string GenerateUniqueName(IParameterSymbol parameter, ImmutableAr
{
// Found an existing field/property that corresponds to a preceding parameter.
// Place ourselves directly after it.
return new CodeGenerationOptions(afterThisLocation: symbolSyntax.GetLocation());
return new CodeGenerationOptions(afterThisLocation: symbolSyntax.GetLocation(), options: options);
}
else
{
// Found an existing field/property that corresponds to a following parameter.
// Place ourselves directly before it.
return new CodeGenerationOptions(beforeThisLocation: symbolSyntax.GetLocation());
return new CodeGenerationOptions(beforeThisLocation: symbolSyntax.GetLocation(), options: options);
}
}
}
}
return null;
return new CodeGenerationOptions(options: options);
}
private static ImmutableArray<(IParameterSymbol parameter, bool before)> GetSiblingParameters(IParameterSymbol parameter)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册