Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
d1fc6e65
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,发现更多精彩内容 >>
提交
d1fc6e65
编写于
6月 02, 2015
作者:
A
Andrew Casey
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3236 from amcasey/GH3231
Loosen check in CapturedVariableRewriter.RewriteParameter
上级
1d61936d
cbc056c9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
103 addition
and
1 deletion
+103
-1
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs
.../ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs
+1
-1
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
...onEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
+53
-0
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
...luator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
+49
-0
未找到文件。
src/ExpressionEvaluator/CSharp/Source/ExpressionCompiler/Rewriters/CapturedVariableRewriter.cs
浏览文件 @
d1fc6e65
...
...
@@ -140,7 +140,7 @@ private BoundExpression RewriteParameter(CSharpSyntaxNode syntax, ParameterSymbo
{
var
typeNameKind
=
GeneratedNames
.
GetKind
(
symbol
.
Type
.
Name
);
if
(
typeNameKind
!=
GeneratedNameKind
.
None
&&
GeneratedNames
.
GetKind
(
symbol
.
Name
)
!=
GeneratedNameKind
.
TransparentIdentifier
)
typeNameKind
!=
GeneratedNameKind
.
AnonymousType
)
{
// The state machine case is for async lambdas. The state machine
// will have a hoisted "this" field if it needs to access the
...
...
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/LocalsTests.cs
浏览文件 @
d1fc6e65
...
...
@@ -2963,6 +2963,59 @@ .maxstack 1
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
yIL
);
}
[
WorkItem
(
3236
,
"https://github.com/dotnet/roslyn/pull/3236"
)]
[
Fact
]
public
void
AnonymousTypeParameter
()
{
const
string
source
=
@"
using System.Linq;
class C
{
static void Main(string[] args)
{
var anonymousTypes =
from a in args
select new { Value = a, Length = a.Length };
var values =
from t in anonymousTypes
select t.Value;
}
}
"
;
const
string
methodName
=
"C.<>c.<Main>b__0_1"
;
const
string
tIL
=
@"
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.1
IL_0001: ret
}
"
;
var
comp
=
CreateCompilationWithMscorlib
(
source
,
new
[]
{
SystemCoreRef
},
TestOptions
.
DebugDll
);
var
runtime
=
CreateRuntimeInstance
(
comp
);
string
typeName
;
var
locals
=
ArrayBuilder
<
LocalAndMethod
>.
GetInstance
();
CompilationTestData
testData
;
GetLocals
(
runtime
,
methodName
,
argumentsOnly
:
false
,
locals
:
locals
,
count
:
1
,
typeName
:
out
typeName
,
testData
:
out
testData
);
VerifyLocal
(
testData
,
typeName
,
locals
[
0
],
"<>m0"
,
"t"
,
expectedILOpt
:
tIL
);
locals
.
Free
();
var
context
=
CreateMethodContext
(
runtime
,
methodName
);
string
error
;
testData
=
new
CompilationTestData
();
context
.
CompileExpression
(
"t"
,
out
error
,
testData
);
Assert
.
Null
(
error
);
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
tIL
);
}
private
static
void
GetLocals
(
RuntimeInstance
runtime
,
string
methodName
,
bool
argumentsOnly
,
ArrayBuilder
<
LocalAndMethod
>
locals
,
int
count
,
out
string
typeName
,
out
CompilationTestData
testData
)
{
var
context
=
CreateMethodContext
(
runtime
,
methodName
);
...
...
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/LocalsTests.vb
浏览文件 @
d1fc6e65
...
...
@@ -3145,6 +3145,55 @@ End Class
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
xIL
)
End
Sub
<
WorkItem
(
3236
,
"https://github.com/dotnet/roslyn/pull/3236"
)
>
<
Fact
>
Public
Sub
AnonymousTypeParameter
()
Const
source
=
"
Imports System.Linq
Class C
Shared Sub Main(args As String())
Dim anonymousTypes =
From a In args
Select New With {.Value = a, .Length = a.Length}
Dim values =
From t In anonymousTypes
Select t.Value
End Sub
End Class
"
Const
methodName
=
"C._Closure$__._Lambda$__1-1"
Const
xIL
=
"
{
// Code size 2 (0x2)
.maxstack 1
IL_0000: ldarg.1
IL_0001: ret
}
"
Dim
comp
=
CreateCompilationWithMscorlib
({
source
},
{
SystemCoreRef
,
MsvbRef
},
TestOptions
.
DebugDll
)
Dim
runtime
=
CreateRuntimeInstance
(
comp
)
Dim
typeName
As
String
=
Nothing
Dim
locals
=
ArrayBuilder
(
Of
LocalAndMethod
).
GetInstance
()
Dim
testData
As
CompilationTestData
=
Nothing
GetLocals
(
runtime
,
methodName
,
argumentsOnly
:
=
False
,
locals
:
=
locals
,
count
:
=
1
,
typeName
:
=
typeName
,
testData
:
=
testData
)
VerifyLocal
(
testData
,
typeName
,
locals
(
0
),
"<>m0"
,
"t"
,
expectedILOpt
:
=
xIL
)
locals
.
Free
()
Dim
context
=
CreateMethodContext
(
runtime
,
methodName
)
Dim
errorMessage
As
String
=
Nothing
testData
=
New
CompilationTestData
()
context
.
CompileExpression
(
"t"
,
errorMessage
,
testData
)
Assert
.
Null
(
errorMessage
)
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
xIL
)
End
Sub
Private
Shared
Sub
GetLocals
(
runtime
As
RuntimeInstance
,
methodName
As
String
,
argumentsOnly
As
Boolean
,
locals
As
ArrayBuilder
(
Of
LocalAndMethod
),
count
As
Integer
,
ByRef
typeName
As
String
,
ByRef
testData
As
CompilationTestData
)
Dim
context
=
CreateMethodContext
(
runtime
,
methodName
)
testData
=
New
CompilationTestData
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录