提交 11ab6fcd 编写于 作者: C Cyrus Najmabadi

Use pattern matching

上级 233ff8d5
...@@ -90,8 +90,7 @@ protected override bool CanAddImport(SyntaxNode node, CancellationToken cancella ...@@ -90,8 +90,7 @@ protected override bool CanAddImport(SyntaxNode node, CancellationToken cancella
return false; return false;
} }
var method = parent.Expression as MemberAccessExpressionSyntax; if (parent.Expression is MemberAccessExpressionSyntax method)
if (method != null)
{ {
node = method.Name; node = method.Name;
} }
...@@ -173,8 +172,7 @@ protected override bool CanAddImportForType(string diagnosticId, SyntaxNode node ...@@ -173,8 +172,7 @@ protected override bool CanAddImportForType(string diagnosticId, SyntaxNode node
case CS1574: case CS1574:
case CS1584: case CS1584:
var cref = node as QualifiedCrefSyntax; if (node is QualifiedCrefSyntax cref)
if (cref != null)
{ {
node = cref.Container; node = cref.Container;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册