diff --git a/src/Compilers/VisualBasic/Portable/Syntax/SyntaxEquivalence.vb b/src/Compilers/VisualBasic/Portable/Syntax/SyntaxEquivalence.vb index 9f55a27e336d8..dfb7c13a73052 100644 --- a/src/Compilers/VisualBasic/Portable/Syntax/SyntaxEquivalence.vb +++ b/src/Compilers/VisualBasic/Portable/Syntax/SyntaxEquivalence.vb @@ -52,7 +52,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax SyntaxKind.FloatingLiteralToken, SyntaxKind.IntegerLiteralToken, SyntaxKind.InterpolatedStringTextToken, - SyntaxKind.StringLiteralToken + SyntaxKind.StringLiteralToken, + SyntaxKind.XmlTextLiteralToken, + SyntaxKind.XmlNameToken Return String.Equals(DirectCast(before, Green.SyntaxToken).Text, DirectCast(after, Green.SyntaxToken).Text, StringComparison.Ordinal) diff --git a/src/Compilers/VisualBasic/Test/Syntax/Syntax/SyntaxEquivalenceTests.vb b/src/Compilers/VisualBasic/Test/Syntax/Syntax/SyntaxEquivalenceTests.vb index af6167567223e..c21610dc21125 100644 --- a/src/Compilers/VisualBasic/Test/Syntax/Syntax/SyntaxEquivalenceTests.vb +++ b/src/Compilers/VisualBasic/Test/Syntax/Syntax/SyntaxEquivalenceTests.vb @@ -2,6 +2,8 @@ ' The .NET Foundation licenses this file to you under the MIT license. ' See the LICENSE file in the project root for more information. +Imports Roslyn.Test.Utilities + Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests Public Class SyntaxEquivalenceTests @@ -274,6 +276,46 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests VerifyNotEquivalent(tree1, tree2, topLevel:=False) End Sub + + Public Sub TestXmlLiteral_Text() + Dim tree1 = VisualBasicSyntaxTree.ParseText(NewLines("namespace N \n class C \n sub Goo() \n Dim x = Text1 \n end sub \n end class \n end namespace")) + Dim tree2 = tree1.WithReplaceFirst("Text1", "Text2") + VerifyEquivalent(tree1, tree2, topLevel:=True) + VerifyNotEquivalent(tree1, tree2, topLevel:=False) + End Sub + + + Public Sub TestXmlLiteral_AttributeValue() + Dim tree1 = VisualBasicSyntaxTree.ParseText(NewLines("namespace N \n class C \n sub Goo() \n Dim x = Text \n end sub \n end class \n end namespace")) + Dim tree2 = tree1.WithReplaceFirst("attr1", "attr2") + VerifyEquivalent(tree1, tree2, topLevel:=True) + VerifyNotEquivalent(tree1, tree2, topLevel:=False) + End Sub + + + Public Sub TestXmlLiteral_AttributeName() + Dim tree1 = VisualBasicSyntaxTree.ParseText(NewLines("namespace N \n class C \n sub Goo() \n Dim x = Text \n end sub \n end class \n end namespace")) + Dim tree2 = tree1.WithReplaceFirst("attr1", "attr2") + VerifyEquivalent(tree1, tree2, topLevel:=True) + VerifyNotEquivalent(tree1, tree2, topLevel:=False) + End Sub + + + Public Sub TestXmlLiteral_CDATA() + Dim tree1 = VisualBasicSyntaxTree.ParseText(NewLines("namespace N \n class C \n sub Goo() \n Dim a = \n end sub \n end class \n end namespace")) + Dim tree2 = tree1.WithReplaceFirst("Text1", "Text2") + VerifyEquivalent(tree1, tree2, topLevel:=True) + VerifyNotEquivalent(tree1, tree2, topLevel:=False) + End Sub + + + Public Sub TestXmlLiteral_Comment() + Dim tree1 = VisualBasicSyntaxTree.ParseText(NewLines("namespace N \n class C \n sub Goo() \n Dim a = \n end sub \n end class \n end namespace")) + Dim tree2 = tree1.WithReplaceFirst("Text1", "Text2") + VerifyEquivalent(tree1, tree2, topLevel:=True) + VerifyNotEquivalent(tree1, tree2, topLevel:=False) + End Sub + #Region "Field" diff --git a/src/Features/VisualBasicTest/EditAndContinue/StatementEditingTests.vb b/src/Features/VisualBasicTest/EditAndContinue/StatementEditingTests.vb index a6550aca7c311..52579ee25b1e1 100644 --- a/src/Features/VisualBasicTest/EditAndContinue/StatementEditingTests.vb +++ b/src/Features/VisualBasicTest/EditAndContinue/StatementEditingTests.vb @@ -139,6 +139,90 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.EditAndContinue.UnitTests "Update [Resume Next]@80 -> [Resume]@65") End Sub + + Public Sub XmlLiteral_Text() + Dim src1 = " +Dim a = Text1 +" + Dim src2 = " +Dim a = Text2 +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = Text1]@14 -> [a = Text2]@14") + End Sub + + + Public Sub XmlLiteral_Node() + Dim src1 = " +Dim a = Text +" + Dim src2 = " +Dim a = Text +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = Text]@14 -> [a = Text]@14") + End Sub + + + Public Sub XmlLiteral_AttributeValue() + Dim src1 = " +Dim a = Text +" + Dim src2 = " +Dim a = Text +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = Text]@14 -> [a = Text]@14") + End Sub + + + Public Sub XmlLiteral_AttributeName() + Dim src1 = " +Dim a = Text +" + Dim src2 = " +Dim a = Text +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = Text]@14 -> [a = Text]@14") + End Sub + + + Public Sub XmlLiteral_CDATA() + Dim src1 = " +Dim a = +" + Dim src2 = " +Dim a = +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = ]@14 -> [a = ]@14") + End Sub + + + Public Sub XmlLiteral_Comment() + Dim src1 = " +Dim a = +" + Dim src2 = " +Dim a = +" + Dim edits = GetMethodEdits(src1, src2) + + edits.VerifyEdits( + "Update [a = ]@14 -> [a = ]@14") + End Sub + #End Region #Region "Select" diff --git a/src/Features/VisualBasicTest/EditAndContinue/TopLevelEditingTests.vb b/src/Features/VisualBasicTest/EditAndContinue/TopLevelEditingTests.vb index ca321cab826b5..c44cf409c5dd2 100644 --- a/src/Features/VisualBasicTest/EditAndContinue/TopLevelEditingTests.vb +++ b/src/Features/VisualBasicTest/EditAndContinue/TopLevelEditingTests.vb @@ -120,18 +120,9 @@ Imports System.Collections.Generic Dim edits = GetTopEdits(src1, src2) - ' TODO: https://github.com/dotnet/roslyn/issues/51374 - ' Should be following: - 'edits.VerifyEdits( - ' "Update [Imports X1 = System.Collections]@30 -> [Imports X2 = System.Collections]@30", - ' "Update [Imports ]@28 -> [Imports ]@28") - ' - 'edits.VerifySemanticDiagnostics( - ' Diagnostic(RudeEditKind.Update, "Imports X2 = System.Collections", VBFeaturesResources.import), - ' Diagnostic(RudeEditKind.Update, "Imports ", VBFeaturesResources.import)) - - edits.VerifyEdits( - "Update [Imports X1 = System.Collections]@30 -> [Imports X2 = System.Collections]@30") + edits.VerifyEdits( + "Update [Imports X1 = System.Collections]@30 -> [Imports X2 = System.Collections]@30", + "Update [Imports ]@63 -> [Imports ]@63") edits.VerifySemanticDiagnostics() End Sub