提交 422c315e 编写于 作者: N Neal Gafter

Merge pull request #7383 from gafter/fix7380

make SyntaxFactory.AreEquivalent ignore => bodies if topLevel:true
......@@ -110,11 +110,13 @@ private static bool AreEquivalentRecursive(GreenNode before, GreenNode after, Fu
if (topLevel)
{
// Once we get down to the block level we don't need to go any further and we can
// Once we get down to the body level we don't need to go any further and we can
// consider these trees equivalent.
if ((SyntaxKind)before.RawKind == SyntaxKind.Block)
switch ((SyntaxKind)before.RawKind)
{
return true;
case SyntaxKind.Block:
case SyntaxKind.ArrowExpressionClause:
return true;
}
// If we're only checking top level equivalence, then we don't have to go down into
......
......@@ -437,5 +437,15 @@ public void TestUpdateInterpolatedString()
VerifyEquivalent(tree1, tree2, topLevel: true);
VerifyNotEquivalent(tree1, tree2, topLevel: false);
}
[Fact(DisplayName = "https://github.com/dotnet/roslyn/issues/7380")]
public void TestExpressionBodiedMethod()
{
var tree1 = SyntaxFactory.ParseSyntaxTree("class C { void M() => 1; }");
var tree2 = SyntaxFactory.ParseSyntaxTree("class C { void M() => 2; }");
VerifyEquivalent(tree1, tree2, topLevel: true);
VerifyNotEquivalent(tree1, tree2, topLevel: false);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册