Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lwm1986
roslyn
提交
7683a0a7
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,发现更多精彩内容 >>
提交
7683a0a7
编写于
3月 20, 2015
作者:
K
Kevin Halverson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1408 from KevinH-MS/master
Support "typeof(Action<>)" in debugger expressions...
上级
a0f06b75
8e690c43
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
74 addition
and
86 deletion
+74
-86
src/Compilers/CSharp/Portable/Parser/Lexer.cs
src/Compilers/CSharp/Portable/Parser/Lexer.cs
+0
-13
src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs
...ompilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs
+0
-73
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs
...CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs
+47
-0
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb
...lBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb
+27
-0
未找到文件。
src/Compilers/CSharp/Portable/Parser/Lexer.cs
浏览文件 @
7683a0a7
...
...
@@ -674,12 +674,6 @@ private void ScanSyntaxToken(ref TokenInfo info)
break
;
case
'<'
:
if
(
this
.
ModeIs
(
LexerMode
.
DebuggerSyntax
)
&&
TextWindow
.
PeekChar
(
1
)
==
'>'
)
{
// For "<>f_AnonymousType", which is an identifier in DebuggerSyntax mode
goto
case
'a'
;
}
TextWindow
.
AdvanceChar
();
if
(
TextWindow
.
PeekChar
()
==
'='
)
{
...
...
@@ -688,13 +682,6 @@ private void ScanSyntaxToken(ref TokenInfo info)
}
else
if
(
TextWindow
.
PeekChar
()
==
'<'
)
{
if
(
this
.
ModeIs
(
LexerMode
.
DebuggerSyntax
)
&&
TextWindow
.
PeekChar
(
1
)
==
'>'
)
{
// For "GenericOf<<>f__AnonymousType>"
info
.
Kind
=
SyntaxKind
.
LessThanToken
;
break
;
}
TextWindow
.
AdvanceChar
();
if
(
TextWindow
.
PeekChar
()
==
'='
)
{
...
...
src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs
浏览文件 @
7683a0a7
...
...
@@ -2282,79 +2282,6 @@ public void TestDottedNameSequence()
Assert
.
Equal
(
6
,
results
.
Count
);
}
[
Fact
]
public
void
TestDebuggerCompilerGeneratedIdentifiers
()
{
string
text
=
"<>"
;
var
token
=
DebuggerLexToken
(
text
);
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
IdentifierToken
,
token
.
Kind
());
var
errors
=
token
.
Errors
();
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
text
,
token
.
Text
);
Assert
.
Equal
(
text
,
token
.
Value
);
text
=
"<>f__AnonymousType0"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
IdentifierToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
text
,
token
.
Text
);
Assert
.
Equal
(
text
,
token
.
Value
);
text
=
"<>f__AnonymousType0>"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
IdentifierToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
text
.
Substring
(
0
,
text
.
Length
-
1
),
token
.
Text
);
Assert
.
Equal
(
text
.
Substring
(
0
,
text
.
Length
-
1
),
token
.
Value
);
text
=
"<>f__AnonymousType0<"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
IdentifierToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
text
.
Substring
(
0
,
text
.
Length
-
1
),
token
.
Text
);
Assert
.
Equal
(
text
.
Substring
(
0
,
text
.
Length
-
1
),
token
.
Value
);
text
=
"<>f__\\u0041nonymousType1"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
IdentifierToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
text
,
token
.
Text
);
Assert
.
NotEqual
(
text
,
token
.
Value
);
Assert
.
Equal
(
"<>f__AnonymousType1"
,
token
.
Value
);
text
=
"<<>"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
LessThanToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
"<"
,
token
.
Text
);
text
=
"<<X"
;
token
=
DebuggerLexToken
(
text
);
errors
=
token
.
Errors
();
Assert
.
NotNull
(
token
);
Assert
.
Equal
(
SyntaxKind
.
LessThanLessThanToken
,
token
.
Kind
());
Assert
.
Equal
(
0
,
errors
.
Length
);
Assert
.
Equal
(
"<<"
,
token
.
Text
);
}
[
Fact
]
public
void
TestDebuggerDollarIdentifiers
()
{
...
...
src/ExpressionEvaluator/CSharp/Test/ExpressionCompiler/ExpressionCompilerTests.cs
浏览文件 @
7683a0a7
...
...
@@ -5915,5 +5915,52 @@ .maxstack 1
}
"
);
}
[
WorkItem
(
1136085
,
"DevDiv"
)]
[
Fact
]
public
void
TypeofOpenGenericType
()
{
var
source
=
@"
using System;
public class C
{
public void M()
{
}
}"
;
var
compilation
=
CreateCompilationWithMscorlib45
(
source
);
var
runtime
=
CreateRuntimeInstance
(
compilation
);
var
context
=
CreateMethodContext
(
runtime
,
"C.M"
);
string
error
;
var
expectedIL
=
@"
{
// Code size 11 (0xb)
.maxstack 1
IL_0000: ldtoken ""System.Action<T>""
IL_0005: call ""System.Type System.Type.GetTypeFromHandle(System.RuntimeTypeHandle)""
IL_000a: ret
}"
;
var
testData
=
new
CompilationTestData
();
context
.
CompileExpression
(
"typeof(Action<>)"
,
out
error
,
testData
);
Assert
.
Null
(
error
);
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
expectedIL
);
testData
=
new
CompilationTestData
();
context
.
CompileExpression
(
"typeof(Action<> )"
,
out
error
,
testData
);
Assert
.
Null
(
error
);
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
expectedIL
);
context
.
CompileExpression
(
"typeof(Action<Action<>>)"
,
out
error
,
testData
);
Assert
.
Equal
(
"error CS7003: Unexpected use of an unbound generic name"
,
error
);
context
.
CompileExpression
(
"typeof(Action<Action< > > )"
,
out
error
);
Assert
.
Equal
(
"error CS7003: Unexpected use of an unbound generic name"
,
error
);
context
.
CompileExpression
(
"typeof(Action<>a)"
,
out
error
);
Assert
.
Equal
(
"(1,16): error CS1026: ) expected"
,
error
);
}
}
}
src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb
浏览文件 @
7683a0a7
...
...
@@ -3942,6 +3942,33 @@ End Module"
}"
)
End
Sub
<
Fact
>
Public
Sub
GetTypeOpenGenericType
()
Dim
source
=
"
Imports System
Class C
Sub M()
End Sub
End Class"
Dim
compilation
=
CreateCompilationWithMscorlib
({
source
},
compOptions
:
=
TestOptions
.
DebugDll
)
Dim
runtime
=
CreateRuntimeInstance
(
compilation
)
Dim
context
=
CreateMethodContext
(
runtime
,
"C.M"
)
Dim
errorMessage
As
String
=
Nothing
Dim
testData
=
New
CompilationTestData
()
context
.
CompileExpression
(
"GetType(Action(Of ))"
,
errorMessage
,
testData
)
Assert
.
Null
(
errorMessage
)
testData
.
GetMethodData
(
"<>x.<>m0"
).
VerifyIL
(
"
{
// Code size 11 (0xb)
.maxstack 1
IL_0000: ldtoken
""
System.Action(Of T)
""
IL_0005: call
""
Function System.Type.GetTypeFromHandle(System.RuntimeTypeHandle) As System.Type
""
IL_000a: ret
}"
)
End
Sub
End
Class
End
Namespace
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录