Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
4d819cea
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,发现更多精彩内容 >>
提交
4d819cea
编写于
3月 21, 2016
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
CR feedback and better visualization
上级
7ad395c8
变更
20
显示空白变更内容
内联
并排
Showing
20 changed file
with
172 addition
and
110 deletion
+172
-110
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
+32
-6
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
+3
-11
src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
...Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
+0
-8
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
+1
-0
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
...ompilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
+8
-3
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs
...harp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs
+34
-1
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.cs
...rp/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
+4
-9
src/Compilers/CSharp/Portable/Symbols/TupleTypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/TupleTypeSymbol.cs
+40
-38
src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
+11
-0
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
...Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
+0
-1
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+10
-12
src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs
src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs
+5
-0
src/Compilers/Core/Portable/Symbols/SymbolKind.cs
src/Compilers/Core/Portable/Symbols/SymbolKind.cs
+0
-5
src/Compilers/Core/Portable/Symbols/SymbolVisitor.cs
src/Compilers/Core/Portable/Symbols/SymbolVisitor.cs
+0
-5
src/Compilers/Core/Portable/Symbols/SymbolVisitor`1.cs
src/Compilers/Core/Portable/Symbols/SymbolVisitor`1.cs
+0
-5
src/Compilers/Core/Portable/Symbols/TypeKind.cs
src/Compilers/Core/Portable/Symbols/TypeKind.cs
+0
-5
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
+7
-0
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs
...AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs
+8
-0
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationTypeSymbol.cs
...rtable/CodeGeneration/Symbols/CodeGenerationTypeSymbol.cs
+8
-0
未找到文件。
src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs
浏览文件 @
4d819cea
...
...
@@ -648,9 +648,18 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
if
(
arguments
.
Count
<
2
)
{
// this should be a parse error already.
return
BadExpression
(
node
);
var
args
=
arguments
.
Count
==
1
?
new
BoundExpression
[]
{
BindValue
(
arguments
[
0
].
Expression
,
diagnostics
,
BindValueKind
.
RValue
)
}
:
new
BoundExpression
[
0
];
return
BadExpression
(
node
,
args
);
}
bool
hasErrors
=
false
;
// set of names already used
HashSet
<
string
>
uniqueFieldNames
=
new
HashSet
<
string
>();
var
boundArguments
=
ArrayBuilder
<
BoundExpression
>.
GetInstance
(
arguments
.
Count
);
var
elementTypes
=
ArrayBuilder
<
TypeSymbol
>.
GetInstance
(
arguments
.
Count
);
ArrayBuilder
<
string
>
elementNames
=
null
;
...
...
@@ -658,8 +667,22 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
for
(
int
i
=
0
,
l
=
arguments
.
Count
;
i
<
l
;
i
++)
{
var
argumentSyntax
=
arguments
[
i
];
var
name
=
argumentSyntax
.
NameColon
?.
Name
.
Identifier
.
ValueText
;
var
name
=
argumentSyntax
.
NameColon
?.
Name
?.
Identifier
.
ValueText
;
// validate name if we have one
if
(
name
!=
null
)
{
// PROTOTYPE: check for a case "ItemX" where X is not i
if
(!
uniqueFieldNames
.
Add
(
name
))
{
hasErrors
=
true
;
// PROTOTYPE: need specific duplicate name error for tuples
Error
(
diagnostics
,
ErrorCode
.
ERR_AnonymousTypeDuplicatePropertyName
,
argumentSyntax
.
NameColon
.
Name
);
}
}
// add the name to the list
// names would typically all be there or none at all
// but in case we need to handle this in error cases
if
(
elementNames
!=
null
)
...
...
@@ -679,15 +702,18 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
}
}
var
boundArgument
=
Bind
Expression
(
argumentSyntax
.
Expression
,
diagnostics
);
var
boundArgument
=
Bind
Value
(
argumentSyntax
.
Expression
,
diagnostics
,
BindValueKind
.
RValue
);
boundArguments
.
Add
(
boundArgument
);
elementTypes
.
Add
(
boundArgument
.
Type
);
// PROTOTYPE: need to report distinc errors for tuples
var
elementType
=
GetAnonymousTypeFieldType
(
boundArgument
,
argumentSyntax
,
diagnostics
,
ref
hasErrors
);
elementTypes
.
Add
(
elementType
);
}
var
type
=
new
TupleTypeSymbol
(
elementTypes
.
ToImmutableAndFree
(),
elementNames
==
null
?
ImmutableArray
<
string
>.
Empty
:
default
(
ImmutableArray
<
string
>)
:
elementNames
.
ToImmutableAndFree
(),
node
,
this
,
...
...
@@ -696,7 +722,7 @@ private BoundExpression BindTupleExpression(TupleExpressionSyntax node, Diagnost
//PROTOTYPE: should be a wellknown member?
var
ctor
=
type
.
UnderlyingTupleType
?.
InstanceConstructors
.
FirstOrDefault
();
return
new
BoundTupleCreationExpression
(
node
,
ctor
,
boundArguments
.
ToImmutableAndFree
(),
type
);
return
new
BoundTupleCreationExpression
(
node
,
ctor
,
boundArguments
.
ToImmutableAndFree
(),
type
,
hasErrors
);
}
private
BoundExpression
BindRefValue
(
RefValueExpressionSyntax
node
,
DiagnosticBag
diagnostics
)
...
...
src/Compilers/CSharp/Portable/Binder/Binder_Lookup.cs
浏览文件 @
4d819cea
...
...
@@ -187,10 +187,6 @@ protected void LookupMembersInType(LookupResult result, TypeSymbol type, string
this
.
LookupMembersInClass
(
result
,
type
,
name
,
arity
,
basesBeingResolved
,
options
,
originalBinder
,
diagnose
,
ref
useSiteDiagnostics
);
break
;
case
TypeKind
.
Tuple
:
useSiteDiagnostics
=
LookupMembersInTuple
(
result
,
type
,
name
,
arity
,
basesBeingResolved
,
options
,
originalBinder
,
diagnose
,
useSiteDiagnostics
);
break
;
case
TypeKind
.
Submission
:
this
.
LookupMembersInSubmissions
(
result
,
type
,
name
,
arity
,
basesBeingResolved
,
options
,
originalBinder
,
diagnose
,
ref
useSiteDiagnostics
);
break
;
...
...
@@ -212,12 +208,6 @@ protected void LookupMembersInType(LookupResult result, TypeSymbol type, string
// done in the caller?
}
private
HashSet
<
DiagnosticInfo
>
LookupMembersInTuple
(
LookupResult
result
,
TypeSymbol
type
,
string
name
,
int
arity
,
ConsList
<
Symbol
>
basesBeingResolved
,
LookupOptions
options
,
Binder
originalBinder
,
bool
diagnose
,
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
)
{
this
.
LookupMembersInClass
(
result
,
type
,
name
,
arity
,
basesBeingResolved
,
options
,
originalBinder
,
diagnose
,
ref
useSiteDiagnostics
);
return
useSiteDiagnostics
;
}
private
void
LookupMembersInErrorType
(
LookupResult
result
,
ErrorTypeSymbol
errorType
,
string
name
,
int
arity
,
ConsList
<
Symbol
>
basesBeingResolved
,
LookupOptions
options
,
Binder
originalBinder
,
bool
diagnose
,
ref
HashSet
<
DiagnosticInfo
>
useSiteDiagnostics
)
{
if
(!
errorType
.
CandidateSymbols
.
IsDefault
&&
errorType
.
CandidateSymbols
.
Length
==
1
)
...
...
@@ -728,7 +718,7 @@ internal virtual bool SupportsExtensionMethods
// PROTOTYPE consider taking this out of the loop. tuples are always at the end of hierarchy
// PROTOTYPE match this in other lookups
var
tuple
=
currentType
as
TupleTypeSymbol
;
if
(
tuple
!=
null
)
if
(
(
object
)
tuple
!=
null
)
{
currentType
=
tuple
.
UnderlyingTupleType
;
continue
;
...
...
@@ -1542,6 +1532,8 @@ private void AddMemberLookupSymbolsInfoInType(LookupSymbolsInfo result, TypeSymb
this
.
AddMemberLookupSymbolsInfoInClass
(
result
,
type
,
options
,
originalBinder
,
type
);
break
;
//PROTOTYPE: add special handling for tuple types - we need to collect both tuple members and from the underlying.
case
TypeKind
.
Submission
:
this
.
AddMemberLookupSymbolsInfoInSubmissions
(
result
,
type
,
options
,
originalBinder
);
break
;
...
...
src/Compilers/CSharp/Portable/Binder/Semantics/AccessCheck.cs
浏览文件 @
4d819cea
...
...
@@ -99,9 +99,6 @@ internal static class AccessCheck
case
SymbolKind
.
NamedType
:
return
IsNamedTypeAccessible
((
NamedTypeSymbol
)
symbol
,
within
,
ref
useSiteDiagnostics
,
basesBeingResolved
);
case
SymbolKind
.
TupleType
:
return
IsNamedTypeAccessible
(((
TupleTypeSymbol
)
symbol
).
UnderlyingTupleType
,
within
,
ref
useSiteDiagnostics
,
basesBeingResolved
);
case
SymbolKind
.
ErrorType
:
// Always assume that error types are accessible.
return
true
;
...
...
@@ -224,11 +221,6 @@ private static bool IsNamedTypeAccessible(NamedTypeSymbol type, Symbol within, r
failedThroughTypeCheck
=
false
;
// for tuples consider the underlying type as a true container for visibility puroposes.
containingType
=
(
containingType
as
TupleTypeSymbol
)?.
UnderlyingTupleType
??
containingType
;
// easy case - members of containing type are accessible.
if
((
object
)
containingType
==
(
object
)
within
)
{
...
...
src/Compilers/CSharp/Portable/BoundTree/BoundNodes.xml
浏览文件 @
4d819cea
...
...
@@ -1145,6 +1145,7 @@
<Node
Name=
"BoundTupleCreationExpression"
Base=
"BoundExpression"
>
<!-- Non-null type is required for this node kind -->
<Field
Name=
"Type"
Type=
"TypeSymbol"
Override=
"true"
Null=
"disallow"
/>
<!-- The constructor of the underlying tuple type -->
<Field
Name=
"Constructor"
Type=
"MethodSymbol"
Null=
"disallow"
/>
<Field
Name=
"Arguments"
Type=
"ImmutableArray<BoundExpression>"
/>
</Node>
...
...
src/Compilers/CSharp/Portable/Emitter/Model/PEModuleBuilder.cs
浏览文件 @
4d819cea
...
...
@@ -768,6 +768,10 @@ protected virtual Cci.IModuleReference TranslateModule(ModuleSymbol module, Diag
{
namedTypeSymbol
=
AnonymousTypeManager
.
TranslateAnonymousTypeSymbol
(
namedTypeSymbol
);
}
else
if
(
namedTypeSymbol
.
IsTupleType
)
{
namedTypeSymbol
=
((
TupleTypeSymbol
)
namedTypeSymbol
).
UnderlyingTupleType
;
}
// Substitute error types with a special singleton object.
// Unreported bad types can come through NoPia embedding, for example.
...
...
@@ -914,9 +918,6 @@ internal static Cci.IGenericParameterReference Translate(TypeParameterSymbol par
case
SymbolKind
.
TypeParameter
:
return
Translate
((
TypeParameterSymbol
)
typeSymbol
);
case
SymbolKind
.
TupleType
:
return
Translate
(((
TupleTypeSymbol
)
typeSymbol
).
UnderlyingTupleType
,
syntaxNodeOpt
,
diagnostics
);
}
throw
ExceptionUtilities
.
UnexpectedValue
(
typeSymbol
.
Kind
);
...
...
@@ -1090,6 +1091,10 @@ internal override Cci.IMethodReference Translate(MethodSymbol symbol, Diagnostic
{
methodSymbol
=
AnonymousTypeManager
.
TranslateAnonymousTypeMethodSymbol
(
methodSymbol
);
}
else
if
(
container
.
IsTupleType
)
{
container
=
((
TupleTypeSymbol
)
container
).
UnderlyingTupleType
;
}
if
(!
methodSymbol
.
IsDefinition
)
{
...
...
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor.Types.cs
浏览文件 @
4d819cea
...
...
@@ -165,7 +165,9 @@ public override void VisitNamedType(INamedTypeSymbol symbol)
}
}
if
(
this
.
IsMinimizing
)
// PROTOTYPE : we need to settle on final tuple symbol visualization.
// it feels like tuples would not need any qualification
if
(
this
.
IsMinimizing
||
symbol
.
IsTupleType
)
{
MinimallyQualify
(
symbol
);
return
;
...
...
@@ -238,6 +240,11 @@ private void AddNameAndTypeArgumentsOrParameters(INamedTypeSymbol symbol)
AddAnonymousTypeName
(
symbol
);
return
;
}
else
if
(
symbol
.
IsTupleType
)
{
AddTupleTypeName
(
symbol
);
return
;
}
string
symbolName
=
null
;
...
...
@@ -378,11 +385,32 @@ private void AddAnonymousTypeName(INamedTypeSymbol symbol)
}
}
private
void
AddTupleTypeName
(
INamedTypeSymbol
symbol
)
{
// TODO: revise to generate user-friendly name
var
members
=
string
.
Join
(
", "
,
symbol
.
GetMembers
().
OfType
<
IFieldSymbol
>().
Select
(
CreateTupleTypeMember
));
if
(
members
.
Length
==
0
)
{
builder
.
Add
(
new
SymbolDisplayPart
(
SymbolDisplayPartKind
.
ClassName
,
symbol
,
"<empty tuple type>"
));
}
else
{
var
name
=
$"<tuple:
{
members
}
>"
;
builder
.
Add
(
new
SymbolDisplayPart
(
SymbolDisplayPartKind
.
ClassName
,
symbol
,
name
));
}
}
private
string
CreateAnonymousTypeMember
(
IPropertySymbol
property
)
{
return
property
.
Type
.
ToDisplayString
(
format
)
+
" "
+
property
.
Name
;
}
private
string
CreateTupleTypeMember
(
IFieldSymbol
field
)
{
return
field
.
Type
.
ToDisplayString
(
format
)
+
" "
+
field
.
Name
;
}
private
bool
CanShowDelegateSignature
(
INamedTypeSymbol
symbol
)
{
return
...
...
@@ -479,6 +507,11 @@ private void AddTypeKind(INamedTypeSymbol symbol)
builder
.
Add
(
new
SymbolDisplayPart
(
SymbolDisplayPartKind
.
AnonymousTypeIndicator
,
null
,
"AnonymousType"
));
AddSpace
();
}
else
if
(
symbol
.
IsTupleType
)
{
builder
.
Add
(
new
SymbolDisplayPart
(
SymbolDisplayPartKind
.
AnonymousTypeIndicator
,
null
,
"Tuple"
));
AddSpace
();
}
else
{
var
kindKeyword
=
GetKindKeyword
(
symbol
.
TypeKind
);
...
...
src/Compilers/CSharp/Portable/SymbolDisplay/SymbolDisplayVisitor_Minimal.cs
浏览文件 @
4d819cea
...
...
@@ -118,7 +118,7 @@ private void MinimallyQualify(INamedTypeSymbol symbol)
// TODO(cyrusn): This code needs to see if type is an attribute and if it can be shown
// in simplified form here.
if
(!
symbol
.
IsAnonymousType
)
if
(!
(
symbol
.
IsAnonymousType
||
symbol
.
IsTupleType
)
)
{
if
(!
NameBoundSuccessfullyToSameSymbol
(
symbol
))
{
...
...
src/Compilers/CSharp/Portable/Symbols/NamedTypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -655,18 +655,13 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiersAndArrayS
//PROTOTYPE: rename ignoreDynamic or introduce another "ignoreTuple" flag
// if ignoring dynamic, compare underlying tuple types
var
tupleType
=
t2
as
TupleTypeSymbol
;
if
(
tupleType
!=
null
)
if
(
t2
.
IsTupleType
)
{
t2
=
tupleType
.
UnderlyingTupleType
;
t2
=
((
TupleTypeSymbol
)
t2
)
.
UnderlyingTupleType
;
if
((
object
)
t2
==
this
)
return
true
;
}
tupleType
=
this
as
TupleTypeSymbol
;
if
(
tupleType
!=
null
)
{
return
tupleType
.
UnderlyingTupleType
.
Equals
(
t2
,
ignoreCustomModifiersAndArraySizesAndLowerBounds
,
ignoreDynamic
);
}
Debug
.
Assert
(!
this
.
IsTupleType
);
}
NamedTypeSymbol
other
=
t2
as
NamedTypeSymbol
;
...
...
src/Compilers/CSharp/Portable/Symbols/TupleTypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -65,11 +65,11 @@ internal sealed class TupleTypeSymbol : NamedTypeSymbol, ITupleTypeSymbol
var
underlyingField2
=
(
FieldSymbol
)
Binder
.
GetWellKnownTypeMember
(
binder
.
Compilation
,
WellKnownMember
.
System_Runtime_CompilerServices_ValueTuple_T1_T2__Item2
,
diagnostics
,
syntax
:
syntax
);
fields
=
ImmutableArray
.
Create
(
new
TupleFieldSymbol
(
elementNames
.
Is
Empty
?
"Item1"
:
elementNames
[
0
],
new
TupleFieldSymbol
(
elementNames
.
Is
Default
?
"Item1"
:
elementNames
[
0
],
this
,
elementTypes
[
0
],
underlyingField1
?.
AsMember
(
underlyingType
)),
new
TupleFieldSymbol
(
elementNames
.
Is
Empty
?
"Item2"
:
elementNames
[
1
],
new
TupleFieldSymbol
(
elementNames
.
Is
Default
?
"Item2"
:
elementNames
[
1
],
this
,
elementTypes
[
1
],
underlyingField2
?.
AsMember
(
underlyingType
))
...
...
@@ -136,6 +136,14 @@ internal sealed override bool IsManagedType
}
}
public
override
bool
IsTupleType
{
get
{
return
true
;
}
}
internal
sealed
override
ObsoleteAttributeData
ObsoleteAttributeData
{
get
{
return
_underlyingType
.
ObsoleteAttributeData
;
}
...
...
@@ -148,7 +156,7 @@ public override ImmutableArray<Symbol> GetMembers()
public
override
ImmutableArray
<
Symbol
>
GetMembers
(
string
name
)
{
//
TODO
: PERF do we need to have a dictionary here?
//
PROTOTYPE
: PERF do we need to have a dictionary here?
// tuples will be typically small 2 or 3 elements only
return
ImmutableArray
<
Symbol
>.
CastUp
(
_fields
).
WhereAsArray
(
field
=>
field
.
Name
==
name
);
}
...
...
@@ -172,7 +180,7 @@ public override SymbolKind Kind
{
get
{
return
SymbolKind
.
TupleType
;
return
_underlyingType
.
Kind
;
}
}
...
...
@@ -180,7 +188,7 @@ public override TypeKind TypeKind
{
get
{
return
TypeKind
.
Tuple
;
return
_underlyingType
.
TypeKind
;
}
}
...
...
@@ -188,7 +196,7 @@ public override Symbol ContainingSymbol
{
get
{
return
nul
l
;
return
_underlyingType
.
ContainingSymbo
l
;
}
}
...
...
@@ -229,6 +237,10 @@ internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers, bool ig
{
//PROTOTYPE: rename ignoreDynamic or introduce another "ignoreTuple" flag
// if ignoring dynamic, compare underlying tuple types
if
(
t2
.
IsTupleType
)
{
t2
=
(
t2
as
TupleTypeSymbol
).
UnderlyingTupleType
;
}
return
_underlyingType
.
Equals
(
t2
,
ignoreCustomModifiers
,
ignoreDynamic
);
}
...
...
@@ -280,7 +292,7 @@ public override Accessibility DeclaredAccessibility
{
get
{
return
Accessibility
.
NotApplicable
;
return
_underlyingType
.
DeclaredAccessibility
;
}
}
...
...
@@ -312,7 +324,7 @@ public override int Arity
{
get
{
return
_underlyingType
.
Arity
;
return
0
;
}
}
...
...
@@ -320,7 +332,7 @@ public override ImmutableArray<TypeParameterSymbol> TypeParameters
{
get
{
return
_underlyingType
.
TypeParameters
;
return
ImmutableArray
<
TypeParameterSymbol
>.
Empty
;
}
}
...
...
@@ -328,7 +340,7 @@ internal override ImmutableArray<ImmutableArray<CustomModifier>> TypeArgumentsCu
{
get
{
return
_underlyingType
.
TypeArgumentsCustomModifiers
;
return
ImmutableArray
<
ImmutableArray
<
CustomModifier
>>.
Empty
;
}
}
...
...
@@ -336,7 +348,7 @@ internal override bool HasTypeArgumentsCustomModifiers
{
get
{
return
_underlyingType
.
HasTypeArgumentsCustomModifiers
;
return
false
;
}
}
...
...
@@ -344,7 +356,7 @@ internal override ImmutableArray<TypeSymbol> TypeArgumentsNoUseSiteDiagnostics
{
get
{
return
_underlyingType
.
TypeArgumentsNoUseSiteDiagnostics
;
return
ImmutableArray
<
TypeSymbol
>.
Empty
;
}
}
...
...
@@ -352,7 +364,7 @@ public override NamedTypeSymbol ConstructedFrom
{
get
{
return
_underlyingType
.
ConstructedFrom
;
return
this
;
}
}
...
...
@@ -376,7 +388,7 @@ internal override bool MangleName
{
get
{
return
_underlyingType
.
MangleNam
e
;
return
fals
e
;
}
}
...
...
@@ -392,7 +404,7 @@ internal override bool HasSpecialName
{
get
{
return
_underlyingType
.
HasSpecialNam
e
;
return
fals
e
;
}
}
...
...
@@ -400,7 +412,7 @@ internal override bool IsComImport
{
get
{
return
_underlyingType
.
IsComImport
;
return
false
;
}
}
...
...
@@ -408,7 +420,7 @@ internal override bool IsWindowsRuntimeImport
{
get
{
return
_underlyingType
.
IsWindowsRuntimeImport
;
return
false
;
}
}
...
...
@@ -416,7 +428,7 @@ internal override bool ShouldAddWinRTMembers
{
get
{
return
_underlyingType
.
ShouldAddWinRTMembers
;
return
false
;
}
}
...
...
@@ -456,7 +468,7 @@ internal override bool IsInterface
{
get
{
return
_underlyingType
.
IsInterfac
e
;
return
fals
e
;
}
}
...
...
@@ -488,59 +500,49 @@ internal override bool GetUnificationUseSiteDiagnosticRecursive(ref DiagnosticIn
#
region
ISymbol
Members
public
override
void
Accept
(
SymbolVisitor
visitor
)
{
visitor
.
VisitTupleType
(
this
);
}
public
override
TResult
Accept
<
TResult
>(
SymbolVisitor
<
TResult
>
visitor
)
{
return
visitor
.
VisitTupleType
(
this
);
}
internal
override
AttributeUsageInfo
GetAttributeUsageInfo
()
{
throw
new
NotImplementedException
()
;
return
AttributeUsageInfo
.
Null
;
}
internal
override
ImmutableArray
<
Symbol
>
GetEarlyAttributeDecodingMembers
()
{
throw
new
NotImplementedException
();
return
this
.
GetMembers
();
}
internal
override
ImmutableArray
<
Symbol
>
GetEarlyAttributeDecodingMembers
(
string
name
)
{
throw
new
NotImplementedException
(
);
return
this
.
GetMembers
(
name
);
}
internal
override
NamedTypeSymbol
GetDeclaredBaseType
(
ConsList
<
Symbol
>
basesBeingResolved
)
{
throw
new
NotImplementedException
(
);
return
_underlyingType
.
GetDeclaredBaseType
(
basesBeingResolved
);
}
internal
override
ImmutableArray
<
NamedTypeSymbol
>
GetDeclaredInterfaces
(
ConsList
<
Symbol
>
basesBeingResolved
)
{
throw
new
NotImplementedException
(
);
return
_underlyingType
.
GetDeclaredInterfaces
(
basesBeingResolved
);
}
internal
override
IEnumerable
<
SecurityAttribute
>
GetSecurityInformation
()
{
throw
new
NotImplementedException
()
;
throw
ExceptionUtilities
.
Unreachable
;
}
internal
override
ImmutableArray
<
string
>
GetAppliedConditionalSymbols
()
{
throw
new
NotImplementedException
()
;
return
ImmutableArray
<
string
>.
Empty
;
}
internal
override
IEnumerable
<
FieldSymbol
>
GetFieldsToEmit
()
{
throw
new
NotImplementedException
()
;
throw
ExceptionUtilities
.
Unreachable
;
}
internal
override
ImmutableArray
<
NamedTypeSymbol
>
GetInterfacesToEmit
()
{
throw
new
NotImplementedException
()
;
throw
ExceptionUtilities
.
Unreachable
;
}
#
endregion
...
...
src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -553,6 +553,17 @@ public virtual bool IsAnonymousType
}
}
/// <summary>
/// Is this a symbol for a Tuple
/// </summary>
public
virtual
bool
IsTupleType
{
get
{
return
false
;
}
}
/// <summary>
/// Is this type a managed type (false for everything but enum, pointer, and
/// some struct types).
...
...
src/Compilers/CSharp/Portable/Symbols/TypeSymbolExtensions.cs
浏览文件 @
4d819cea
...
...
@@ -509,7 +509,6 @@ public static TypeSymbol VisitType<T>(this TypeSymbol type, Func<TypeSymbol, T,
case
TypeKind
.
Interface
:
case
TypeKind
.
Enum
:
case
TypeKind
.
Delegate
:
case
TypeKind
.
Tuple
:
foreach
(
var
typeArg
in
((
NamedTypeSymbol
)
current
).
TypeArgumentsNoUseSiteDiagnostics
)
{
var
result
=
typeArg
.
VisitType
(
predicate
,
arg
);
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
4d819cea
...
...
@@ -12,8 +12,6 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests.CodeGen
{
public
class
CodeGenTupleTests
:
CSharpTestBase
{
private
static
readonly
string
trivial2uple
=
@"
...
...
@@ -95,17 +93,17 @@ static void Main()
// Code size 54 (0x36)
.maxstack 5
.locals init (System.Runtime.CompilerServices.ValueTuple<int, string> V_0, //x
System.Runtime.CompilerServices.ValueTuple<int, > V_1)
System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int Item1, int Item2>
> V_1)
IL_0000: ldloca.s V_0
IL_0002: ldc.i4.1
IL_0003: ldc.i4.2
IL_0004: ldc.i4.3
IL_0005: ldc.i4.4
IL_0006: newobj ""System.Runtime.CompilerServices.ValueTuple<int, int>..ctor(int, int)""
IL_000b: newobj ""System.Runtime.CompilerServices.ValueTuple<int,
>..ctor(int,
)""
IL_000b: newobj ""System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int Item1, int Item2>>..ctor(int, <tuple: int Item1, int Item2>
)""
IL_0010: stloc.1
IL_0011: ldloca.s V_1
IL_0013: constrained. ""System.Runtime.CompilerServices.ValueTuple<int, >""
IL_0013: constrained. ""System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int Item1, int Item2>
>""
IL_0019: callvirt ""string object.ToString()""
IL_001e: call ""System.Runtime.CompilerServices.ValueTuple<int, string>..ctor(int, string)""
IL_0023: ldloca.s V_0
...
...
@@ -277,30 +275,30 @@ static void Main()
{
// Code size 87 (0x57)
.maxstack 4
.locals init (System.Runtime.CompilerServices.ValueTuple<int, > V_0) //x
.locals init (System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int c, int d>
> V_0) //x
IL_0000: ldloca.s V_0
IL_0002: ldc.i4.1
IL_0003: ldc.i4.2
IL_0004: ldc.i4.3
IL_0005: newobj ""System.Runtime.CompilerServices.ValueTuple<int, int>..ctor(int, int)""
IL_000a: call ""System.Runtime.CompilerServices.ValueTuple<int,
>..ctor(int,
)""
IL_000a: call ""System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int c, int d>>..ctor(int, <tuple: int c, int d>
)""
IL_000f: ldloca.s V_0
IL_0011: ldflda ""
System.Runtime.CompilerServices.ValueTuple<int,
>.Item2""
IL_0011: ldflda ""
<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>
>.Item2""
IL_0016: ldflda ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item1""
IL_001b: call ""string int.ToString()""
IL_0020: call ""void System.Console.WriteLine(string)""
IL_0025: ldloca.s V_0
IL_0027: ldflda ""
System.Runtime.CompilerServices.ValueTuple<int,
>.Item2""
IL_0027: ldflda ""
<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>
>.Item2""
IL_002c: ldc.i4.s 39
IL_002e: stfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item2""
IL_0033: ldloc.0
IL_0034: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, >.Item1""
IL_0034: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int,
<tuple: int c, int d>
>.Item1""
IL_0039: ldloc.0
IL_003a: ldfld ""
System.Runtime.CompilerServices.ValueTuple<int,
>.Item2""
IL_003a: ldfld ""
<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>
>.Item2""
IL_003f: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item1""
IL_0044: add
IL_0045: ldloc.0
IL_0046: ldfld ""
System.Runtime.CompilerServices.ValueTuple<int,
>.Item2""
IL_0046: ldfld ""
<tuple: int c, int d> System.Runtime.CompilerServices.ValueTuple<int, <tuple: int c, int d>
>.Item2""
IL_004b: ldfld ""int System.Runtime.CompilerServices.ValueTuple<int, int>.Item2""
IL_0050: add
IL_0051: call ""void System.Console.WriteLine(int)""
...
...
src/Compilers/Core/Portable/Symbols/ITypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -64,6 +64,11 @@ public interface ITypeSymbol : INamespaceOrTypeSymbol
/// </summary>
bool
IsAnonymousType
{
get
;
}
/// <summary>
/// Is this a symbol for a tuple .
/// </summary>
bool
IsTupleType
{
get
;
}
/// <summary>
/// The original definition of this symbol. If this symbol is constructed from another
/// symbol by type substitution then <see cref="OriginalDefinition"/> gets the original symbol as it was defined in
...
...
src/Compilers/Core/Portable/Symbols/SymbolKind.cs
浏览文件 @
4d819cea
...
...
@@ -101,10 +101,5 @@ public enum SymbolKind
/// Symbol is a preprocessing/conditional compilation constant.
/// </summary>
Preprocessing
=
18
,
/// <summary>
/// Symbol is a tuple type.
/// </summary>
TupleType
=
19
,
}
}
src/Compilers/Core/Portable/Symbols/SymbolVisitor.cs
浏览文件 @
4d819cea
...
...
@@ -23,11 +23,6 @@ public virtual void VisitArrayType(IArrayTypeSymbol symbol)
DefaultVisit
(
symbol
);
}
public
virtual
void
VisitTupleType
(
ITupleTypeSymbol
symbol
)
{
DefaultVisit
(
symbol
);
}
public
virtual
void
VisitAssembly
(
IAssemblySymbol
symbol
)
{
DefaultVisit
(
symbol
);
...
...
src/Compilers/Core/Portable/Symbols/SymbolVisitor`1.cs
浏览文件 @
4d819cea
...
...
@@ -26,11 +26,6 @@ public virtual TResult VisitArrayType(IArrayTypeSymbol symbol)
return
DefaultVisit
(
symbol
);
}
public
virtual
TResult
VisitTupleType
(
ITupleTypeSymbol
symbol
)
{
return
DefaultVisit
(
symbol
);
}
public
virtual
TResult
VisitAssembly
(
IAssemblySymbol
symbol
)
{
return
DefaultVisit
(
symbol
);
...
...
src/Compilers/Core/Portable/Symbols/TypeKind.cs
浏览文件 @
4d819cea
...
...
@@ -79,10 +79,5 @@ public enum TypeKind : byte
/// Type is an interactive submission.
/// </summary>
Submission
=
12
,
/// <summary>
/// Type is a tuple.
/// </summary>
Tuple
=
13
,
}
}
src/Compilers/VisualBasic/Portable/Symbols/TypeSymbol.vb
浏览文件 @
4d819cea
...
...
@@ -452,6 +452,13 @@ Done:
End
Get
End
Property
Private
ReadOnly
Property
ITypeSymbol_IsTupleSymbol
As
Boolean
Implements
ITypeSymbol
.
IsTupleType
Get
' PROTOTYPE: VB does not yet support tuples.
Return
False
End
Get
End
Property
Private
ReadOnly
Property
ITypeSymbol_TypeKind
As
TypeKind
Implements
ITypeSymbol
.
TypeKind
Get
Return
Me
.
TypeKind
.
ToCommon
()
...
...
src/Features/Core/Portable/MetadataAsSource/AbstractMetadataAsSourceService.WrappedNamedTypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -243,6 +243,14 @@ public bool IsAnonymousType
}
}
public
bool
IsTupleType
{
get
{
return
_symbol
.
IsTupleType
;
}
}
ITypeSymbol
ITypeSymbol
.
OriginalDefinition
{
get
...
...
src/Workspaces/Core/Portable/CodeGeneration/Symbols/CodeGenerationTypeSymbol.cs
浏览文件 @
4d819cea
...
...
@@ -74,6 +74,14 @@ public bool IsAnonymousType
}
}
public
bool
IsTupleType
{
get
{
return
false
;
}
}
public
new
ITypeSymbol
OriginalDefinition
{
get
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录