提交 9bed5d71 编写于 作者: T Thijs Brobbel

Also fix #33242 for the scenario of finalizers.

上级 953c081f
......@@ -11106,6 +11106,32 @@ private static string GetBar(string bar)
{
return bar;
}
}";
await TestExtractMethodAsync(code, expected);
}
[WorkItem(33242, "https://github.com/dotnet/roslyn/issues/33242")]
[Fact, Trait(Traits.Feature, Traits.Features.ExtractMethod)]
public async Task ExtractMethodInExpressionBodiedFinalizers()
{
var code = @"
class Foo
{
bool finalized;
~Foo() => finalized = [|true|];
}";
var expected = @"
class Foo
{
bool finalized;
~Foo() => finalized = NewMethod();
private static bool NewMethod()
{
return true;
}
}";
await TestExtractMethodAsync(code, expected);
}
......
......@@ -295,6 +295,8 @@ public static ArrowExpressionClauseSyntax GetExpressionBody(this MemberDeclarati
return ((ConversionOperatorDeclarationSyntax)memberDeclaration).ExpressionBody;
case SyntaxKind.ConstructorDeclaration:
return ((ConstructorDeclarationSyntax)memberDeclaration).ExpressionBody;
case SyntaxKind.DestructorDeclaration:
return ((DestructorDeclarationSyntax)memberDeclaration).ExpressionBody;
default:
return null;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册