Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
c296452d
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,发现更多精彩内容 >>
提交
c296452d
编写于
10月 14, 2015
作者:
V
VSadov
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5901 from VSadov/AddTest001
Added a regression test as in repro for #5880
上级
9cdb1c13
8d402b3d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
129 addition
and
0 deletion
+129
-0
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
+129
-0
未找到文件。
src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenTests.cs
浏览文件 @
c296452d
...
...
@@ -14698,5 +14698,134 @@ .maxstack 3
"
);
}
[
WorkItem
(
5880
,
"https://github.com/dotnet/roslyn/issues/5880"
)]
[
Fact
]
public
void
StuctCtorArgTernary
()
{
string
source
=
@"
using System.Collections.Generic;
using System;
class Program
{
struct TextSpan
{
private int start;
private int length;
public int Start => start;
public int End => start + length;
public int Length => length;
public TextSpan(int start, int length)
{
this.start = start;
this.length = length;
}
}
static void Main(string[] args)
{
int length = 123;
int start = 5;
var list = new List<TextSpan>(10);
list.Add(new TextSpan(0, 10));
list.Add(new TextSpan(0, 10));
for (int i = 0; i < list.Count; i++)
{
var span = list[i];
if (span.End < start)
{
continue;
}
var newStart = Math.Min(Math.Max(span.Start + 10, 0), length);
var newSpan = new TextSpan(newStart, newStart >= length ? 0 : span.Length);
list[i] = newSpan;
}
}
}
"
;
var
compilation
=
CompileAndVerify
(
source
,
expectedOutput
:
""
);
compilation
.
VerifyIL
(
"Program.Main"
,
@"
{
// Code size 135 (0x87)
.maxstack 4
.locals init (int V_0, //length
int V_1, //start
System.Collections.Generic.List<Program.TextSpan> V_2, //list
int V_3, //i
Program.TextSpan V_4, //span
int V_5, //newStart
Program.TextSpan V_6) //newSpan
IL_0000: ldc.i4.s 123
IL_0002: stloc.0
IL_0003: ldc.i4.5
IL_0004: stloc.1
IL_0005: ldc.i4.s 10
IL_0007: newobj ""System.Collections.Generic.List<Program.TextSpan>..ctor(int)""
IL_000c: stloc.2
IL_000d: ldloc.2
IL_000e: ldc.i4.0
IL_000f: ldc.i4.s 10
IL_0011: newobj ""Program.TextSpan..ctor(int, int)""
IL_0016: callvirt ""void System.Collections.Generic.List<Program.TextSpan>.Add(Program.TextSpan)""
IL_001b: ldloc.2
IL_001c: ldc.i4.0
IL_001d: ldc.i4.s 10
IL_001f: newobj ""Program.TextSpan..ctor(int, int)""
IL_0024: callvirt ""void System.Collections.Generic.List<Program.TextSpan>.Add(Program.TextSpan)""
IL_0029: ldc.i4.0
IL_002a: stloc.3
IL_002b: br.s IL_007d
IL_002d: ldloc.2
IL_002e: ldloc.3
IL_002f: callvirt ""Program.TextSpan System.Collections.Generic.List<Program.TextSpan>.this[int].get""
IL_0034: stloc.s V_4
IL_0036: ldloca.s V_4
IL_0038: call ""int Program.TextSpan.End.get""
IL_003d: ldloc.1
IL_003e: blt.s IL_0079
IL_0040: ldloca.s V_4
IL_0042: call ""int Program.TextSpan.Start.get""
IL_0047: ldc.i4.s 10
IL_0049: add
IL_004a: ldc.i4.0
IL_004b: call ""int System.Math.Max(int, int)""
IL_0050: ldloc.0
IL_0051: call ""int System.Math.Min(int, int)""
IL_0056: stloc.s V_5
IL_0058: ldloca.s V_6
IL_005a: ldloc.s V_5
IL_005c: ldloc.s V_5
IL_005e: ldloc.0
IL_005f: bge.s IL_006a
IL_0061: ldloca.s V_4
IL_0063: call ""int Program.TextSpan.Length.get""
IL_0068: br.s IL_006b
IL_006a: ldc.i4.0
IL_006b: call ""Program.TextSpan..ctor(int, int)""
IL_0070: ldloc.2
IL_0071: ldloc.3
IL_0072: ldloc.s V_6
IL_0074: callvirt ""void System.Collections.Generic.List<Program.TextSpan>.this[int].set""
IL_0079: ldloc.3
IL_007a: ldc.i4.1
IL_007b: add
IL_007c: stloc.3
IL_007d: ldloc.3
IL_007e: ldloc.2
IL_007f: callvirt ""int System.Collections.Generic.List<Program.TextSpan>.Count.get""
IL_0084: blt.s IL_002d
IL_0086: ret
}"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录