Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
759077fb
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,发现更多精彩内容 >>
未验证
提交
759077fb
编写于
9月 12, 2017
作者:
F
Fredric Silberberg
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for RValues in VB With Expressions.
上级
ef52c548
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
11 deletion
+55
-11
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
...lBasic/Portable/Operations/VisualBasicOperationFactory.vb
+20
-7
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb
...c/IOperation/IOperationTests_IObjectCreationExpression.vb
+3
-3
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IPropertyReferenceExpression.vb
...Operation/IOperationTests_IPropertyReferenceExpression.vb
+32
-1
未找到文件。
src/Compilers/VisualBasic/Portable/Operations/VisualBasicOperationFactory.vb
浏览文件 @
759077fb
...
@@ -234,6 +234,10 @@ Namespace Microsoft.CodeAnalysis.Semantics
...
@@ -234,6 +234,10 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return
Create
(
DirectCast
(
boundNode
,
BoundAnonymousTypeFieldInitializer
).
Value
)
Return
Create
(
DirectCast
(
boundNode
,
BoundAnonymousTypeFieldInitializer
).
Value
)
Case
BoundKind
.
AnonymousTypePropertyAccess
Case
BoundKind
.
AnonymousTypePropertyAccess
Return
CreateBoundAnonymousTypePropertyAccessOperation
(
DirectCast
(
boundNode
,
BoundAnonymousTypePropertyAccess
))
Return
CreateBoundAnonymousTypePropertyAccessOperation
(
DirectCast
(
boundNode
,
BoundAnonymousTypePropertyAccess
))
Case
BoundKind
.
WithLValueExpressionPlaceholder
Return
CreateBoundWithLValueExpressionPlaceholder
(
DirectCast
(
boundNode
,
BoundWithLValueExpressionPlaceholder
))
Case
BoundKind
.
WithRValueExpressionPlaceholder
Return
CreateBoundWithRValueExpressionPlaceholder
(
DirectCast
(
boundNode
,
BoundWithRValueExpressionPlaceholder
))
Case
Else
Case
Else
Dim
constantValue
=
ConvertToOptional
(
TryCast
(
boundNode
,
BoundExpression
)
?
.
ConstantValueOpt
)
Dim
constantValue
=
ConvertToOptional
(
TryCast
(
boundNode
,
BoundExpression
)
?
.
ConstantValueOpt
)
Dim
isImplicit
As
Boolean
=
boundNode
.
WasCompilerGenerated
Dim
isImplicit
As
Boolean
=
boundNode
.
WasCompilerGenerated
...
@@ -678,13 +682,6 @@ Namespace Microsoft.CodeAnalysis.Semantics
...
@@ -678,13 +682,6 @@ Namespace Microsoft.CodeAnalysis.Semantics
Function
()
Function
()
If
boundPropertyAccess
.
PropertySymbol
.
IsShared
Then
If
boundPropertyAccess
.
PropertySymbol
.
IsShared
Then
Return
Nothing
Return
Nothing
ElseIf
boundPropertyAccess
.
ReceiverOpt
IsNot
Nothing
AndAlso
boundPropertyAccess
.
ReceiverOpt
.
Kind
=
BoundKind
.
WithLValueExpressionPlaceholder
Then
Return
New
InstanceReferenceExpression
(
semanticModel
:
=
_semanticModel
,
syntax
:
=
boundPropertyAccess
.
ReceiverOpt
.
Syntax
,
type
:
=
boundPropertyAccess
.
ReceiverOpt
.
Type
,
constantValue
:
=
Nothing
,
isImplicit
:
=
boundPropertyAccess
.
WasCompilerGenerated
)
Else
Else
Return
Create
(
boundPropertyAccess
.
ReceiverOpt
)
Return
Create
(
boundPropertyAccess
.
ReceiverOpt
)
End
If
End
If
...
@@ -704,6 +701,22 @@ Namespace Microsoft.CodeAnalysis.Semantics
...
@@ -704,6 +701,22 @@ Namespace Microsoft.CodeAnalysis.Semantics
Return
New
LazyPropertyReferenceExpression
(
[
property
]
,
instance
,
[
property
]
,
argumentsInEvaluationOrder
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
Return
New
LazyPropertyReferenceExpression
(
[
property
]
,
instance
,
[
property
]
,
argumentsInEvaluationOrder
,
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
End
Function
End
Function
Private
Function
CreateBoundWithLValueExpressionPlaceholder
(
boundWithLValueExpressionPlaceholder
As
BoundWithLValueExpressionPlaceholder
)
As
IInstanceReferenceExpression
Dim
syntax
As
SyntaxNode
=
boundWithLValueExpressionPlaceholder
.
Syntax
Dim
type
As
ITypeSymbol
=
boundWithLValueExpressionPlaceholder
.
Type
Dim
constantValue
As
[
Optional
]
(
Of
Object
)
=
ConvertToOptional
(
boundWithLValueExpressionPlaceholder
.
ConstantValueOpt
)
Dim
isImplicit
As
Boolean
=
boundWithLValueExpressionPlaceholder
.
WasCompilerGenerated
Return
New
InstanceReferenceExpression
(
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
End
Function
Private
Function
CreateBoundWithRValueExpressionPlaceholder
(
boundWithRValueExpressionPlaceholder
As
BoundWithRValueExpressionPlaceholder
)
As
IInstanceReferenceExpression
Dim
syntax
As
SyntaxNode
=
boundWithRValueExpressionPlaceholder
.
Syntax
Dim
type
As
ITypeSymbol
=
boundWithRValueExpressionPlaceholder
.
Type
Dim
constantValue
As
[
Optional
]
(
Of
Object
)
=
ConvertToOptional
(
boundWithRValueExpressionPlaceholder
.
ConstantValueOpt
)
Dim
isImplicit
As
Boolean
=
boundWithRValueExpressionPlaceholder
.
WasCompilerGenerated
Return
New
InstanceReferenceExpression
(
_semanticModel
,
syntax
,
type
,
constantValue
,
isImplicit
)
End
Function
Private
Function
CreateBoundEventAccessOperation
(
boundEventAccess
As
BoundEventAccess
)
As
IEventReferenceExpression
Private
Function
CreateBoundEventAccessOperation
(
boundEventAccess
As
BoundEventAccess
)
As
IEventReferenceExpression
Dim
instance
As
Lazy
(
Of
IOperation
)
=
New
Lazy
(
Of
IOperation
)(
Dim
instance
As
Lazy
(
Of
IOperation
)
=
New
Lazy
(
Of
IOperation
)(
Function
()
Function
()
...
...
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IObjectCreationExpression.vb
浏览文件 @
759077fb
...
@@ -60,7 +60,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
...
@@ -60,7 +60,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
Initializers
(
1
):
Initializers
(
1
):
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'.Field = 2')
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'.Field = 2')
Left
:
IFieldReferenceExpression
:
F
.
Field
As
System
.
Int32
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'Field')
Left
:
IFieldReferenceExpression
:
F
.
Field
As
System
.
Int32
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'Field')
Instance
Receiver
:
I
Operation
:
(
OperationKind
.
None
)
(
Syntax
:
'New F() Wit ... .Field = 2}')
Instance
Receiver
:
I
InstanceReferenceExpression
(
OperationKind
.
InstanceReferenceExpression
,
Type
:
F
)
(
Syntax
:
'New F() Wit ... .Field = 2}')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
2
)
(
Syntax
:
'2')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
2
)
(
Syntax
:
'2')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
)
(
Syntax
:
'Dim x3 = Ne ... erty1 = ""}')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
)
(
Syntax
:
'Dim x3 = Ne ... erty1 = ""}')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'x3')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'x3')
...
@@ -86,7 +86,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
...
@@ -86,7 +86,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
String
,
Constant
:
""
)
(
Syntax
:
'""')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
String
,
Constant
:
""
)
(
Syntax
:
'""')
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'.Field = 2')
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'.Field = 2')
Left
:
IFieldReferenceExpression
:
F
.
Field
As
System
.
Int32
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'Field')
Left
:
IFieldReferenceExpression
:
F
.
Field
As
System
.
Int32
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Int32
)
(
Syntax
:
'Field')
Instance
Receiver
:
I
Operation
:
(
OperationKind
.
None
)
(
Syntax
:
'New F() Wit ... .Field = 2}')
Instance
Receiver
:
I
InstanceReferenceExpression
(
OperationKind
.
InstanceReferenceExpression
,
Type
:
F
)
(
Syntax
:
'New F() Wit ... .Field = 2}')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
2
)
(
Syntax
:
'2')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Int32
,
Constant
:
2
)
(
Syntax
:
'2')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
)
(
Syntax
:
'Dim x5 = Ne ... ld = True}}')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
)
(
Syntax
:
'Dim x5 = Ne ... ld = True}}')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'x5')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'x5')
...
@@ -104,7 +104,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
...
@@ -104,7 +104,7 @@ IBlockStatement (9 statements, 7 locals) (OperationKind.BlockStatement, IsInvali
Initializers
(
1
):
Initializers
(
1
):
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Boolean
)
(
Syntax
:
'.Field = True')
ISimpleAssignmentExpression
(
OperationKind
.
SimpleAssignmentExpression
,
Type
:
System
.
Boolean
)
(
Syntax
:
'.Field = True')
Left
:
IFieldReferenceExpression
:
B
.
Field
As
System
.
Boolean
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Boolean
)
(
Syntax
:
'Field')
Left
:
IFieldReferenceExpression
:
B
.
Field
As
System
.
Boolean
(
OperationKind
.
FieldReferenceExpression
,
Type
:
System
.
Boolean
)
(
Syntax
:
'Field')
Instance
Receiver
:
I
Operation
:
(
OperationKind
.
None
)
(
Syntax
:
'New B() Wit ... eld = True}')
Instance
Receiver
:
I
InstanceReferenceExpression
(
OperationKind
.
InstanceReferenceExpression
,
Type
:
B
)
(
Syntax
:
'New B() Wit ... eld = True}')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Boolean
,
Constant
:
True
)
(
Syntax
:
'True')
Right
:
ILiteralExpression
(
OperationKind
.
LiteralExpression
,
Type
:
System
.
Boolean
,
Constant
:
True
)
(
Syntax
:
'True')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
,
IsInvalid
)
(
Syntax
:
'Dim e1 = Ne ... perty2 = 1}')
IVariableDeclarationStatement
(
1
declarations
)
(
OperationKind
.
VariableDeclarationStatement
,
IsInvalid
)
(
Syntax
:
'Dim e1 = Ne ... perty2 = 1}')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'e1')
IVariableDeclaration
(
1
variables
)
(
OperationKind
.
VariableDeclaration
)
(
Syntax
:
'e1')
...
...
src/Compilers/VisualBasic/Test/Semantic/IOperation/IOperationTests_IPropertyReferenceExpression.vb
浏览文件 @
759077fb
...
@@ -10,7 +10,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
...
@@ -10,7 +10,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.UnitTests.Semantics
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
()
>
<
Fact
()
>
Public
Sub
PropertyReferenceExpression_PropertyReferenceIn
DerivedTypeUsesDerivedTypeAsInstanceTyp
e
()
Public
Sub
PropertyReferenceExpression_PropertyReferenceIn
WithDerivedTypeUsesDerivedTypeAsInstanceType_LValu
e
()
Dim
source
=
<
!
[
CDATA
[
Dim
source
=
<
!
[
CDATA
[
Option Strict On
Option Strict On
Module
M1
Module
M1
...
@@ -36,5 +36,36 @@ IPropertyReferenceExpression: Property M1.C1.P1 As System.Object (OperationKind.
...
@@ -36,5 +36,36 @@ IPropertyReferenceExpression: Property M1.C1.P1 As System.Object (OperationKind.
VerifyOperationTreeAndDiagnosticsForTest
(
Of
IdentifierNameSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
VerifyOperationTreeAndDiagnosticsForTest
(
Of
IdentifierNameSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
End
Sub
<
CompilerTrait
(
CompilerFeature
.
IOperation
)
>
<
Fact
()
>
Public
Sub
PropertyReferenceExpression_PropertyReferenceInWithDerivedTypeUsesDerivedTypeAsInstanceType_RValue
()
Dim
source
=
<
!
[
CDATA
[
Option Strict On
Module
M1
Sub
Method1
()
Dim
c2
As
C2
=
New
C2
With
{.
P2
=
.
P1
}
'BIND:".P1"
c2
.
P1
=
Nothing
End
Sub
Class
C1
Public
Overridable
Property
P1
As
Object
Public
Property
P2
As
Object
End
Class
Class
C2
Inherits
C1
End
Class
End
Module
]]
>
.
Value
Dim
expectedOperationTree
=
<
!
[
CDATA
[
IPropertyReferenceExpression
:
Property
M1
.
C1
.
P1
As
System
.
Object
(
OperationKind
.
PropertyReferenceExpression
,
Type
:
System
.
Object
)
(
Syntax
:
'.P1')
Instance
Receiver
:
IInstanceReferenceExpression
(
OperationKind
.
InstanceReferenceExpression
,
Type
:
M1
.
C2
)
(
Syntax
:
'New C2 With {.P2 = .P1}')
]]
>
.
Value
Dim
expectedDiagnostics
=
String
.
Empty
VerifyOperationTreeAndDiagnosticsForTest
(
Of
MemberAccessExpressionSyntax
)(
source
,
expectedOperationTree
,
expectedDiagnostics
)
End
Sub
End
Class
End
Class
End
Namespace
End
Namespace
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录