提交 93b32624 编写于 作者: C CyrusNajmabadi

Add VB side.

上级 18858a39
......@@ -270,5 +270,31 @@ NewLines("partial class C \n function [||]GetFoo() as integer \n End function \n
NewLines("partial class C \n Property Foo as integer \n Get \n End Get \n Set(i as integer) \n End Set \n End Property \n End class \n partial class C \n End class"),
index:=1)
End Function
<WorkItem(14327, "https://github.com/dotnet/roslyn/issues/14327")>
<Fact, Trait(Traits.Feature, Traits.Features.CodeActionsReplaceMethodWithProperty)>
Public Async Function TestUpdateChainedGet1() As Task
Await TestAsync(
"
public class Foo
public sub Foo()
dim v = GetValue().GetValue()
end sub
Public Function [||]GetValue() As Foo
End Function
end class",
"
public class Foo
public sub Foo()
dim v = Value.Value
end sub
Public ReadOnly Property Value As Foo
Get
End Get
End Property
end class")
End Function
End Class
End Namespace
\ No newline at end of file
......@@ -169,7 +169,16 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
Dim parentExpression = If(nameNode.IsRightSideOfDot(), DirectCast(nameNode.Parent, ExpressionSyntax), nameNode)
Dim root = If(parentExpression.IsParentKind(SyntaxKind.InvocationExpression), parentExpression.Parent, parentExpression)
editor.ReplaceNode(root, parentExpression.ReplaceNode(nameNode, newName))
editor.ReplaceNode(
root,
Function(c As SyntaxNode, g As SyntaxGenerator)
Dim currentRoot = DirectCast(c, ExpressionSyntax)
Dim expression = If(currentRoot.IsKind(SyntaxKind.InvocationExpression),
DirectCast(currentRoot, InvocationExpressionSyntax).Expression,
currentRoot)
Dim rightName = expression.GetRightmostName()
Return expression.ReplaceNode(rightName, newName.WithTrailingTrivia(currentRoot.GetTrailingTrivia()))
End Function)
End Sub
Public Sub ReplaceSetReference(editor As SyntaxEditor, nameToken As SyntaxToken, propertyName As String, nameChanged As Boolean) Implements IReplaceMethodWithPropertyService.ReplaceSetReference
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册