Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
1da56fdd
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,发现更多精彩内容 >>
未验证
提交
1da56fdd
编写于
7月 03, 2019
作者:
N
Neal Gafter
提交者:
GitHub
7月 03, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use pattern-matching in MetadataWriter for readability and possibly performance. (#36219)
上级
248e3d67
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
39 addition
and
92 deletion
+39
-92
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
+39
-92
未找到文件。
src/Compilers/Core/Portable/PEWriter/MetadataWriter.cs
浏览文件 @
1da56fdd
...
...
@@ -903,8 +903,7 @@ private static GenericParameterAttributes GetGenericParameterAttributes(IGeneric
private
EntityHandle
GetExportedTypeImplementation
(
INamespaceTypeReference
namespaceRef
)
{
IUnitReference
uref
=
namespaceRef
.
GetUnit
(
Context
);
var
aref
=
uref
as
IAssemblyReference
;
if
(
aref
!=
null
)
if
(
uref
is
IAssemblyReference
aref
)
{
return
GetAssemblyReferenceHandle
(
aref
);
}
...
...
@@ -966,8 +965,7 @@ internal EntityHandle GetMemberReferenceParent(ITypeMemberReference memberRef)
return
parentTypeDefHandle
;
}
IMethodReference
methodRef
=
memberRef
as
IMethodReference
;
if
(
methodRef
!=
null
)
if
(
memberRef
is
IMethodReference
methodRef
)
{
if
(
methodRef
.
AcceptsExtraArguments
)
{
...
...
@@ -1117,19 +1115,12 @@ private BlobHandle GetMarshallingDescriptorHandle(ImmutableArray<byte> descripto
private
BlobHandle
GetMemberReferenceSignatureHandle
(
ITypeMemberReference
memberRef
)
{
IFieldReference
fieldReference
=
memberRef
as
IFieldReference
;
if
(
fieldReference
!=
null
)
return
memberRef
switch
{
return
this
.
GetFieldSignatureIndex
(
fieldReference
);
}
IMethodReference
methodReference
=
memberRef
as
IMethodReference
;
if
(
methodReference
!=
null
)
{
return
this
.
GetMethodSignatureHandle
(
methodReference
);
}
throw
ExceptionUtilities
.
Unreachable
;
IFieldReference
fieldReference
=>
this
.
GetFieldSignatureIndex
(
fieldReference
),
IMethodReference
methodReference
=>
this
.
GetMethodSignatureHandle
(
methodReference
),
_
=>
throw
ExceptionUtilities
.
Unreachable
};
}
internal
BlobHandle
GetMethodSignatureHandle
(
IMethodReference
methodReference
)
...
...
@@ -1311,8 +1302,7 @@ private BlobHandle GetPropertySignatureHandle(IPropertyDefinition propertyDef)
private
EntityHandle
GetResolutionScopeHandle
(
IUnitReference
unitReference
)
{
var
aref
=
unitReference
as
IAssemblyReference
;
if
(
aref
!=
null
)
if
(
unitReference
is
IAssemblyReference
aref
)
{
return
GetAssemblyReferenceHandle
(
aref
);
}
...
...
@@ -1680,37 +1670,15 @@ internal EntityHandle GetTypeHandle(ITypeReference typeReference, bool treatRefA
internal
EntityHandle
GetDefinitionHandle
(
IDefinition
definition
)
{
ITypeDefinition
typeDef
=
definition
as
ITypeDefinition
;
if
(
typeDef
!=
null
)
{
return
GetTypeDefinitionHandle
(
typeDef
);
}
IMethodDefinition
methodDef
=
definition
as
IMethodDefinition
;
if
(
methodDef
!=
null
)
{
return
GetMethodDefinitionHandle
(
methodDef
);
}
IFieldDefinition
fieldDef
=
definition
as
IFieldDefinition
;
if
(
fieldDef
!=
null
)
{
return
GetFieldDefinitionHandle
(
fieldDef
);
}
IEventDefinition
eventDef
=
definition
as
IEventDefinition
;
if
(
eventDef
!=
null
)
return
definition
switch
{
return
GetEventDefinitionHandle
(
eventDef
);
}
IPropertyDefinition
propertyDef
=
definition
as
IPropertyDefinition
;
if
(
propertyDef
!=
null
)
{
return
GetPropertyDefIndex
(
propertyDef
);
}
throw
ExceptionUtilities
.
Unreachable
;
ITypeDefinition
typeDef
=>
(
EntityHandle
)
GetTypeDefinitionHandle
(
typeDef
),
IMethodDefinition
methodDef
=>
GetMethodDefinitionHandle
(
methodDef
),
IFieldDefinition
fieldDef
=>
GetFieldDefinitionHandle
(
fieldDef
),
IEventDefinition
eventDef
=>
GetEventDefinitionHandle
(
eventDef
),
IPropertyDefinition
propertyDef
=>
GetPropertyDefIndex
(
propertyDef
),
_
=>
throw
ExceptionUtilities
.
Unreachable
};
}
public
void
WriteMetadataAndIL
(
PdbWriter
nativePdbWriterOpt
,
Stream
metadataStream
,
Stream
ilStream
,
Stream
portablePdbStreamOpt
,
out
MetadataSizes
metadataSizes
)
...
...
@@ -3058,25 +3026,13 @@ private static int ReadInt32(ImmutableArray<byte> buffer, int pos)
private
EntityHandle
GetHandle
(
IReference
reference
)
{
var
typeReference
=
reference
as
ITypeReference
;
if
(
typeReference
!=
null
)
{
return
GetTypeHandle
(
typeReference
);
}
var
fieldReference
=
reference
as
IFieldReference
;
if
(
fieldReference
!=
null
)
{
return
GetFieldHandle
(
fieldReference
);
}
var
methodReference
=
reference
as
IMethodReference
;
if
(
methodReference
!=
null
)
return
reference
switch
{
return
GetMethodHandle
(
methodReference
);
}
throw
ExceptionUtilities
.
UnexpectedValue
(
reference
);
ITypeReference
typeReference
=>
GetTypeHandle
(
typeReference
),
IFieldReference
fieldReference
=>
GetFieldHandle
(
fieldReference
),
IMethodReference
methodReference
=>
GetMethodHandle
(
methodReference
),
_
=>
throw
ExceptionUtilities
.
UnexpectedValue
(
reference
)
};
}
private
EntityHandle
ResolveEntityHandleFromPseudoToken
(
int
pseudoSymbolToken
)
...
...
@@ -3391,8 +3347,7 @@ private void SerializeCustomAttributeNamedArguments(NamedArgumentsEncoder encode
private
void
SerializeNamedArgumentType
(
NamedArgumentTypeEncoder
encoder
,
ITypeReference
type
)
{
var
arrayType
=
type
as
IArrayTypeReference
;
if
(
arrayType
!=
null
)
if
(
type
is
IArrayTypeReference
arrayType
)
{
SerializeCustomAttributeArrayType
(
encoder
.
SZArray
(),
arrayType
);
}
...
...
@@ -3408,14 +3363,11 @@ private void SerializeNamedArgumentType(NamedArgumentTypeEncoder encoder, ITypeR
private
void
SerializeMetadataExpression
(
LiteralEncoder
encoder
,
IMetadataExpression
expression
,
ITypeReference
targetType
)
{
var
a
=
expression
as
MetadataCreateArray
;
if
(
a
!=
null
)
if
(
expression
is
MetadataCreateArray
a
)
{
ITypeReference
targetElementType
;
var
targetArrayType
=
targetType
as
IArrayTypeReference
;
VectorEncoder
vectorEncoder
;
if
(
targetArrayType
==
null
)
if
(
!(
targetType
is
IArrayTypeReference
targetArrayType
)
)
{
// implicit conversion from array to object
Debug
.
Assert
(
this
.
module
.
IsPlatformType
(
targetType
,
PlatformType
.
SystemObject
));
...
...
@@ -3507,18 +3459,17 @@ private void SerializeMarshallingDescriptor(IMarshallingInformation marshallingI
writer
.
WriteUInt16
(
0
);
// padding
object
marshaller
=
marshallingInformation
.
GetCustomMarshaller
(
Context
);
ITypeReference
marshallerTypeRef
=
marshaller
as
ITypeReference
;
if
(
marshallerTypeRef
!=
null
)
switch
(
marshaller
)
{
this
.
SerializeTypeName
(
marshallerTypeRef
,
writer
);
}
else
if
(
marshaller
!=
null
)
{
writer
.
WriteSerializedString
((
string
)
marshaller
);
}
else
{
writer
.
WriteByte
(
0
)
;
case
ITypeReference
marshallerTypeRef
:
this
.
SerializeTypeName
(
marshallerTypeRef
,
writer
);
break
;
case
null
:
writer
.
WriteByte
(
0
);
break
;
default
:
writer
.
WriteSerializedString
((
string
)
marshaller
);
break
;
}
var
arg
=
marshallingInformation
.
CustomMarshallerRuntimeArgument
;
...
...
@@ -3648,8 +3599,7 @@ private void SerializePermissionSet(ImmutableArray<ICustomAttribute> permissionS
if
(!
isAssemblyQualified
)
{
INamespaceTypeReference
namespaceType
=
customAttribute
.
GetType
(
context
).
AsNamespaceTypeReference
;
var
referencedAssembly
=
namespaceType
?.
GetUnit
(
context
)
as
IAssemblyReference
;
if
(
referencedAssembly
!=
null
)
if
(
namespaceType
?.
GetUnit
(
context
)
is
IAssemblyReference
referencedAssembly
)
{
typeName
=
typeName
+
", "
+
StrongName
(
referencedAssembly
);
}
...
...
@@ -3725,8 +3675,7 @@ private void SerializeTypeReference(SignatureTypeEncoder encoder, ITypeReference
// TYPEDREF is only allowed in RetType, Param, LocalVarSig signatures
Debug
.
Assert
(!
module
.
IsPlatformType
(
typeReference
,
PlatformType
.
SystemTypedReference
));
var
modifiedTypeReference
=
typeReference
as
IModifiedTypeReference
;
if
(
modifiedTypeReference
!=
null
)
if
(
typeReference
is
IModifiedTypeReference
modifiedTypeReference
)
{
SerializeCustomModifiers
(
encoder
.
CustomModifiers
(),
modifiedTypeReference
.
CustomModifiers
);
typeReference
=
modifiedTypeReference
.
UnmodifiedType
;
...
...
@@ -3740,8 +3689,7 @@ private void SerializeTypeReference(SignatureTypeEncoder encoder, ITypeReference
return
;
}
var
pointerTypeReference
=
typeReference
as
IPointerTypeReference
;
if
(
pointerTypeReference
!=
null
)
if
(
typeReference
is
IPointerTypeReference
pointerTypeReference
)
{
typeReference
=
pointerTypeReference
.
GetTargetType
(
Context
);
encoder
=
encoder
.
Pointer
();
...
...
@@ -3757,8 +3705,7 @@ private void SerializeTypeReference(SignatureTypeEncoder encoder, ITypeReference
return
;
}
var
arrayTypeReference
=
typeReference
as
IArrayTypeReference
;
if
(
arrayTypeReference
!=
null
)
if
(
typeReference
is
IArrayTypeReference
arrayTypeReference
)
{
typeReference
=
arrayTypeReference
.
GetElementType
(
Context
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录