diff --git a/src/Compilers/CSharp/Portable/Parser/Lexer.cs b/src/Compilers/CSharp/Portable/Parser/Lexer.cs index 895a2bf752ea2e445d762dd34dea64bdc0e0d7b9..f52fd1efe8acb65167b203d6bd1c403d71745005 100644 --- a/src/Compilers/CSharp/Portable/Parser/Lexer.cs +++ b/src/Compilers/CSharp/Portable/Parser/Lexer.cs @@ -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() == '=') { diff --git a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs index 3c92b4d6f94fa8c93214da27fa155d3c9d12ea17..101c6bf8ca516a415436a12da227cdbf527495ee 100644 --- a/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/LexicalAndXml/LexicalTests.cs @@ -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 = "<"" + 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>)", out error, testData); + Assert.Equal("error CS7003: Unexpected use of an unbound generic name", error); + + context.CompileExpression("typeof(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); + } } } diff --git a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb index b1290dabf85ae5c9552cfd8f11b7bf95d0f14045..80cf0a8e8b6442817b89a54c3e83ea1ea97407d7 100644 --- a/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb +++ b/src/ExpressionEvaluator/VisualBasic/Test/ExpressionCompiler/ExpressionCompilerTests.vb @@ -3942,6 +3942,33 @@ End Module" }") End Sub + + 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