Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
9025ad48
R
roslyn
项目概览
lwm1986
/
roslyn
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
roslyn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9025ad48
编写于
5月 27, 2016
作者:
C
CyrusNajmabadi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add VB tests.
上级
f904ba18
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
431 addition
and
7 deletion
+431
-7
src/EditorFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
...orFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
+2
-1
src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb
...acePropertyWithMethods/ReplacePropertyWithMethodsTests.vb
+392
-0
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CrefCompletionProviderTests.vb
...letion/CompletionProviders/CrefCompletionProviderTests.vb
+24
-0
src/Features/VisualBasic/Portable/ReplacePropertyWithMethods/VisualBasicReplacePropertyWithMethods.vb
...pertyWithMethods/VisualBasicReplacePropertyWithMethods.vb
+13
-6
未找到文件。
src/EditorFeatures/VisualBasicTest/BasicEditorServicesTest.vbproj
浏览文件 @
9025ad48
...
...
@@ -136,6 +136,7 @@
<Compile
Include=
"CodeActions\IntroduceVariable\IntroduceVariableTests.vb"
/>
<Compile
Include=
"CodeActions\InvertIf\InvertIfTests.vb"
/>
<Compile
Include=
"CodeActions\Preview\PreviewTests.vb"
/>
<Compile
Include=
"CodeActions\ReplacePropertyWithMethods\ReplacePropertyWithMethodsTests.vb"
/>
<Compile
Include=
"Diagnostics\AddImport\AddImportTests_NuGet.vb"
/>
<Compile
Include=
"Diagnostics\ImplementAbstractClass\ImplementAbstractClassTests_FixAllTests.vb"
/>
<Compile
Include=
"Diagnostics\ImplementInterface\ImplementInterfaceTests_FixAllTests.vb"
/>
...
...
@@ -609,4 +610,4 @@
<Import
Project=
"..\..\..\build\Targets\VSL.Imports.targets"
/>
<Import
Project=
"..\..\..\build\Targets\Roslyn.Toolsets.Xunit.targets"
/>
</ImportGroup>
</Project>
</Project>
\ No newline at end of file
src/EditorFeatures/VisualBasicTest/CodeActions/ReplacePropertyWithMethods/ReplacePropertyWithMethodsTests.vb
0 → 100644
浏览文件 @
9025ad48
Imports
Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeRefactorings
Imports
Microsoft.CodeAnalysis.ReplacePropertyWithMethods
Namespace
Microsoft.CodeAnalysis.Editor.VisualBasic.UnitTests.CodeActions.ReplacePropertyWithMethods
Public
Class
ReplacePropertyWithMethodsTests
Inherits
AbstractVisualBasicCodeActionTest
Protected
Overrides
Function
CreateCodeRefactoringProvider
(
workspace
As
Workspace
)
As
Object
Return
New
ReplacePropertyWithMethodsCodeRefactoringProvider
()
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestGetWithBody
()
As
Task
Await
TestAsync
(
"class C
readonly property [||]Prop as integer
get
return 0
end get
end property
end class"
,
"class C
Public Function GetProp() As Integer
return 0
End Function
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestPrivateProperty
()
As
Task
Await
TestAsync
(
"class C
private readonly property [||]Prop as integer
get
return 0
end get
end property
end class"
,
"class C
Private Function GetProp() As Integer
return 0
End Function
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAnonyousType1
()
As
Task
Await
TestAsync
(
"class C
public readonly property [||]Prop as integer
get
return 0
end get
end property
public sub M()
dim v = new with { .P = me.Prop }
end sub
end class"
,
"class C
Public Function GetProp() As Integer
return 0
End Function
public sub M()
dim v = new with { .P = me.GetProp() }
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAnonyousType2
()
As
Task
Await
TestAsync
(
"class C
public readonly [||]Prop as integer
get
return 0
end get
end property
public sub M()
dim v = new with { me.Prop }
end sub
end class"
,
"class C
Public Function GetProp() As Integer
return 0
End Function
public sub M()
dim v = new with { .Prop = me.GetProp() }
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestPassedToRef1
()
As
Task
Await
TestAsync
(
"class C
public readonly [||]Prop as integer
get
return 0
end get
end property
public sub RefM(byref i as integer)
end sub
public sub M()
RefM(me.Prop)
end sub
end class"
,
"class C
Public Function GetProp() As Integer
return 0
End Function
public sub RefM(byref i as integer)
end sub
public sub M()
RefM(me.{|Conflict:GetProp|}())
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestUsedInAttribute1
()
As
Task
Await
TestAsync
(
"
imports System
class CAttribute
inherits Attribute
public readonly property [||]Prop as integer
get
return 0
end get
end property
end class
<C(Prop:=1)>
class D
end class
"
,
"
imports System
class CAttribute
inherits Attribute
Public Function GetProp() As Integer
return 0
End Function
end class
<C({|Conflict:Prop|}:=1)>
class D
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestSetWithBody1
()
As
Task
Await
TestAsync
(
"class C
writeonly property [||]Prop as integer
set
dim v = value
end set
end property
end class"
,
"class C
Public Sub SetProp(Value As Integer)
dim v = value
End Sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestSetWithBody2
()
As
Task
Await
TestAsync
(
"class C
writeonly property [||]Prop as integer
set(val as integer)
dim v = val
end set
end property
end class"
,
"class C
Public Sub SetProp(val As Integer)
dim v = val
End Sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestSetReference1
()
As
Task
Await
TestAsync
(
"class C
writeonly property [||]Prop as integer
set(val as integer)
dim v = val
end set
end property
sub M()
me.Prop = 1
end sub
end class"
,
"class C
Private Sub SetProp(Value As Integer)
dim v = value
End Sub
sub M()
me.SetProp(1)
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestGetterAndSetter
()
As
Task
Await
TestAsync
(
"class C
property [||]Prop as integer
get
return 0
end get
set
dim v = value
end set
end property
end class"
,
"class C
Public Function GetProp() As Integer
return 0
End Function
Public Sub SetProp(Value As Integer)
dim v = value
End Sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestRecursiveGet
()
As
Task
Await
TestAsync
(
"class C
readonly property [||]Prop as integer
get
return me.Prop + 1
end get
end property
end class"
,
"class C
Public Function GetProp() As Integer
return me.GetProp() + 1
End Function
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestRecursiveSet
()
As
Task
Await
TestAsync
(
"class C
writeonly property [||]Prop as integer
set
me.Prop = value + 1
end get
end property
end class"
,
"class C
Public Sub SetProp(Value As Integer)
me.SetProp(value + 1)
End Sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAbstractProperty
()
As
Task
Await
TestAsync
(
"class C
public readonly mustinherit property[||]Prop as integer
public sub M()
dim v = me.Prop
end sub
end class"
,
"class C
Public MustInherit Function GetProp() As Integer
public sub M()
dim v = me.GetProp()
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestVirtualProperty
()
As
Task
Await
TestAsync
(
"class C
public readonly overridable property[||]Prop as integer
get
return 0
end get
end property
public sub M()
dim v = me.Prop
end sub
end class"
,
"class C
Public Overridable Function GetProp() As Integer
return 0
End Function
public sub M()
dim v = me.GetProp()
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestInterfaceProperty1
()
As
Task
Await
TestAsync
(
"interface I
readonly property [||]Prop as integer
end interface"
,
"interface I
Function GetProp() As Integer
end interface"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestInterfaceProperty2
()
As
Task
Await
TestAsync
(
"interface I
writeonly property [||]Prop as integer
end interface"
,
"interface I
Sub SetProp(Value As Integer)
end interface"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestInterfaceProperty3
()
As
Task
Await
TestAsync
(
"interface I
property [||]Prop as integer
end interface"
,
"interface I
Function GetProp() As Integer
Sub SetProp(Value As Integer)
end interface"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAutoProperty1
()
As
Task
Await
TestAsync
(
"class C
public readonly property [||]Prop as integer
end class"
,
"class C
Private _Prop As Integer
Public Function GetProp() As Integer
Return Me._Prop
End Function
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAutoProperty2
()
As
Task
Await
TestAsync
(
"class C
public readonly property [||]Prop as integer
public sub new()
me.Prop = 1
end sub
end class"
,
"class C
Private _Prop As Integer
Public Function GetProp() As Integer
Return Me._Prop
End Function
public sub new()
me._Prop = 1
end sub
end class"
)
End
Function
<
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
CodeActionsReplacePropertyWithMethods
)
>
Public
Async
Function
TestAutoProperty4
()
As
Task
Await
TestAsync
(
"class C
public readonly property [||]Prop as integer = 1
end class"
,
"class C
Private _Prop As Integer = 1
Public Function GetProp() As Integer
Return Me._Prop
End Function
end class"
)
End
Function
End
Class
End
Namespace
\ No newline at end of file
src/EditorFeatures/VisualBasicTest/Completion/CompletionProviders/CrefCompletionProviderTests.vb
浏览文件 @
9025ad48
...
...
@@ -828,6 +828,30 @@ End Class]]></a>.Value.NormalizeLineEndings()
Public
Function
GetRightSideOfDot
(
node
As
SyntaxNode
)
As
SyntaxNode
Implements
ISyntaxFactsService
.
GetRightSideOfDot
Throw
New
NotImplementedException
()
End
Function
Public
Function
IsLeftSideOfAssignment
(
node
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsLeftSideOfAssignment
Throw
New
NotImplementedException
()
End
Function
Public
Function
IsLeftSideOfAnyAssignment
(
node
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsLeftSideOfAnyAssignment
Throw
New
NotImplementedException
()
End
Function
Public
Function
GetRightHandSideOfAssignment
(
node
As
SyntaxNode
)
As
SyntaxNode
Implements
ISyntaxFactsService
.
GetRightHandSideOfAssignment
Throw
New
NotImplementedException
()
End
Function
Public
Function
IsInferredAnonymousObjectMemberDeclarator
(
node
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsInferredAnonymousObjectMemberDeclarator
Throw
New
NotImplementedException
()
End
Function
Public
Function
IsOperandOfIncrementExpression
(
node
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOperandOfIncrementExpression
Throw
New
NotImplementedException
()
End
Function
Public
Function
IsOperandOfIncrementOrDecrementExpression
(
node
As
SyntaxNode
)
As
Boolean
Implements
ISyntaxFactsService
.
IsOperandOfIncrementOrDecrementExpression
Throw
New
NotImplementedException
()
End
Function
End
Class
End
Class
End
Namespace
src/Features/VisualBasic/Portable/ReplacePropertyWithMethods/VisualBasicReplacePropertyWithMethods.vb
浏览文件 @
9025ad48
...
...
@@ -16,6 +16,11 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
Return
Nothing
End
If
' a parameterized property can be trivially converted to a method.
If
containingProperty
.
ParameterList
IsNot
Nothing
Then
Return
Nothing
End
If
Dim
start
=
If
(
containingProperty
.
AttributeLists
.
Count
>
0
,
containingProperty
.
AttributeLists
.
Last
().
GetLastToken
().
GetNextToken
().
SpanStart
,
containingProperty
.
SpanStart
)
...
...
@@ -31,10 +36,6 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
Return
Nothing
End
If
If
position
>
containingProperty
.
ParameterList
.
Span
.
End
Then
Return
Nothing
End
If
Return
containingProperty
End
Function
...
...
@@ -101,7 +102,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
cancellationToken
As
CancellationToken
)
As
SyntaxNode
Dim
statements
=
New
List
(
Of
SyntaxNode
)()
Dim
getAccessorDeclaration
=
TryCast
(
getMethod
.
DeclaringSyntaxReferences
(
0
).
GetSyntax
(
cancellationToken
),
AccessorStatementSyntax
)
Dim
getAccessorDeclaration
=
If
(
getMethod
.
DeclaringSyntaxReferences
.
Length
=
0
,
Nothing
,
TryCast
(
getMethod
.
DeclaringSyntaxReferences
(
0
).
GetSyntax
(
cancellationToken
),
AccessorStatementSyntax
))
If
TypeOf
getAccessorDeclaration
?
.
Parent
Is
AccessorBlockSyntax
Then
Dim
block
=
DirectCast
(
getAccessorDeclaration
.
Parent
,
AccessorBlockSyntax
)
statements
.
AddRange
(
block
.
Statements
)
...
...
@@ -122,7 +126,10 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.CodeRefactorings.ReplaceMethodWithP
cancellationToken
As
CancellationToken
)
As
SyntaxNode
Dim
statements
=
New
List
(
Of
SyntaxNode
)()
Dim
setAccessorDeclaration
=
TryCast
(
setMethod
.
DeclaringSyntaxReferences
(
0
).
GetSyntax
(
cancellationToken
),
AccessorStatementSyntax
)
Dim
setAccessorDeclaration
=
If
(
setMethod
.
DeclaringSyntaxReferences
.
Length
=
0
,
Nothing
,
TryCast
(
setMethod
.
DeclaringSyntaxReferences
(
0
).
GetSyntax
(
cancellationToken
),
AccessorStatementSyntax
))
If
TypeOf
setAccessorDeclaration
?
.
Parent
Is
AccessorBlockSyntax
Then
Dim
block
=
DirectCast
(
setAccessorDeclaration
.
Parent
,
AccessorBlockSyntax
)
statements
.
AddRange
(
block
.
Statements
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录