Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
46fe6e49
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,发现更多精彩内容 >>
提交
46fe6e49
编写于
5月 03, 2017
作者:
T
Tomáš Matoušek
提交者:
GitHub
5月 03, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19104 from tmat/Tests
Add a couple of tests
上级
46434d9d
7f1aee3b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
159 addition
and
0 deletion
+159
-0
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
+137
-0
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
...onEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
+22
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/PDB/PDBTests.cs
浏览文件 @
46fe6e49
...
...
@@ -2657,6 +2657,142 @@ static void Main(string[] args)
</symbols>"
);
}
[
Fact
]
public
void
ForEachStatement_Deconstruction
()
{
var
source
=
@"
public class C
{
public static (int, (bool, double))[] F() => new[] { (1, (true, 2.0)) };
public static void Main()
{
foreach (var (c, (d, e)) in F())
{
System.Console.WriteLine(c);
}
}
}
"
;
var
c
=
CreateStandardCompilation
(
source
,
new
[]
{
ValueTupleRef
,
SystemRuntimeFacadeRef
},
options
:
TestOptions
.
DebugDll
);
var
v
=
CompileAndVerify
(
c
);
v
.
VerifyIL
(
"C.Main"
,
@"
{
// Code size 72 (0x48)
.maxstack 2
.locals init ((int, (bool, double))[] V_0,
int V_1,
int V_2, //c
bool V_3, //d
double V_4, //e
System.ValueTuple<bool, double> V_5)
// sequence point: {
IL_0000: nop
// sequence point: foreach
IL_0001: nop
// sequence point: F()
IL_0002: call ""(int, (bool, double))[] C.F()""
IL_0007: stloc.0
IL_0008: ldc.i4.0
IL_0009: stloc.1
// sequence point: <hidden>
IL_000a: br.s IL_0041
// sequence point: var (c, (d, e))
IL_000c: ldloc.0
IL_000d: ldloc.1
IL_000e: ldelem ""System.ValueTuple<int, (bool, double)>""
IL_0013: dup
IL_0014: ldfld ""(bool, double) System.ValueTuple<int, (bool, double)>.Item2""
IL_0019: stloc.s V_5
IL_001b: dup
IL_001c: ldfld ""int System.ValueTuple<int, (bool, double)>.Item1""
IL_0021: stloc.2
IL_0022: ldloc.s V_5
IL_0024: ldfld ""bool System.ValueTuple<bool, double>.Item1""
IL_0029: stloc.3
IL_002a: ldloc.s V_5
IL_002c: ldfld ""double System.ValueTuple<bool, double>.Item2""
IL_0031: stloc.s V_4
IL_0033: pop
// sequence point: {
IL_0034: nop
// sequence point: System.Console.WriteLine(c);
IL_0035: ldloc.2
IL_0036: call ""void System.Console.WriteLine(int)""
IL_003b: nop
// sequence point: }
IL_003c: nop
// sequence point: <hidden>
IL_003d: ldloc.1
IL_003e: ldc.i4.1
IL_003f: add
IL_0040: stloc.1
// sequence point: in
IL_0041: ldloc.1
IL_0042: ldloc.0
IL_0043: ldlen
IL_0044: conv.i4
IL_0045: blt.s IL_000c
// sequence point: }
IL_0047: ret
}
"
,
sequencePoints
:
"C.Main"
,
source
:
source
);
v
.
VerifyPdb
(
@"
<symbols>
<methods>
<method containingType=""C"" name=""F"">
<customDebugInfo>
<using>
<namespace usingCount=""0"" />
</using>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""4"" startColumn=""50"" endLine=""4"" endColumn=""76"" />
</sequencePoints>
</method>
<method containingType=""C"" name=""Main"">
<customDebugInfo>
<forward declaringType=""C"" methodName=""F"" />
<encLocalSlotMap>
<slot kind=""6"" offset=""11"" />
<slot kind=""8"" offset=""11"" />
<slot kind=""0"" offset=""25"" />
<slot kind=""0"" offset=""29"" />
<slot kind=""0"" offset=""32"" />
<slot kind=""temp"" />
</encLocalSlotMap>
</customDebugInfo>
<sequencePoints>
<entry offset=""0x0"" startLine=""7"" startColumn=""5"" endLine=""7"" endColumn=""6"" />
<entry offset=""0x1"" startLine=""8"" startColumn=""9"" endLine=""8"" endColumn=""16"" />
<entry offset=""0x2"" startLine=""8"" startColumn=""37"" endLine=""8"" endColumn=""40"" />
<entry offset=""0xa"" hidden=""true"" />
<entry offset=""0xc"" startLine=""8"" startColumn=""18"" endLine=""8"" endColumn=""33"" />
<entry offset=""0x34"" startLine=""9"" startColumn=""9"" endLine=""9"" endColumn=""10"" />
<entry offset=""0x35"" startLine=""10"" startColumn=""13"" endLine=""10"" endColumn=""41"" />
<entry offset=""0x3c"" startLine=""11"" startColumn=""9"" endLine=""11"" endColumn=""10"" />
<entry offset=""0x3d"" hidden=""true"" />
<entry offset=""0x41"" startLine=""8"" startColumn=""34"" endLine=""8"" endColumn=""36"" />
<entry offset=""0x47"" startLine=""12"" startColumn=""5"" endLine=""12"" endColumn=""6"" />
</sequencePoints>
<scope startOffset=""0x0"" endOffset=""0x48"">
<scope startOffset=""0xc"" endOffset=""0x3d"">
<local name=""c"" il_index=""2"" il_start=""0xc"" il_end=""0x3d"" attributes=""0"" />
<local name=""d"" il_index=""3"" il_start=""0xc"" il_end=""0x3d"" attributes=""0"" />
<local name=""e"" il_index=""4"" il_start=""0xc"" il_end=""0x3d"" attributes=""0"" />
</scope>
</scope>
</method>
</methods>
</symbols>"
);
}
#
endregion
#
region
Switch
[
Fact
]
public
void
SwitchWithPattern_01
()
...
...
@@ -2843,6 +2979,7 @@ class Student : Person { public double GPA; }
</symbols>"
);
}
#
endregion
#
region
DoStatement
...
...
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
浏览文件 @
46fe6e49
...
...
@@ -1452,6 +1452,28 @@ .maxstack 1
});
}
[
Fact
(
Skip
=
"18273"
),
WorkItem
(
18273
,
"https://github.com/dotnet/roslyn/issues/18273"
)]
public
void
CapturedLocalInNestedLambda
()
{
var
source
=
@"
using System;
class C
{
void M() { }
}"
;
var
compilation0
=
CreateStandardCompilation
(
source
,
options
:
TestOptions
.
DebugDll
);
WithRuntimeInstance
(
compilation0
,
runtime
=>
{
var
context
=
CreateMethodContext
(
runtime
,
"C.M"
);
var
testData
=
new
CompilationTestData
();
context
.
CompileExpression
(
"new Action(() => { int x; new Func<int>(() => x).Invoke(); }).Invoke()"
,
out
var
error
,
testData
);
Assert
.
Null
(
error
);
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
""
);
});
}
[
Fact
]
public
void
NestedLambdas
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录