提交 204c331c 编写于 作者: A Allison Chou

Cleanup

上级 9b911d21
......@@ -140,26 +140,21 @@ public override async Task RegisterCodeFixesAsync(CodeFixContext context)
{
// Not supported if this is "new { ... }" (as there are no parameters at all.
var typeNode = syntaxFacts.IsImplicitObjectCreationExpression(node) ?
node : syntaxFacts.GetObjectCreationType(objectCreation);
var typeNode = syntaxFacts.IsImplicitObjectCreationExpression(node)
? node
: syntaxFacts.GetObjectCreationType(objectCreation);
if (typeNode == null)
{
return new RegisterFixData<TArgumentSyntax>();
}
INamedTypeSymbol type = null;
var symbol = semanticModel.GetSymbolInfo(typeNode, cancellationToken).GetAnySymbol();
// Implicit object creation expressions
if (symbol is IMethodSymbol methodSymbol)
{
type = methodSymbol.ContainingType;
}
// Regular object creation expressions
else if (symbol is INamedTypeSymbol namedTypeSymbol)
var type = symbol switch
{
type = namedTypeSymbol;
}
IMethodSymbol methodSymbol => methodSymbol.ContainingType, // Implicit object creation expressions
INamedTypeSymbol namedTypeSymbol => namedTypeSymbol, // Standard object creation expressions
_ => null,
};
// If we can't figure out the type being created, or the type isn't in source,
// then there's nothing we can do.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册