Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
ce88d76b
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,发现更多精彩内容 >>
提交
ce88d76b
编写于
10月 24, 2016
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes: #14708
Fixes: #14709
上级
039a7978
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
127 addition
and
11 deletion
+127
-11
src/Compilers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
...ers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
+5
-5
src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs
...ilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
...s/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs
...p/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs
+1
-1
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
...rs/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
+1
-1
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
+118
-2
未找到文件。
src/Compilers/CSharp/Portable/Symbols/Source/CustomModifierUtils.cs
浏览文件 @
ce88d76b
...
...
@@ -48,24 +48,24 @@ internal static class CustomModifierUtils
TypeSymbol
returnTypeWithCustomModifiers
=
constructedSourceMethod
.
ReturnType
;
if
(
returnType
.
Equals
(
returnTypeWithCustomModifiers
,
TypeCompareKind
.
AllIgnoreOptions
))
{
returnType
=
CopyTypeCustomModifiers
(
returnTypeWithCustomModifiers
,
returnType
,
RefKind
.
None
,
destinationMethod
.
ContainingAssembly
);
returnType
=
CopyTypeCustomModifiers
(
returnTypeWithCustomModifiers
,
returnType
,
destinationMethod
.
ContainingAssembly
);
}
}
/// <param name="sourceType">Type that already has custom modifiers.</param>
/// <param name="destinationType">Same as <paramref name="sourceType"/>, but without custom modifiers. May differ in object/dynamic.</param>
/// <param name="refKind"><see cref="RefKind"/> of the parameter of which this is the type (or <see cref="RefKind.None"/> for a return type.</param>
/// <param name="containingAssembly">The assembly containing the signature referring to the destination type.</param>
/// <returns><paramref name="destinationType"/> with custom modifiers copied from <paramref name="sourceType"/>.</returns>
internal
static
TypeSymbol
CopyTypeCustomModifiers
(
TypeSymbol
sourceType
,
TypeSymbol
destinationType
,
RefKind
refKind
,
AssemblySymbol
containingAssembly
)
internal
static
TypeSymbol
CopyTypeCustomModifiers
(
TypeSymbol
sourceType
,
TypeSymbol
destinationType
,
AssemblySymbol
containingAssembly
)
{
Debug
.
Assert
(
sourceType
.
Equals
(
destinationType
,
TypeCompareKind
.
AllIgnoreOptions
));
// NOTE: overrides can differ by object/dynamic. If they do, we'll need to tweak newType before
// we can use it in place of this.Type. We do so by computing the dynamic transform flags that
// code gen uses and then passing them to the dynamic type decoder that metadata reading uses.
ImmutableArray
<
bool
>
flags
=
CSharpCompilation
.
DynamicTransformsEncoder
.
EncodeWithoutCustomModifierFlags
(
destinationType
,
refKind
);
TypeSymbol
typeWithDynamic
=
DynamicTypeDecoder
.
TransformTypeWithoutCustomModifierFlags
(
sourceType
,
containingAssembly
,
refKind
,
flags
);
// NOTE: ref is irrelevant here since we are just encoding/decoding the type out of the signature context
ImmutableArray
<
bool
>
flags
=
CSharpCompilation
.
DynamicTransformsEncoder
.
EncodeWithoutCustomModifierFlags
(
destinationType
,
RefKind
.
None
);
TypeSymbol
typeWithDynamic
=
DynamicTypeDecoder
.
TransformTypeWithoutCustomModifierFlags
(
sourceType
,
containingAssembly
,
RefKind
.
None
,
flags
);
TypeSymbol
resultType
;
if
(
destinationType
.
ContainsTuple
()
&&
!
sourceType
.
Equals
(
destinationType
,
TypeCompareKind
.
IgnoreCustomModifiersAndArraySizesAndLowerBounds
|
TypeCompareKind
.
IgnoreDynamic
))
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs
浏览文件 @
ce88d76b
...
...
@@ -533,7 +533,7 @@ protected static void CopyEventCustomModifiers(EventSymbol eventWithCustomModifi
// we want to retain the original (incorrect) type to avoid hiding the type given in source.
if
(
type
.
Equals
(
overriddenEventType
,
TypeCompareKind
.
IgnoreCustomModifiersAndArraySizesAndLowerBounds
|
TypeCompareKind
.
IgnoreDynamic
))
{
type
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
overriddenEventType
,
type
,
RefKind
.
None
,
containingAssembly
);
type
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
overriddenEventType
,
type
,
containingAssembly
);
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourceParameterSymbol.cs
浏览文件 @
ce88d76b
...
...
@@ -113,7 +113,7 @@ internal override ParameterSymbol WithCustomModifiersAndParams(TypeSymbol newTyp
internal
SourceParameterSymbol
WithCustomModifiersAndParamsCore
(
TypeSymbol
newType
,
ImmutableArray
<
CustomModifier
>
newCustomModifiers
,
ushort
countOfCustomModifiersPrecedingByRef
,
bool
newIsParams
)
{
newType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
newType
,
this
.
Type
,
_refKind
,
this
.
ContainingAssembly
);
newType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
newType
,
this
.
Type
,
this
.
ContainingAssembly
);
if
(
newCustomModifiers
.
IsDefaultOrEmpty
)
{
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertyAccessorSymbol.cs
浏览文件 @
ce88d76b
...
...
@@ -281,7 +281,7 @@ protected override void MethodChecks(DiagnosticBag diagnostics)
else
if
(
_lazyReturnType
.
SpecialType
!=
SpecialType
.
System_Void
)
{
PropertySymbol
associatedProperty
=
_property
;
_lazyReturnType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
associatedProperty
.
Type
,
_lazyReturnType
,
RefKind
.
None
,
this
.
ContainingAssembly
);
_lazyReturnType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
associatedProperty
.
Type
,
_lazyReturnType
,
this
.
ContainingAssembly
);
_lazyReturnTypeCustomModifiers
=
associatedProperty
.
TypeCustomModifiers
;
}
}
...
...
src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs
浏览文件 @
ce88d76b
...
...
@@ -245,7 +245,7 @@ internal sealed class SourcePropertySymbol : PropertySymbol, IAttributeTargetSym
// we want to retain the original (incorrect) type to avoid hiding the type given in source.
if
(
_lazyType
.
Equals
(
overriddenPropertyType
,
TypeCompareKind
.
IgnoreCustomModifiersAndArraySizesAndLowerBounds
|
TypeCompareKind
.
IgnoreDynamic
))
{
_lazyType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
overriddenPropertyType
,
_lazyType
,
RefKind
.
None
,
this
.
ContainingAssembly
);
_lazyType
=
CustomModifierUtils
.
CopyTypeCustomModifiers
(
overriddenPropertyType
,
_lazyType
,
this
.
ContainingAssembly
);
}
_lazyParameters
=
CustomModifierUtils
.
CopyParameterCustomModifiers
(
overriddenOrImplementedProperty
.
Parameters
,
_lazyParameters
,
alsoCopyParamsModifier
:
isOverride
);
...
...
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTupleTest.cs
浏览文件 @
ce88d76b
...
...
@@ -19385,8 +19385,10 @@ public class B1
comp1.VerifyDiagnostics();
}
[WorkItem(14708, "https://github.com/dotnet/roslyn/issues/14708")]
[WorkItem(14709, "https://github.com/dotnet/roslyn/issues/14709")]
[Fact]
public void Re
gress
001()
public void Re
fTupleDynamicDecode
001()
{
string lib = @"
...
...
@@ -19431,8 +19433,10 @@ public override ref (int, object) Foo(int arg)
var comp = CompileAndVerify(source, expectedOutput: "42qq", additionalRefs: new[] { libComp.ToMetadataReference() }.Concat(s_valueTupleRefs), options: TestOptions.DebugExe, verify: false);
}
[WorkItem(14708, "https://github.com/dotnet/roslyn/issues/14708")]
[WorkItem(14709, "https://github.com/dotnet/roslyn/issues/14709")]
[Fact]
public void Re
gress
002()
public void Re
fTupleDynamicDecode
002()
{
string lib = @"
...
...
@@ -19721,5 +19725,117 @@ struct BB<T>
--
--");
}
[WorkItem(14708, "https://github.com/dotnet/roslyn/issues/14708")]
[WorkItem(14709, "https://github.com/dotnet/roslyn/issues/14709")]
[Fact]
public void RefTupleDynamicDecode003()
{
string lib = @"
// Metadata version: v4.0.30319
.assembly extern mscorlib
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System.Core
{
.publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
.ver 4:0:0:0
}
.assembly extern System.ValueTuple
{
.publickeytoken = (CC 7B 13 FF CD 2D DD 51 ) // .{...-.Q
.ver 4:0:1:0
}
// =============== CLASS MEMBERS DECLARATION ===================
.class public auto ansi beforefieldinit ClassLibrary1.C1
extends [mscorlib]System.Object
{
.method public hidebysig newslot virtual
instance valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>&
Foo(int32 arg) cil managed
{
.param [0]
// the dynamic flags array is too short - decoder expects a flag matching ""ref"", but it is missing here.
.custom instance void [System.Core]System.Runtime.CompilerServices.DynamicAttribute::.ctor(bool[]) = ( 01 00 03 00 00 00 00 00 01 00 00 )
// Code size 37 (0x25)
.maxstack 5
.locals init (valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>& V_0)
IL_0000: nop
IL_0001: ldc.i4.1
IL_0002: newarr valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>
IL_0007: dup
IL_0008: ldc.i4.0
IL_0009: ldc.i4.1
IL_000a: ldarg.1
IL_000b: box [mscorlib]System.Int32
IL_0010: newobj instance void valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>::.ctor(!0,
!1)
IL_0015: stelem valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>
IL_001a: ldc.i4.0
IL_001b: ldelema valuetype [System.ValueTuple]System.ValueTuple`2<int32,object>
IL_0020: stloc.0
IL_0021: br.s IL_0023
IL_0023: ldloc.0
IL_0024: ret
} // end of method C1::Foo
.method public hidebysig specialname rtspecialname
instance void .ctor() cil managed
{
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
} // end of method C1::.ctor
} // end of class ClassLibrary1.C1
";
var libCompRef = CompileIL(lib);
var source = @"
namespace ConsoleApplication5
{
class Program
{
static void Main(string[] args)
{
ref var x = ref new C2().Foo(42);
System.Console.Write(x.Item2);
x.Item2 = ""qq"";
System.Console.WriteLine(x.Item2);
}
}
class C2: ClassLibrary1.C1
{
public override ref (int, dynamic) Foo(int arg)
{
return ref base.Foo(arg);
}
}
}
";
var comp = CreateCompilationWithMscorlib45AndCSruntime(source, additionalRefs: new[] { libCompRef }.Concat(s_valueTupleRefs).ToArray(), options: TestOptions.DebugExe);
CompileAndVerify(comp, expectedOutput: "42qq", verify: false);
var m = (MethodSymbol)(comp.GetTypeByMetadataName("ConsoleApplication5.C2").GetMembers("Foo").First());
Assert.Equal("ref (System.Int32, dynamic) ConsoleApplication5.C2.Foo(System.Int32 arg)", m.ToTestDisplayString());
var b = m.OverriddenMethod;
// not (int, dynamic),
// since dynamic flags were not aligned we ignored flags
Assert.Equal("ref (System.Int32, System.Object) ClassLibrary1.C1.Foo(System.Int32 arg)", b.ToTestDisplayString());
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录