提交 7683a0a7 编写于 作者: K Kevin Halverson

Merge pull request #1408 from KevinH-MS/master

Support "typeof(Action<>)" in debugger expressions...
......@@ -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() == '=')
{
......
......@@ -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()
{
......
......@@ -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);
}
}
}
......@@ -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.
先完成此消息的编辑!
想要评论请 注册