Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
2885542f
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,发现更多精彩内容 >>
提交
2885542f
编写于
9月 12, 2017
作者:
C
chborl
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Responded to feedback
上级
748c5e43
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
59 addition
and
30 deletion
+59
-30
src/EditorFeatures/CSharpTest/ConvertAutoPropertyToFullProperty/ConvertAutoPropertyToFullPropertyTests.cs
...yToFullProperty/ConvertAutoPropertyToFullPropertyTests.cs
+28
-0
src/EditorFeatures/VisualBasicTest/ConvertAutoPropertyToFullProperty/ConvertAutoPropertyToFullPropertyTests.vb
...yToFullProperty/ConvertAutoPropertyToFullPropertyTests.vb
+22
-22
src/Features/CSharp/Portable/ConvertAutoPropertyToFullProperty/CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
...nvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
+1
-1
src/Features/Core/Portable/ConvertAutoPropertyToFullProperty/AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
...nvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
+5
-6
src/Features/VisualBasic/Portable/ConvertAutoPropertyToFullProperty/VisualBasicConvertAutoPropertyToFullProperty.vb
...lProperty/VisualBasicConvertAutoPropertyToFullProperty.vb
+3
-1
未找到文件。
src/EditorFeatures/CSharpTest/ConvertAutoPropertyToFullProperty/ConvertAutoPropertyToFullPropertyTests.cs
浏览文件 @
2885542f
...
...
@@ -275,6 +275,34 @@ class goo
await
TestInRegularAndScriptAsync
(
text
,
expected
,
options
:
PreferExpressionBodiedAccessorsWhenOnSingleLine
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ConvertAutoPropertyToFullProperty
)]
public
async
Task
WithExpressionBodyWhenOnSingleLine2
()
{
var
text
=
@"
class goo
{
public int G[||]oo
{
get;
set;
}
}
"
;
var
expected
=
@"
class goo
{
private int _goo;
public int Goo
{
get => _goo;
set => _goo = value;
}
}
"
;
await
TestInRegularAndScriptAsync
(
text
,
expected
,
options
:
PreferExpressionBodiedAccessorsWhenOnSingleLine
);
}
[
Fact
,
Trait
(
Traits
.
Feature
,
Traits
.
Features
.
ConvertAutoPropertyToFullProperty
)]
public
async
Task
WithExpressionBodyWithTrivia
()
{
...
...
src/EditorFeatures/VisualBasicTest/ConvertAutoPropertyToFullProperty/ConvertAutoPropertyToFullPropertyTests.vb
浏览文件 @
2885542f
...
...
@@ -20,14 +20,14 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private _
t
est1 As Integer
Private _
T
est1 As Integer
Public Property Test1 As Integer
Get
Return _
t
est1
Return _
T
est1
End Get
Set
_
t
est1 = Value
_
T
est1 = Value
End Set
End Property
End Class"
...
...
@@ -42,14 +42,14 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private _
t
est2 As Integer = 4
Private _
T
est2 As Integer = 4
Public Property Test2 As Integer
Get
Return _
t
est2
Return _
T
est2
End Get
Set
_
t
est2 = Value
_
T
est2 = Value
End Set
End Property
End Class"
...
...
@@ -64,11 +64,11 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private ReadOnly _
t
est5 As String
Private ReadOnly _
T
est5 As String
Public ReadOnly Property Test5 As String
Get
Return _
t
est5
Return _
T
est5
End Get
End Property
End Class"
...
...
@@ -83,11 +83,11 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private ReadOnly _
t
est4 As String =
""
Initial Value
""
Private ReadOnly _
T
est4 As String =
""
Initial Value
""
Public ReadOnly Property Test4 As String
Get
Return _
t
est4
Return _
T
est4
End Get
End Property
End Class"
...
...
@@ -103,14 +103,14 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private _
t
est4 As String
Private _
T
est4 As String
Private Property Test4 As String
Get
Return _
t
est4
Return _
T
est4
End Get
Set
_
t
est4 = Value
_
T
est4 = Value
End Set
End Property
End Class"
...
...
@@ -128,14 +128,14 @@ Class C
End Class"
Dim
expected
=
"
Class C
Private _
t
est1 As Integer
Private _
T
est1 As Integer
'' Comment before
Public Property Test1 As Integer ''Comment during
Get
Return _
t
est1
Return _
T
est1
End Get
Set
_
t
est1 = Value
_
T
est1 = Value
End Set
End Property
'' Comment after
...
...
@@ -153,14 +153,14 @@ End Class"
Dim
expected
=
"
Class C
Private Shared
s_t
est1 As Double
Private Shared
_T
est1 As Double
Public Shared Property Test1 As Double
Get
Return
s_t
est1
Return
_T
est1
End Get
Set
s_t
est1 = Value
_T
est1 = Value
End Set
End Property
End Class"
...
...
@@ -176,14 +176,14 @@ End Class"
Dim
expected
=
"
Class C
Private _
t
est4 As Decimal
Private _
T
est4 As Decimal
Public Overridable Property Test4 As Decimal
Get
Return _
t
est4
Return _
T
est4
End Get
Set
_
t
est4 = Value
_
T
est4 = Value
End Set
End Property
End Class"
...
...
src/Features/CSharp/Portable/ConvertAutoPropertyToFullProperty/CSharpConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
浏览文件 @
2885542f
...
...
@@ -96,7 +96,7 @@ internal override SyntaxNode GetProperty(SyntaxToken token)
return
accessorDeclarationSyntax
.
WithExpressionBody
(
arrowExpression
)
.
WithBody
(
null
)
.
WithSemicolonToken
(
s
emicolonToken
)
.
WithSemicolonToken
(
accessorDeclarationSyntax
.
S
emicolonToken
)
.
WithAdditionalAnnotations
(
Formatter
.
Annotation
);
}
...
...
src/Features/Core/Portable/ConvertAutoPropertyToFullProperty/AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider.cs
浏览文件 @
2885542f
...
...
@@ -163,9 +163,9 @@ private string GenerateFieldName(IPropertySymbol property, ImmutableArray<Naming
var
accessorTuple
=
GetNewAccessors
(
options
,
property
,
fieldName
,
generator
);
var
fullProperty
=
generator
.
WithAccessorDeclarations
(
GetPropertyWithoutInitializer
(
property
),
accessorTuple
.
newSetAccessor
==
null
?
new
SyntaxNode
[]
{
accessorTuple
.
newGetAccessor
}
GetPropertyWithoutInitializer
(
property
),
accessorTuple
.
newSetAccessor
==
null
?
new
SyntaxNode
[]
{
accessorTuple
.
newGetAccessor
}
:
new
SyntaxNode
[]
{
accessorTuple
.
newGetAccessor
,
accessorTuple
.
newSetAccessor
})
.
WithLeadingTrivia
(
property
.
GetLeadingTrivia
());
fullProperty
=
ConvertPropertyToExpressionBodyIfDesired
(
options
,
fullProperty
);
...
...
@@ -190,9 +190,8 @@ private string GenerateFieldName(IPropertySymbol property, ImmutableArray<Naming
private
class
ConvertAutoPropertyToFullPropertyCodeAction
:
CodeAction
.
DocumentChangeAction
{
public
ConvertAutoPropertyToFullPropertyCodeAction
(
string
Title
,
Func
<
CancellationToken
,
Task
<
Document
>>
createChangedDocument
)
:
base
(
Title
,
createChangedDocument
)
string
title
,
Func
<
CancellationToken
,
Task
<
Document
>>
createChangedDocument
)
:
base
(
title
,
createChangedDocument
)
{
}
}
...
...
src/Features/VisualBasic/Portable/ConvertAutoPropertyToFullProperty/VisualBasicConvertAutoPropertyToFullProperty.vb
浏览文件 @
2885542f
...
...
@@ -13,6 +13,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ConvertAutoPropertyToFullProperty
Friend
Class
VisualBasicConvertAutoPropertyToFullPropertyCodeRefactoringProvider
Inherits
AbstractConvertAutoPropertyToFullPropertyCodeRefactoringProvider
Private
Const
Underscore
As
String
=
"_"
Friend
Overrides
Function
GetProperty
(
token
As
SyntaxToken
)
As
SyntaxNode
Dim
containingProperty
=
token
.
Parent
.
FirstAncestorOrSelf
(
Of
PropertyStatementSyntax
)
If
containingProperty
Is
Nothing
Then
...
...
@@ -79,7 +81,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.ConvertAutoPropertyToFullProperty
' In VB, auto properties have an implicit backing field that is named using the property
' name preceded by an underscore. We will use this as the field name so we don't mess up
' any existing references to this field.
Return
field
Name
Return
Underscore
+
propertySymbol
.
Name
End
Function
Friend
Overrides
Function
GetTypeBlock
(
syntaxNode
As
SyntaxNode
)
As
SyntaxNode
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录