Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
fa10f4ec
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,发现更多精彩内容 >>
提交
fa10f4ec
编写于
7月 14, 2016
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tuple type visualization
上级
fa83ec65
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
88 addition
and
5 deletion
+88
-5
src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb
...pilers/VisualBasic/Portable/Binding/Binder_Expressions.vb
+1
-1
src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb
...asic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb
+85
-2
src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.vb
...ic/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.vb
+1
-1
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
+1
-1
未找到文件。
src/Compilers/VisualBasic/Portable/Binding/Binder_Expressions.vb
浏览文件 @
fa10f4ec
...
...
@@ -329,7 +329,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Public
Function
BindNamespaceOrTypeOrExpressionSyntaxForSemanticModel
(
node
As
ExpressionSyntax
,
diagnostics
As
DiagnosticBag
)
As
BoundExpression
If
(
node
.
Kind
=
SyntaxKind
.
PredefinedType
)
OrElse
(((
TypeOf
node
Is
NameSyntax
)
OrElse
node
.
Kind
=
SyntaxKind
.
ArrayType
)
AndAlso
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
node
))
Then
(((
TypeOf
node
Is
NameSyntax
)
OrElse
node
.
Kind
=
SyntaxKind
.
ArrayType
OrElse
node
.
Kind
=
SyntaxKind
.
TupleType
)
AndAlso
SyntaxFacts
.
IsInNamespaceOrTypeContext
(
node
))
Then
Dim
result
As
BoundExpression
=
Me
.
BindNamespaceOrTypeExpression
(
DirectCast
(
node
,
TypeSyntax
),
diagnostics
)
' Deal with the case of a namespace group. We may need to bind more in order to see if the ambiguity can be resolved.
...
...
src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.vb
浏览文件 @
fa10f4ec
...
...
@@ -103,7 +103,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
If
End
If
If
Me
.
IsMinimizing
Then
If
Me
.
IsMinimizing
OrElse
symbol
.
IsTupleType
Then
MinimallyQualify
(
symbol
)
Return
End
If
...
...
@@ -197,9 +197,20 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
If
symbol
.
IsAnonymousType
Then
AddAnonymousTypeName
(
symbol
)
Return
ElseIf
(
symbol
.
IsTupleType
)
Then
' If top level tuple uses non-default names, there is no way to preserve them
' unless we use tuple syntax for the type. So, we give them priority.
If
HasNonDefaultTupleElementNames
(
symbol
)
OrElse
CanUseTupleTypeName
(
symbol
)
Then
AddTupleTypeName
(
symbol
)
Return
End
If
' Fall back to displaying the underlying type.
symbol
=
symbol
.
TupleUnderlyingType
End
If
If
format
.
MiscellaneousOptions
.
IncludesOption
(
SymbolDisplayMiscellaneousOptions
.
UseErrorTypeSymbolName
)
AndAlso
If
format
.
MiscellaneousOptions
.
IncludesOption
(
SymbolDisplayMiscellaneousOptions
.
UseErrorTypeSymbolName
)
AndAlso
String
.
IsNullOrEmpty
(
symbolName
)
Then
symbolName
=
StringConstants
.
NamedSymbolErrorName
...
...
@@ -287,6 +298,75 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
End
Select
End
Sub
''' <summary>
''' Returns true if tuple type syntax can be used to refer to the tuple type without loss of information.
''' For example, it cannot be used when extension tuple is using non-default friendly names.
''' </summary>
''' <param name="tupleSymbol"></param>
''' <returns></returns>
Private
Function
CanUseTupleTypeName
(
tupleSymbol
As
INamedTypeSymbol
)
As
Boolean
Dim
currentUnderlying
As
INamedTypeSymbol
=
tupleSymbol
.
TupleUnderlyingType
While
currentUnderlying
.
Arity
=
TupleTypeSymbol
.
RestPosition
tupleSymbol
=
DirectCast
(
currentUnderlying
.
TypeArguments
(
TupleTypeSymbol
.
RestPosition
-
1
),
INamedTypeSymbol
)
Debug
.
Assert
(
tupleSymbol
.
IsTupleType
)
If
HasNonDefaultTupleElementNames
(
tupleSymbol
)
Then
Return
False
End
If
currentUnderlying
=
tupleSymbol
.
TupleUnderlyingType
End
While
Return
True
End
Function
Private
Shared
Function
HasNonDefaultTupleElementNames
(
tupleSymbol
As
INamedTypeSymbol
)
As
Boolean
Dim
elementNames
=
tupleSymbol
.
TupleElementNames
If
Not
elementNames
.
IsDefault
Then
For
i
As
Integer
=
0
To
elementNames
.
Length
-
1
If
(
elementNames
(
i
)
<>
TupleTypeSymbol
.
TupleMemberName
(
i
+
1
))
Then
Return
True
End
If
Next
End
If
Return
False
End
Function
Private
Sub
AddTupleTypeName
(
symbol
As
INamedTypeSymbol
)
Debug
.
Assert
(
symbol
.
IsTupleType
)
Dim
elementTypes
As
ImmutableArray
(
Of
ITypeSymbol
)
=
symbol
.
TupleElementTypes
Dim
elementNames
As
ImmutableArray
(
Of
String
)
=
symbol
.
TupleElementNames
Dim
hasNames
As
Boolean
=
Not
elementNames
.
IsDefault
AddPunctuation
(
SyntaxKind
.
OpenParenToken
)
Dim
first
As
Boolean
=
True
For
i
As
Integer
=
0
To
elementTypes
.
Length
-
1
If
Not
first
Then
AddPunctuation
(
SyntaxKind
.
CommaToken
)
AddSpace
()
End
If
first
=
False
If
hasNames
Then
builder
.
Add
(
CreatePart
(
SymbolDisplayPartKind
.
FieldName
,
symbol
,
elementNames
(
i
),
noEscaping
:
=
False
))
AddSpace
()
AddPunctuation
(
SyntaxKind
.
AsKeyword
)
AddSpace
()
End
If
elementTypes
(
i
).
Accept
(
Me
.
NotFirstVisitor
)
Next
AddPunctuation
(
SyntaxKind
.
CloseParenToken
)
End
Sub
Private
Function
CreateAnonymousTypeMember
(
prop
As
IPropertySymbol
)
As
String
Dim
result
=
CreateAnonymousTypeMemberWorker
(
prop
)
Return
If
(
prop
.
IsReadOnly
,
"Key "
&
result
,
result
)
...
...
@@ -313,6 +393,9 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
' NOTE: Not actually a keyword, but it's not worth introducing a new kind just for this.
builder
.
Add
(
New
SymbolDisplayPart
(
SymbolDisplayPartKind
.
Keyword
,
Nothing
,
"AnonymousType"
))
AddSpace
()
ElseIf
symbol
.
IsTupleType
Then
builder
.
Add
(
New
SymbolDisplayPart
(
SymbolDisplayPartKind
.
AnonymousTypeIndicator
,
Nothing
,
"Tuple"
))
AddSpace
()
Else
Dim
keyword
=
GetTypeKindKeyword
(
symbol
.
TypeKind
)
If
keyword
=
SyntaxKind
.
None
Then
...
...
src/Compilers/VisualBasic/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.vb
浏览文件 @
fa10f4ec
...
...
@@ -92,7 +92,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic
Dim
visitedParents
As
Boolean
=
False
If
Not
symbol
.
IsAnonymousType
Then
If
Not
(
symbol
.
IsAnonymousType
OrElse
symbol
.
IsTupleType
)
Then
If
Not
NameBoundSuccessfullyToSameSymbol
(
symbol
)
Then
If
IncludeNamedType
(
symbol
.
ContainingType
)
Then
symbol
.
ContainingType
.
Accept
(
NotFirstVisitor
)
...
...
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
浏览文件 @
fa10f4ec
...
...
@@ -510,7 +510,7 @@ Done:
Private
ReadOnly
Property
ITypeSymbol_IsTupleSymbol
As
Boolean
Implements
ITypeSymbol
.
IsTupleType
Get
Return
Fals
e
Return
Me
.
IsTupleTyp
e
End
Get
End
Property
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录