diff --git a/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs b/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs index a751e3608b96b234c1363b656a09a65540277b5a..e3b7a8ef7cdb8e9cbed3852c8056102a9d4efae5 100644 --- a/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs +++ b/src/EditorFeatures/CSharpTest/EditAndContinue/StatementEditingTests.cs @@ -2,7 +2,6 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. -using System.Collections.Generic; using System.IO; using Microsoft.CodeAnalysis.EditAndContinue; using Microsoft.CodeAnalysis.EditAndContinue.UnitTests; @@ -9767,42 +9766,41 @@ public void TupleType_LocalVariables() } [Fact] - [WorkItem(44423, "https://github.com/dotnet/roslyn/issues/44423")] public void TupleElementName() { - var src1 = @"(int a, int b) F();"; - var src2 = @"(int x, int b) F();"; + var src1 = @"class C { (int a, int b) F(); }"; + var src2 = @"class C { (int x, int b) F(); }"; var edits = GetTopEdits(src1, src2); edits.VerifyEdits( - "Update [(int a, int b) F();]@0 -> [(int x, int b) F();]@0"); + "Update [(int a, int b) F();]@10 -> [(int x, int b) F();]@10"); } [Fact] public void TupleInField() { - var src1 = @"private (int, int) _x = (1, 2);"; - var src2 = @"private (int, string) _y = (1, 2);"; + var src1 = @"class C { private (int, int) _x = (1, 2); }"; + var src2 = @"class C { private (int, string) _y = (1, 2); }"; var edits = GetTopEdits(src1, src2); edits.VerifyEdits( - "Update [(int, int) _x = (1, 2)]@8 -> [(int, string) _y = (1, 2)]@8", - "Update [_x = (1, 2)]@19 -> [_y = (1, 2)]@22"); + "Update [(int, int) _x = (1, 2)]@18 -> [(int, string) _y = (1, 2)]@18", + "Update [_x = (1, 2)]@29 -> [_y = (1, 2)]@32"); } [Fact] public void TupleInProperty() { - var src1 = @"public (int, int) Property1 { get { return (1, 2); } }"; - var src2 = @"public (int, string) Property2 { get { return (1, string.Empty); } }"; + var src1 = @"class C { public (int, int) Property1 { get { return (1, 2); } } }"; + var src2 = @"class C { public (int, string) Property2 { get { return (1, string.Empty); } } }"; var edits = GetTopEdits(src1, src2); edits.VerifyEdits( - "Update [public (int, int) Property1 { get { return (1, 2); } }]@0 -> [public (int, string) Property2 { get { return (1, string.Empty); } }]@0", - "Update [get { return (1, 2); }]@30 -> [get { return (1, string.Empty); }]@33"); + "Update [public (int, int) Property1 { get { return (1, 2); } }]@10 -> [public (int, string) Property2 { get { return (1, string.Empty); } }]@10", + "Update [get { return (1, 2); }]@40 -> [get { return (1, string.Empty); }]@43"); } [Fact] diff --git a/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs b/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs index bb8ec2d5684250fafcffcc9564c48187482f83e6..65005e0471fe5f2ffb86af78a95b57c8dc310ab2 100644 --- a/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs +++ b/src/Features/CSharp/Portable/EditAndContinue/TopSyntaxComparer.cs @@ -106,7 +106,6 @@ internal enum Label IndexerDeclaration, // tied to parent EventDeclaration, // tied to parent EnumMemberDeclaration, // tied to parent - GlobalStatement, // tied to parent AccessorList, // tied to parent AccessorDeclaration, // tied to parent @@ -146,7 +145,6 @@ private static int TiedToAncestor(Label label) case Label.IndexerDeclaration: case Label.EventDeclaration: case Label.EnumMemberDeclaration: - case Label.GlobalStatement: case Label.AccessorDeclaration: case Label.AccessorList: case Label.TypeParameterList: @@ -174,8 +172,9 @@ internal static Label Classify(SyntaxKind kind, out bool isLeaf) return Label.CompilationUnit; case SyntaxKind.GlobalStatement: - isLeaf = false; - return Label.GlobalStatement; + // TODO: + isLeaf = true; + return Label.Ignored; case SyntaxKind.ExternAliasDirective: isLeaf = true; @@ -340,7 +339,6 @@ public override bool ValuesEqual(SyntaxNode left, SyntaxNode right) case SyntaxKind.SetAccessorDeclaration: case SyntaxKind.AddAccessorDeclaration: case SyntaxKind.RemoveAccessorDeclaration: - case SyntaxKind.GlobalStatement: // When comparing method bodies we need to NOT ignore VariableDeclaration and VariableDeclarator children, // but when comparing field definitions we should ignore VariableDeclarations children. @@ -377,7 +375,6 @@ private static SyntaxNode GetBody(SyntaxNode node) { case BaseMethodDeclarationSyntax baseMethodDeclarationSyntax: return baseMethodDeclarationSyntax.Body ?? (SyntaxNode)baseMethodDeclarationSyntax.ExpressionBody?.Expression; case AccessorDeclarationSyntax accessorDeclarationSyntax: return accessorDeclarationSyntax.Body ?? (SyntaxNode)accessorDeclarationSyntax.ExpressionBody?.Expression; - case GlobalStatementSyntax globalStatement: return globalStatement.Statement; default: throw ExceptionUtilities.UnexpectedValue(node); } }