' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. Imports Microsoft.CodeAnalysis.Rename.ConflictEngine Namespace Microsoft.CodeAnalysis.Editor.UnitTests.Rename Partial Public Class RenameEngineTests <[UseExportProvider]> Public Class VisualBasicConflicts Private ReadOnly _outputHelper As Abstractions.ITestOutputHelper Public Sub New(outputHelper As Abstractions.ITestOutputHelper) _outputHelper = outputHelper End Sub Public Sub BreakingRenameWithRollBacksInsideLambdas_2() Using result = RenameEngineResult.Create(_outputHelper, Imports System Class C Class D Public x As Integer = 1 End Class Dim a As Action(Of Integer) = Sub([|$$x|] As Integer) Dim {|Conflict:y|} = New D() Console.{|Conflict:WriteLine|}({|Conflict:x|}) End Sub End Class , renameTo:="y") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub BreakingRenameWithRollBacksInsideLambdas() Using result = RenameEngineResult.Create(_outputHelper, Structure y Public x As Integer End Structure Class C Class D Public x As Integer = 1 Dim w As Action(Of y) = Sub([|$$x|] As y) Dim {|Conflict:y|} = New D() Console.WriteLine(y.x) Console.WriteLine({|Conflict:x|}.{|Conflict:x|}) End Sub End Class End Class , renameTo:="y") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub HandleInvocationExpressions() Using result = RenameEngineResult.Create(_outputHelper, Module Program Sub [|$$Main|](args As String()) Dim x As New Dictionary(Of Integer, Dictionary(Of Integer, Integer)) Console.WriteLine(x(1)(3)) End Sub End Module , renameTo:="x") End Using End Sub Public Sub BreakingRenameWithInvocationOnDelegateInstance() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Delegate Sub Goo(x As Integer) Public Sub GooMeth(x As Integer) End Sub Public Sub void() Dim {|Conflict:x|} As Goo = New Goo(AddressOf GooMeth) Dim [|$$z|] As Integer = 1 Dim y As Integer = {|Conflict:z|} x({|Conflict:z|}) End Sub End Class , renameTo:="x") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub BreakingRenameWithSameClassInOneNamespace() Using result = RenameEngineResult.Create(_outputHelper, Imports A = N.{|Conflict:X|} Namespace N Class {|Conflict:X|} End Class End Namespace Namespace N Class {|Conflict:$$Y|} End Class End Namespace , renameTo:="X") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub OverloadResolutionConflictResolve_1() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Runtime.CompilerServices Module C <Extension()> Public Sub Ex(x As String) End Sub Sub Outer(x As Action(Of String), y As Object) Console.WriteLine(1) End Sub Sub Outer(x As Action(Of Integer), y As Integer) Console.WriteLine(2) End Sub Sub Inner(x As Action(Of String), y As String) End Sub Sub Inner(x As Action(Of String), y As Integer) End Sub Sub Inner(x As Action(Of Integer), y As Integer) End Sub Sub Main() {|conflict1:Outer|}(Sub(y) {|conflict2:Inner|}(Sub(x) x.Ex(), y), 0) Outer(Sub(y As Integer) Inner(CType(Sub(x) Console.WriteLine(x) x.Ex() End Sub, Action(Of String)), y) End Sub, 0) End Sub End Module Module E ' Rename Ex To Goo <Extension()> Public Sub [|$$Ex|](x As Integer) End Sub End Module , renameTo:="z") result.AssertLabeledSpansAre("conflict2", "Outer(Sub(y As String) Inner(Sub(x) x.Ex(), y), 0)", type:=RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("conflict1", "Outer(Sub(y As String) Inner(Sub(x) x.Ex(), y), 0)", type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub OverloadResolutionConflictResolve_2() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Runtime.CompilerServices Module C <Extension()> Public Sub Ex(x As String) End Sub Sub Outer(x As Action(Of String), y As Object) Console.WriteLine(1) End Sub Sub Outer(x As Action(Of Integer), y As Integer) Console.WriteLine(2) End Sub Sub Inner(x As Action(Of String), y As String) End Sub Sub Inner(x As Action(Of String), y As Integer) End Sub Sub Inner(x As Action(Of Integer), y As Integer) End Sub Sub Main() {|conflict2:Outer|}(Sub(y) {|conflict1:Inner|}(Sub(x) Console.WriteLine(x) x.Ex() End Sub, y) End Sub, 0) End Sub End Module Module E ' Rename Ex To Goo <Extension()> Public Sub [|$$Ex|](x As Integer) End Sub End Module , renameTo:="z") Dim outputResult = Outer(Sub(y As String).Value + vbCrLf + Inner(Sub(x).Value + vbCrLf + Console.WriteLine(x).Value + vbCrLf + x.Ex().Value + vbCrLf + End Sub, y).Value + vbCrLf + End Sub, 0).Value result.AssertLabeledSpansAre("conflict2", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("conflict1", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub OverloadResolutionConflictResolve_3() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Runtime.CompilerServices Module C <Extension()> Public Sub Ex(x As String) End Sub Sub Outer(x As Action(Of String), y As Object) Console.WriteLine(1) End Sub Sub Outer(x As Action(Of Integer), y As Integer) Console.WriteLine(2) End Sub Sub Inner(x As Action(Of String), y As String) End Sub Sub Inner(x As Action(Of String), y As Integer) End Sub Sub Inner(x As Action(Of Integer), y As Integer) End Sub Sub Main() {|conflict1:Outer|}(Sub(y) {|conflict2:Inner|}(Sub(x) Console.WriteLine(x) Dim z = 5 z.{|conflict0:Ex|}() x.Ex() End Sub, y) End Sub, 0) End Sub End Module Module E ' Rename Ex To Goo <Extension()> Public Sub [|$$Ex|](x As Integer) End Sub End Module , renameTo:="goo") Dim outputResult = Outer(Sub(y As String).Value + vbCrLf + Inner(Sub(x).Value + vbCrLf + Console.WriteLine(x).Value + vbCrLf + Dim z = 5.Value + vbCrLf + z.goo().Value + vbCrLf + x.Ex().Value + vbCrLf + End Sub, y).Value + vbCrLf + End Sub, 0).Value result.AssertLabeledSpansAre("conflict0", outputResult, type:=RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("conflict2", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("conflict1", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub OverloadResolutionConflictResolve_4() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Runtime.CompilerServices Module C <Extension()> Public Sub Ex(x As String) End Sub Sub Outer(x As Action(Of String), y As Object) Console.WriteLine(1) End Sub Sub Outer(x As Action(Of Integer), y As Integer) Console.WriteLine(2) End Sub Sub Inner(x As Action(Of String), y As String) End Sub Sub Inner(x As Action(Of String), y As Integer) End Sub Sub Inner(x As Action(Of Integer), y As Integer) End Sub Sub Main() {|conflict1:Outer|}(Sub(y) {|conflict2:Inner|}(Sub(x) Console.WriteLine(x) Dim z = 5 z.{|conflict0:blah|}() x.Ex() End Sub, y) End Sub, 0) End Sub End Module Module E ' Rename blah To Ex <Extension()> Public Sub [|$$blah|](x As Integer) End Sub End Module , renameTo:="Ex") Dim outputResult = Outer(Sub(y).Value + vbCrLf + Inner(Sub(x As String).Value + vbCrLf + Console.WriteLine(x).Value + vbCrLf + Dim z = 5.Value + vbCrLf + z.Ex().Value + vbCrLf + x.Ex().Value + vbCrLf + End Sub, y).Value + vbCrLf + End Sub, 0).Value result.AssertLabeledSpansAre("conflict0", outputResult, type:=RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("conflict2", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("conflict1", outputResult, type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameStatementWithResolvingAndUnresolvingConflictInSameStatement_VB() Using result = RenameEngineResult.Create(_outputHelper, Module Program Dim z As Object Sub Main(args As String()) Dim sx = Function([|$$x|] As Integer) {|resolve:z|} = Nothing If (True) Then Dim z As Boolean = {|conflict1:goo|}({|conflict2:x|}) End If Return True End Function End Sub Public Function goo(bar As Integer) As Boolean Return True End Function Public Function goo(bar As Object) As Boolean Return bar End Function End Module , renameTo:="z") result.AssertLabeledSpansAre("conflict2", type:=RelatedLocationType.UnresolvedConflict) result.AssertLabeledSpansAre("conflict1", type:=RelatedLocationType.UnresolvedConflict) result.AssertLabeledSpansAre("resolve", "Program.z = Nothing", type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub #Region "Type Argument Expand/Reduce for Generic Method Calls - 639136" Public Sub IntroduceWhitespaceTriviaToInvocationIfCallKeywordIsIntroduced() Using result = RenameEngineResult.Create(_outputHelper, Module M Public Sub [|$$Goo|](Of T)(ByVal x As T) ' Rename Goo to Bar End Sub End Module Class C Public Sub Bar(ByVal x As String) End Sub Class M Public Shared Bar As Action(Of String) = Sub(ByVal x As String) End Sub End Class Public Sub Test() {|stmt1:Goo|}("1") End Sub End Class , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "Call Global.M.Bar(""1"")", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ExpandInvocationInStaticMemberAccess() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Collections.Generic Imports System.Linq Class CC Public Shared Sub [|$$Goo|](Of T)(x As T) End Sub Public Shared Sub Bar(x As Integer) End Sub Public Sub Baz() End Sub End Class Class D Public Sub Baz() CC.{|stmt1:Goo|}(1) End Sub End Class , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "CC.Bar(Of Integer)(1)", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_Me() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Collections.Generic Imports System.Linq Class C Public Sub TestMethod() Dim x = 1 Dim y = {|stmt1:F|}(x) End Sub Public Function F(Of T)(x As T) As Integer Return 1 End Function Public Function [|$$B|](x As Integer) As Integer Return 1 End Function End Class , renameTo:="F") result.AssertLabeledSpansAre("stmt1", "Dim y = F(Of Integer)(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Collections.Generic Imports System.Linq Class C Shared Sub F(Of T)(x As Func(Of Integer, T)) End Sub Shared Sub [|$$B|](x As Func(Of Integer, Integer)) End Sub Shared Sub main() {|stmt1:F|}(Function(a) a) End Sub End Class , renameTo:="F") result.AssertLabeledSpansAre("stmt1", "F(Of Integer)(Function(a) a)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_Nested() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub [|$$Goo|](Of T)(ByVal x As T) End Sub Public Shared Sub Bar(ByVal x As Integer) End Sub Class D Sub Bar(Of T)(ByVal x As T) End Sub Sub Bar(ByVal x As Integer) End Sub Sub Test() {|stmt1:Goo|}(1) End Sub End Class End Class , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "C.Bar(Of Integer)(1)", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_ReferenceType() Using result = RenameEngineResult.Create(_outputHelper, Module M Public Sub Goo(Of T)(ByVal x As T) End Sub Public Sub [|$$Bar|](ByVal x As String) End Sub Public Sub Test() Dim x = "1" {|stmt1:Goo|}(x) End Sub End Module , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of String)(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_Cref() Using result = RenameEngineResult.Create(_outputHelper, ''' ''' ''' Public Sub [|$$Bar|](ByVal x As Integer) End Sub End Class ]]> , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of T)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_DifferentScope1() Using result = RenameEngineResult.Create(_outputHelper, Module M Public Sub [|$$Goo|](Of T)(ByVal x As T) ' Rename Goo to Bar End Sub Public Sub Bar(ByVal x As Integer) End Sub End Module Class C Public Sub Bar(ByVal x As Integer) End Sub Class M Public Shared Bar As Action(Of Integer) = Sub(ByVal x As Integer) End Sub End Class Public Sub Test() {|stmt1:Goo|}(1) End Sub End Class , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "Call Global.M.Bar(Of Integer)(1)", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_ConstructedTypeArgumentGenericContainer() Using result = RenameEngineResult.Create(_outputHelper, Class C(Of S) Public Shared Sub Goo(Of T)(ByVal x As T) End Sub Public Shared Sub [|$$Bar|](ByVal x As C(Of Integer)) End Sub Public Sub Test() Dim x As C(Of Integer) = New C(Of Integer)() {|stmt1:Goo|}(x) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of C(Of Integer))(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_ConstructedTypeArgumentNonGenericContainer() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub Goo(Of T)(ByVal x As T) End Sub Public Shared Sub [|$$Bar|](ByVal x As D(Of Integer)) End Sub Public Sub Test() Dim x As D(Of Integer) = New D(Of Integer)() {|stmt1:Goo|}(x) End Sub End Class Class D(Of S) End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of D(Of Integer))(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_ObjectType() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub Goo(Of T)(ByVal x As T) End Sub Public Shared Sub [|$$Bar|](ByVal x As Object) End Sub Public Sub Test() Dim x = DirectCast(1, Object) {|stmt1:Goo|}(x) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of Object)(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_SameTypeParameter() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub Goo(Of T)(ByVal x As T) End Sub Public Shared Sub [|$$Bar|](Of T)(ByVal x As T()) End Sub Public Sub Test() Dim x As Integer() = New Integer() {1, 2, 3} {|stmt1:Goo|}(x) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of Integer())(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_MultiDArrayTypeParameter() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub Goo(Of T)(ByVal x As T) End Sub Public Shared Sub [|$$Bar|](Of T)(ByVal x As T(,)) End Sub Public Sub Test() Dim x As Integer(,) = New Integer(,) {{1, 2}, {2, 3}, {3, 4}} {|stmt1:Goo|}(x) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of Integer(,))(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_UsedAsArgument() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Function Goo(Of T)(ByVal x As T) As Integer Return 1 End Function Public Function [|$$Bar|](ByVal x As Integer) As Integer Return 1 End Function Public Sub Method(ByVal x As Integer) End Sub Public Sub Test() Method({|stmt1:Goo|}(1)) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Method(Goo(Of Integer)(1))", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_UsedInConstructorInitialization() Using result = RenameEngineResult.Create(_outputHelper, Class C Sub New(ByVal x As Integer) End Sub Public Function Goo(Of T)(ByVal x As T) As Integer Return 1 End Function Public Function [|$$Bar|](ByVal x As Integer) As Integer Return 1 End Function Public Sub Method() Dim x As New C({|stmt1:Goo|}(1)) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Dim x As New C(Goo(Of Integer)(1))", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_CalledOnObject() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Function Goo(Of T)(ByVal x As T) As Integer Return 1 End Function Public Function [|$$Bar|](ByVal x As Integer) As Integer Return 1 End Function Public Sub Method() Dim x As New C() x.{|stmt1:Goo|}(1) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "x.Goo(Of Integer)(1)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_UsedInGenericDelegate() Using result = RenameEngineResult.Create(_outputHelper, Class C Delegate Function GooDel(Of T)(ByVal x As T) As Integer Public Function Goo(Of T)(ByVal x As T) As Integer Return 1 End Function Public Function [|$$Bar|](ByVal x As String) As Integer Return 1 End Function Public Sub Method() Dim x = New GooDel(Of String)(AddressOf {|stmt1:Goo|}) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Dim x = New GooDel(Of String)(AddressOf Goo(Of String))", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_UsedInNonGenericDelegate() Using result = RenameEngineResult.Create(_outputHelper, Class C Delegate Function GooDel(ByVal x As String) As Integer Public Function Goo(Of T)(ByVal x As T) As Integer Return 1 End Function Public Function [|$$Bar|](ByVal x As String) As Integer Return 1 End Function Public Sub Method() Dim x = New GooDel(AddressOf {|stmt1:Goo|}) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Dim x = New GooDel(AddressOf Goo(Of String))", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_MultipleTypeParameters() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Shared Sub Goo(Of T, S)(ByVal x As T, ByVal y As S) End Sub Public Shared Sub [|$$Bar|](Of T, S)(ByVal x As T(), ByVal y As S) End Sub Public Sub Test() Dim x = New Integer() {1, 2} {|stmt1:Goo|}(x, New C()) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "Goo(Of Integer(), C)(x, New C())", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ConflictResolutionWithTypeInference_ConflictInDerived() Using result = RenameEngineResult.Create(_outputHelper, Class C Public Sub Goo(Of T)(ByRef x As T) End Sub Public Sub Goo(ByRef x As String) End Sub End Class Class D Inherits C Public Sub [|$$Bar|](ByRef x As Integer) End Sub Public Sub Test() Dim x As String {|stmt1:Goo|}(x) End Sub End Class , renameTo:="Goo") result.AssertLabeledSpansAre("stmt1", "MyBase.Goo(x)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub #End Region Public Sub ParameterConflictingWithInstanceField() Using result = RenameEngineResult.Create(_outputHelper, Class GooClass Private goo As Integer Sub Blah([|$$bar|] As Integer) {|stmt2:goo|} = {|stmt1:bar|} End Sub End Class , renameTo:="goo") result.AssertLabeledSpansAre("stmt1", "Me.goo = goo", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt2", "Me.goo = goo", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ParameterConflictingWithInstanceFieldRenamingToKeyword() Using result = RenameEngineResult.Create(_outputHelper, Class GooClass Private [if] As Integer Sub Blah({|Escape:$$bar|} As Integer) {|stmt2:[if]|} = {|stmt1:bar|} End Sub End Class , renameTo:="if") result.AssertLabeledSpecialSpansAre("Escape", "[if]", RelatedLocationType.NoConflict) ' we don't unescape [if] in Me.[if] because the user gave it to us escaped. result.AssertLabeledSpecialSpansAre("stmt1", "Me.[if] = [if]", RelatedLocationType.NoConflict) result.AssertLabeledSpecialSpansAre("stmt2", "Me.[if] = [if]", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ParameterConflictingWithInstanceFieldRenamingToKeyword2() Using result = RenameEngineResult.Create(_outputHelper, Class GooClass Private {|escape:$$bar|} As Integer Sub Blah([if] As Integer) {|stmt1:bar|} = [if] End Sub End Class , renameTo:="if") result.AssertLabeledSpecialSpansAre("escape", "[if]", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt1", "Me.if = [if]", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ParameterConflictingWithSharedField() Using result = RenameEngineResult.Create(_outputHelper, Class GooClass Shared goo As Integer Sub Blah([|$$bar|] As Integer) {|stmt2:goo|} = {|stmt1:bar|} End Sub End Class , renameTo:="goo") result.AssertLabeledSpansAre("stmt1", "GooClass.goo = goo", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt2", "GooClass.goo = goo", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ParameterConflictingWithFieldInModule() Using result = RenameEngineResult.Create(_outputHelper, Module GooModule Private goo As Integer Sub Blah([|$$bar|] As Integer) {|stmt2:goo|} = {|stmt1:bar|} End Sub End Module , renameTo:="goo") result.AssertLabeledSpansAre("stmt1", "GooModule.goo = goo", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt2", "GooModule.goo = goo", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub MinimalQualificationOfBaseType1() Using result = RenameEngineResult.Create(_outputHelper, Class X Protected Class [|$$A|] End Class End Class Class Y Inherits X Protected Class C Inherits {|Resolve:A|} End Class Class B End Class End Class , renameTo:="B") result.AssertLabeledSpansAre("Resolve", "X.B", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub MinimalQualificationOfBaseType2() Using result = RenameEngineResult.Create(_outputHelper, Class X Protected Class A End Class End Class Class Y Inherits X Protected Class C Inherits {|Resolve:A|} End Class Class [|$$B|] End Class End Class , renameTo:="A") result.AssertLabeledSpansAre("Resolve", "X.A", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub PreserveTypeCharactersForKeywordsAsIdentifiers() Using result = RenameEngineResult.Create(_outputHelper, Option Strict On Class C Sub New Dim x$ = Me.{|stmt1:$$Goo|}.ToLower End Sub Function {|TypeSuffix:Goo$|} Return "ABC" End Function End Class , renameTo:="Class") result.AssertLabeledSpansAre("stmt1", "Class", RelatedLocationType.NoConflict) result.AssertLabeledSpecialSpansAre("TypeSuffix", "Class$", RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameDoesNotBreakQuery() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Collections.Generic Imports System.Linq Module Program Sub Main(args As String()) Dim col1 As New Col Dim query = From i In col1 Select i End Sub End Module Public Class Col Function {|escaped:$$[Select]|}(ByVal sel As Func(Of Integer, Integer)) As IEnumerable(Of Integer) Return Nothing End Function End Class , renameTo:="GooSelect") result.AssertLabeledSpansAre("escaped", "[GooSelect]", RelatedLocationType.NoConflict) End Using End Sub Public Sub ProperlyEscapeNewKeywordWithTypeCharacters() Using result = RenameEngineResult.Create(_outputHelper, Option Strict On Class C Sub New Dim x$ = Me.{|stmt1:$$Goo$|}.ToLower End Sub Function {|Unescaped:Goo$|} Return "ABC" End Function End Class , renameTo:="New") result.AssertLabeledSpansAre("Unescaped", "New$", type:=RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt1", "Dim x$ = Me.[New].ToLower", type:=RelatedLocationType.NoConflict) End Using End Sub Public Sub AvoidDoubleEscapeAttempt() Using result = RenameEngineResult.Create(_outputHelper, Module [|$$Program|] Sub Main() End Sub End Module , renameTo:="[true]") End Using End Sub Public Sub ReplaceAliasWithNestedGenericType() Using result = RenameEngineResult.Create(_outputHelper, Imports C = A(Of Integer).B Class A(Of T) Class B End Class End Class Module M Sub Main Dim x As {|stmt1:C|} End Sub Class [|D$$|] End Class End Module , renameTo:="C") result.AssertLabeledSpansAre("stmt1", "Dim x As A(Of Integer).B", type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenamingFunctionWithFunctionVariableFromFunction() Using result = RenameEngineResult.Create(_outputHelper, Module Program Function [|$$X|]() As Integer {|stmt1:X|} = 1 End Function End Module , renameTo:="BarBaz") result.AssertLabeledSpansAre("stmt1", "BarBaz", RelatedLocationType.NoConflict) End Using End Sub Public Sub RenamingFunctionWithFunctionVariableFromFunctionVariable() Using result = RenameEngineResult.Create(_outputHelper, Module Program Function [|X|]() As Integer {|stmt1:$$X|} = 1 End Function End Module , renameTo:="BarBaz") result.AssertLabeledSpansAre("stmt1", "BarBaz", RelatedLocationType.NoConflict) End Using End Sub Public Sub ResolveConflictingTypeIncludedThroughModule1() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="A") result.AssertLabeledSpansAre("Replacement", "N.X.A", type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub ResolveConflictingTypeIncludedThroughModule2() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="B") result.AssertLabeledSpansAre("Replacement", "N.X.B") result.AssertLabeledSpansAre("Resolved", type:=RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ResolveConflictingTypeImportedFromMultipleTypes() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "X.Bar = 1", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub ConflictWithImplicitlyDeclaredLocal() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Bar") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameForRangeVariableUsedInLambda() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="j") result.AssertLabeledSpansAre("stmt1", "j", RelatedLocationType.NoConflict) End Using End Sub Public Sub ShouldNotCascadeToExplicitlyImplementedInterfaceMethodOfDifferentName() Using result = RenameEngineResult.Create(_outputHelper, Public Interface MyInterface Sub Bar() End Interface Public Structure MyStructure Implements MyInterface Private Sub [|$$I_Bar|]() Implements MyInterface.Bar End Sub End Structure , renameTo:="Baz") End Using End Sub Public Sub ShouldNotCascadeToImplementingMethodOfDifferentName() Using result = RenameEngineResult.Create(_outputHelper, Public Interface MyInterface Sub [|$$Bar|]() End Interface Public Structure MyStructure Implements MyInterface Private Sub I_Bar() Implements MyInterface.[|Bar|] End Sub End Structure , renameTo:="Baz") End Using End Sub Public Sub RenameAttributeSuffix() Using result = RenameEngineResult.Create(_outputHelper, Public class goo End class Public Class [|$$SomethingAttribute|] Inherits Attribute End Class]]> , renameTo:="SpecialAttribute") result.AssertLabeledSpansAre("Special", "Special", type:=RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameAttributeFromUsage() Using result = RenameEngineResult.Create(_outputHelper, Public class goo End class Public Class {|Special:$$SomethingAttribute|} Inherits Attribute End Class]]> , renameTo:="Special") result.AssertLabeledSpansAre("Special", "Special", type:=RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameFunctionCallAfterElse() ' This is a simple scenario but it has a somewhat strange tree in VB. The ' BeginTerminator of the ElseBlockSyntax is missing, and just so happens to land at ' the same location as the NewMethod invocation that follows the Else. Using result = RenameEngineResult.Create(_outputHelper, Module Program Sub Main(ByRef args As String()) If (True) Else {|stmt1:NewMethod|}() : End If End Sub Private Sub [|$$NewMethod|]() End Sub End Module , renameTo:="NewMethod1") result.AssertLabeledSpansAre("stmt1", "NewMethod1", RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameImplicitlyDeclaredLocal() Using result = RenameEngineResult.Create(_outputHelper, Option Explicit Off Module Program Sub Main(args As String()) {|stmt1:$$goo|} = 23 {|stmt2:goo|} = 42 End Sub End Module , renameTo:="barbaz") result.AssertLabeledSpansAre("stmt1", "barbaz", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt2", "barbaz", RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameFieldToConflictWithImplicitlyDeclaredLocal() Using result = RenameEngineResult.Create(_outputHelper, Option Explicit Off Module Program Dim [|$$bar|] As Object Sub Main(args As String()) {|stmt1_2:goo|} = {|stmt1:bar|} {|stmt2:goo|} = 42 End Sub End Module , renameTo:="goo") result.AssertLabeledSpansAre("stmt1", "goo", type:=RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("stmt1_2", type:=RelatedLocationType.UnresolvedConflict) result.AssertLabeledSpansAre("stmt2", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameParameterOfEvent() Using result = RenameEngineResult.Create(_outputHelper, Class Test Public Event Percent(ByVal [|$$p|] As Single) Public Shared Sub Main() End Sub End Class , renameTo:="barbaz") End Using End Sub Public Sub RenameLocalInMethodMissingParameterList() Using result = RenameEngineResult.Create(_outputHelper, Imports System Module Program Sub Main Dim {|stmt1:$$a|} As Integer End Sub End Module , renameTo:="barbaz") result.AssertLabeledSpansAre("stmt1", "barbaz", RelatedLocationType.NoConflict) End Using End Sub Public Sub QualifyTypeWithGlobalWhenConflicting() Using result = RenameEngineResult.Create(_outputHelper, Class A End Class Class B Dim x As {|Resolve:A|} Class [|$$C|] End Class End Class , renameTo:="A") result.AssertLabeledSpansAre("Resolve", "Global.A", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub QualifyFieldInReDimStatement() Using result = RenameEngineResult.Create(_outputHelper, Module Preserve Sub Main Dim Bar ReDim {|stmt1:Goo|}(0) End Sub Property [|$$Goo|] End Module , renameTo:="Bar") result.AssertLabeledSpansAre("stmt1", "ReDim [Preserve].Bar(0)", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub QualifyTypeNameInImports() Using result = RenameEngineResult.Create(_outputHelper, Imports {|Resolve:X|} Module M Class X End Class End Module Module N Class [|$$Y|] ' Rename Y to X End Class End Module , renameTo:="X") result.AssertLabeledSpansAre("Resolve", "M.X", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameNewOverload() Using result = RenameEngineResult.Create(_outputHelper, Imports System Module Program Sub Main() {|ResolvedNonReference:Goo|}(Sub(x) x.{|Resolve:Old|}()) End Sub Sub Goo(x As Action(Of I)) End Sub Sub Goo(x As Action(Of C)) End Sub End Module Interface I Sub {|Escape:$$Old|}() End Interface Class C Sub [New]() End Sub End Class , renameTo:="New") result.AssertLabeledSpecialSpansAre("Escape", "[New]", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("Resolve", "Goo(Sub(x) x.New())", RelatedLocationType.ResolvedReferenceConflict) result.AssertLabeledSpansAre("ResolvedNonReference", "Goo(Sub(x) x.New())", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameAttributeRequiringReducedNameToResolveConflict() Using result = RenameEngineResult.Create(_outputHelper, Class Class1 End Class Class Class2 End Class ]]> , renameTo:="ZAttribute") result.AssertLabeledSpecialSpansAre("resolve", "Z", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub RenameEvent() Using result = RenameEngineResult.Create(_outputHelper, Imports System Namespace N Public Interface I Event [|$$X|] As EventHandler ' Rename X to Y End Interface End Namespace VBAssembly using System; using N; class C : I { event EventHandler I.[|X|] { add { } remove { } } } , renameTo:="Y") End Using End Sub Public Sub RenameInterfaceImplementation() Using result = RenameEngineResult.Create(_outputHelper, Imports System Interface I Sub Goo(Optional x As Integer = 0) End Interface Class C Implements I Shared Sub Main() DirectCast(New C(), I).Goo() End Sub Private Sub [|$$I_Goo|](Optional x As Integer = 0) Implements I.Goo Console.WriteLine("test") End Sub End Class , renameTo:="Goo") End Using End Sub Public Sub RenameAttributeConflictWithNamespace() Using result = RenameEngineResult.Create(_outputHelper, Delegate Sub F() End Namespace End Namespace ]]> , renameTo:="B") result.AssertLabeledSpansAre("Resolve", "X.B", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub RenameREMToUnicodeREM() Dim text = ChrW(82) & ChrW(69) & ChrW(77) Dim compareText = "[" & text & "]" Using result = RenameEngineResult.Create(_outputHelper, Module {|Resolve:$$[REM]|} End Module , renameTo:=text) result.AssertLabeledSpecialSpansAre("Resolve", compareText, RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameImports() Using result = RenameEngineResult.Create(_outputHelper, Class A Inherits {|Resolve1:Attribute|} End Class End Namespace Module M Dim a As {|Resolve2:S|}.ArrayList End Module ]]> , renameTo:="Attribute") result.AssertLabeledSpansAre("Resolve1", "System.Attribute", RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("Resolve2", "Attribute", RelatedLocationType.NoConflict) End Using End Sub Public Sub Bug578105_VBRenamingPartialMethodDifferentCasing() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Baz") End Using End Sub Public Sub Bug588142_SimplifyAttributeUsageCanAlwaysEscapeInVB() Using result = RenameEngineResult.Create(_outputHelper, Class [|$$AAttribute|] ' Rename A to RemAttribute Inherits Attribute End Class ]]> , renameTo:="RemAttribute") result.AssertLabeledSpansAre("escaped", "[Rem]", RelatedLocationType.NoConflict) End Using End Sub Public Sub Bug588142_RenameAttributeToAttribute() Using result = RenameEngineResult.Create(_outputHelper, Class [|$$GooAttribute|] ' Rename Goo to Attribute Inherits {|resolved:Attribute|} End Class ]]> , renameTo:="Attribute") result.AssertLabeledSpansAre("unreduced", "Attribute", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("resolved", "System.Attribute", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug576573_ConflictAttributeWithNamespace() Using result = RenameEngineResult.Create(_outputHelper, Delegate Sub F() End Namespace End Namespace ]]> , renameTo:="BAttribute") result.AssertLabeledSpansAre("resolved", "X.B", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug603368_ConflictAttributeWithNamespaceCaseInsensitive() Using result = RenameEngineResult.Create(_outputHelper, Delegate Sub F() End Namespace End Namespace ]]> , renameTo:="BATTRIBUTE") result.AssertLabeledSpansAre("resolved", "X.B", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug603367_ConflictAttributeWithNamespaceCaseInsensitive2() Using result = RenameEngineResult.Create(_outputHelper, Module M Class GooAttribute Inherits Attribute End Class End Module Class [|$$X|] ' Rename X to GOOATTRIBUTE End Class ]]> , renameTo:="GOOATTRIBUTE") result.AssertLabeledSpansAre("resolved", "M.Goo", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug603276_ConflictAttributeWithNamespaceCaseInsensitive3() Using result = RenameEngineResult.Create(_outputHelper, Class [|$$Goo|] ' Rename Goo to ATTRIBUTE Inherits {|resolved:Attribute|} End Class ]]> , renameTo:="ATTRIBUTE") result.AssertLabeledSpansAre("resolved", "System.Attribute", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug529712_ConflictNamespaceWithModuleName_1() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Goo") result.AssertLabeledSpansAre("resolved", "N.X.Goo()", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug529837_ResolveConflictByOmittingModuleName() Using result = RenameEngineResult.Create(_outputHelper, Namespace X Public Module Y Public Class C End Class End Module End Namespace Project1 Namespace X Namespace Y Class [|$$D|] Inherits {|resolved:C|} End Class End Namespace End Namespace , renameTo:="C") result.AssertLabeledSpansAre("resolved", "X.C", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub Bug529989_RenameCSharpIdentifierToInvalidVBIdentifier() Using result = RenameEngineResult.Create(_outputHelper, public class {|invalid:$$ProgramCS|} { } Project1 Module ProgramVB Sub Main(args As String()) Dim d As {|invalid:ProgramCS|} End Sub End Module , renameTo:="B\u0061r") result.AssertReplacementTextInvalid() result.AssertLabeledSpansAre("invalid", "B\u0061r", RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameModuleBetweenAssembly() Using result = RenameEngineResult.Create(_outputHelper, Project2 Imports System Module Program Sub Main(args As String()) Dim {|Stmt1:$$Bar|} = Sub(x) Console.Write(x) Call {|Resolve:Goo|}() {|Stmt2:Bar|}(1) End Sub End Module Public Module M Sub Goo() End Sub End Module , renameTo:="Goo") result.AssertLabeledSpansAre("Stmt1", "Goo", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("Stmt2", "Goo", RelatedLocationType.NoConflict) result.AssertLabeledSpansAre("Resolve", "Call M.Goo()", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameModuleClassConflict() Using result = RenameEngineResult.Create(_outputHelper, Imports System Namespace N Module M Class C Shared Sub Goo() End Sub End Class End Module Class [|$$D|] Shared Sub Goo() End Sub End Class Module Program Sub Main() {|Resolve:C|}.{|Resolve:Goo|}() {|Stmt1:D|}.Goo() End Sub End Module End Namespace , renameTo:="C") result.AssertLabeledSpansAre("Resolve", "M.C.Goo()", RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("Stmt1", "C", RelatedLocationType.NoConflict) End Using End Sub Public Sub RenameModuleNamespaceNested() Using result = RenameEngineResult.Create(_outputHelper, Imports System Namespace N Namespace M Module K Sub Goo() End Sub End Module Module L Sub [|$$Bar|]() End Sub End Module End Namespace End Namespace Module Program Sub Main(args As String()) N.M.{|Resolve1:Goo|}() N.M.{|Resolve2:Bar|}() End Sub End Module , renameTo:="Goo") result.AssertLabeledSpansAre("Resolve1", "N.M.K.Goo()", RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("Resolve2", "N.M.L.Goo()", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub RenameModuleConflictWithInterface() Using result = RenameEngineResult.Create(_outputHelper, Imports System Interface M Sub goo(ByVal x As Integer) End Interface Namespace N Module [|$$K|] Sub goo(ByVal x As Integer) End Sub End Module Class C Implements {|Resolve:M|} Public Sub goo(x As Integer) Implements {|Resolve:M|}.goo Throw New NotImplementedException() End Sub End Class End Namespace , renameTo:="M") result.AssertLabeledSpansAre("Resolve", "Global.M", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameModuleConflictWithLocal() Using result = RenameEngineResult.Create(_outputHelper, Imports System Namespace N Class D Public x() As Integer = {0, 1} End Class Module M Public x() As Integer = {0, 1} End Module Module S Dim M As New D() Dim [|$$y|] As Integer Dim p = From x In M.x Select x Dim q = From x In {|Resolve:x|} Select x End Module End Namespace , renameTo:="x") result.AssertLabeledSpansAre("Resolve", "N.M.x", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub VB_DetectOverLoadResolutionChangesInEnclosingInvocations() Using result = RenameEngineResult.Create(_outputHelper, Imports System Imports System.Runtime.CompilerServices Module C <Extension()> Public Sub Ex(x As String) End Sub Sub Outer(x As Action(Of String), y As Object) Console.WriteLine(1) End Sub Sub Outer(x As Action(Of Integer), y As Integer) Console.WriteLine(2) End Sub Sub Inner(x As Action(Of String), y As String) End Sub Sub Inner(x As Action(Of String), y As Integer) End Sub Sub Inner(x As Action(Of Integer), y As Integer) End Sub Sub Main() {|resolved:Outer|}(Sub(y) {|resolved:Inner|}(Sub(x) x.Ex(), y), 0) End Sub End Module Module E ' Rename Ex To Goo <Extension()> Public Sub [|$$Ex|](x As Integer) End Sub End Module , renameTo:="Goo") result.AssertLabeledSpansAre("resolved", "Outer(Sub(y As String) Inner(Sub(x) x.Ex(), y), 0)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameNamespaceConflictsAndResolves() Using result = RenameEngineResult.Create(_outputHelper, Namespace NN Class C ''' <see cref="{|resolve1:NN|}.C"/> Public x As {|resolve2:NN|}.C End Class Namespace [|$$KK|] Class C End Class End Namespace End Namespace , renameTo:="NN") result.AssertLabeledSpansAre("resolve1", "Global.NN.C", RelatedLocationType.ResolvedNonReferenceConflict) result.AssertLabeledSpansAre("resolve2", "Global.NN", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameUnnecessaryExpansion() Using result = RenameEngineResult.Create(_outputHelper, Namespace N Class C Public x As {|resolve:N|}.C End Class Class [|$$D|] Class C Public y As [|D|] End Class End Class End Namespace , renameTo:="N") result.AssertLabeledSpansAre("resolve", "Global.N", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub AdjustTriviaForExtensionMethodRewrite() Using result = RenameEngineResult.Create(_outputHelper, Imports System.Runtime.CompilerServices Class C Sub Bar(tag As Integer) Me.{|resolve:Goo|}(1).{|resolve:Goo|}(2) End Sub End Class Module E <Extension> Public Function [|$$Goo|](x As C, tag As Integer) As C Return x End Function End Module , renameTo:="Bar") result.AssertLabeledSpansAre("resolve", "E.Bar(E.Bar(Me,1),2)", RelatedLocationType.ResolvedReferenceConflict) End Using End Sub Public Sub RenameCrefWithConflict() Using result = RenameEngineResult.Create(_outputHelper, Imports F = N Namespace N Interface I Sub Goo() End Interface End Namespace Class C Private Class E Implements {|Resolve:F|}.I ''' ''' This is a function ''' Public Sub Goo() Implements {|Resolve:F|}.I.Goo End Sub End Class Private Class [|$$K|] End Class End Class , renameTo:="F") result.AssertLabeledSpansAre("Resolve", "N", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameInCrefPreservesWhitespaceTrivia() Using result = RenameEngineResult.Create(_outputHelper, ''' ''' ''' Shared Sub [|$$goo|]() ' Rename goo to D End Sub End Class Public Class D End Class End Class ]]> , renameTo:="D") result.AssertLabeledSpansAre("Resolve", "A.D", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub VB_ConflictBetweenTypeNamesInTypeConstraintSyntax() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="ISymbol") result.AssertLabeledSpansAre("DeclConflict", type:=RelatedLocationType.UnresolvedConflict) result.AssertLabeledSpansAre("unresolved1", type:=RelatedLocationType.UnresolvedConflict) result.AssertLabeledSpansAre("unresolved2", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenamingCompilerGeneratedPropertyBackingField_InvokeFromProperty() Using result = RenameEngineResult.Create(_outputHelper, Class C1 Public ReadOnly Property [|X$$|] As String Sub M() {|backingfield:_X|} = "test" End Sub End Class , renameTo:="Y") result.AssertLabeledSpecialSpansAre("backingfield", "_Y", type:=RelatedLocationType.NoConflict) End Using End Sub Public Sub RenamingCompilerGeneratedPropertyBackingField_IntroduceConflict() Using result = RenameEngineResult.Create(_outputHelper, Class C1 Public ReadOnly Property [|X$$|] As String Sub M() {|Conflict:_X|} = "test" End Sub Dim _Y As String End Class , renameTo:="Y") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenamingCompilerGeneratedPropertyBackingField_InvokableFromBackingFieldReference() Using workspace = CreateWorkspaceWithWaiter( Class C1 Public ReadOnly Property [|X|] As String Sub M() {|backingfield:_X$$|} = "test" End Sub End Class ) AssertTokenRenamable(workspace) End Using End Sub Public Sub MemberQualificationInNameOfUsesTypeName_StaticReferencingInstance() Using result = RenameEngineResult.Create(_outputHelper, Class C Shared Sub F([|$$z|] As Integer) Dim x = NameOf({|ref:zoo|}) End Sub Dim zoo As Integer End Class , renameTo:="zoo") result.AssertLabeledSpansAre("ref", "Dim x = NameOf(C.zoo)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub MemberQualificationInNameOfUsesTypeName_InstanceReferencingStatic() Using result = RenameEngineResult.Create(_outputHelper, Class C Sub F([|$$z|] As Integer) Dim x = NameOf({|ref:zoo|}) End Sub Shared zoo As Integer End Class , renameTo:="zoo") result.AssertLabeledSpansAre("ref", "Dim x = NameOf(C.zoo)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub MemberQualificationInNameOfUsesTypeName_InstanceReferencingInstance() Using result = RenameEngineResult.Create(_outputHelper, Class C Sub F([|$$z|] As Integer) Dim x = NameOf({|ref:zoo|}) End Sub Dim zoo As Integer End Class , renameTo:="zoo") result.AssertLabeledSpansAre("ref", "Dim x = NameOf(C.zoo)", RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub TestConflictBetweenClassAndInterface1() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="C") result.AssertLabeledSpansAre("conflict", "C", RelatedLocationType.UnresolvableConflict) End Using End Sub Public Sub TestConflictBetweenClassAndInterface2() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="I") result.AssertLabeledSpansAre("conflict", "I", RelatedLocationType.UnresolvableConflict) End Using End Sub Public Sub TestConflictBetweenClassAndNamespace1() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="N") result.AssertLabeledSpansAre("conflict", "N", RelatedLocationType.UnresolvableConflict) End Using End Sub Public Sub TestConflictBetweenClassAndNamespace2() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="C") result.AssertLabeledSpansAre("conflict", "C", RelatedLocationType.UnresolvableConflict) End Using End Sub Public Sub TestNoConflictBetweenTwoNamespaces() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="N2") End Using End Sub Public Sub NameOfReferenceNoConflict() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Test") End Using End Sub Public Sub NameOfReferenceWithConflict() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="Test") result.AssertLabeledSpansAre("conflict", "Test", RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub InvalidNamesDoNotCauseCrash_IntroduceQualifiedName() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="C.D") result.AssertReplacementTextInvalid() result.AssertLabeledSpansAre("conflict", "C.D", RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub InvalidNamesDoNotCauseCrash_AccidentallyPasteLotsOfCode() Dim renameTo = " Class C Sub M() System.Console.WriteLine(""Hello, Test!"") End Sub End Class" Using result = RenameEngineResult.Create(_outputHelper, , renameTo) result.AssertReplacementTextInvalid() result.AssertLabeledSpansAre("conflict", renameTo, RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameTypeParameterInPartialClass() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="T2") End Using End Sub Public Sub RenameMethodToConflictWithTypeParameter() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="T") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameParameterizedPropertyResolvedConflict() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="P") result.AssertLabeledSpansAre("Conflict0", replacement:="Return P(CObj(""""))", type:=RelatedLocationType.ResolvedNonReferenceConflict) End Using End Sub Public Sub RenameParameterizedPropertyUnresolvedConflict() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="P") result.AssertLabeledSpansAre("Conflict", type:=RelatedLocationType.UnresolvedConflict) End Using End Sub Public Sub RenameTypeToCurrent() Using result = RenameEngineResult.Create(_outputHelper, Class {|current:$$C|} End Class , renameTo:="Current") result.AssertLabeledSpansAre("current", type:=RelatedLocationType.NoConflict) End Using End Sub Public Sub InvalidControlVariableInForLoopDoNotCrash() Using result = RenameEngineResult.Create(_outputHelper, , renameTo:="v") End Using End Sub End Class End Class End Namespace