Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix property parsing when it contains parantheses #48598

Merged
merged 11 commits into from
Nov 10, 2020
8 changes: 0 additions & 8 deletions src/Compilers/VisualBasic/Portable/Parser/Parser.vb
Original file line number Diff line number Diff line change
Expand Up @@ -4181,14 +4181,6 @@ checkNullable:

If CurrentToken.Kind = SyntaxKind.OpenParenToken Then
propertyParameters = ParseParameters(openParen, closeParen)

' If we blow up on the parameters try to resume on the AS, =, or Implements
' TODO - GreenSepList knows its error count. Expose it instead of recomputing it.
If propertyParameters.Count = 0 Then
Dim unexpected = ResyncAt({SyntaxKind.AsKeyword, SyntaxKind.ImplementsKeyword, SyntaxKind.EqualsToken})
closeParen = closeParen.AddTrailingSyntax(unexpected)
End If

optionalParameters = SyntaxFactory.ParameterList(openParen, propertyParameters, closeParen)
Else
If ident.ContainsDiagnostics Then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -934,4 +934,38 @@ End Enum
Assert.Equal(Syntax.InternalSyntax.Scanner.BadTokenCountLimit, tree.GetDiagnostics().Where(Function(d) d.Code = ERRID.ERR_IllegalChar).Count())
End Sub

<Fact, WorkItem(48587, "https://github.com/dotnet/roslyn/issues/48587")>
Public Sub ParseTrailingTextAfterPropertyWithParentheses()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlib40(
<compilation name="ParseTrailingTextAfterPropertyWithParentheses">
<file name="a.b">
Class C
Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow
Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer
Youssef1313 marked this conversation as resolved.
Show resolved Hide resolved
Public ReadOnly Property NumberOfResult3() UnexpectedToken ' With comment.
Public ReadOnly Property NumberOfResult4() UnexpectedToken _
As Integer ' with line continuation and comment.

Public ReadOnly Property NumberOfResult5() ' With comment - no errors.
Public ReadOnly Property NumberOfResult6() _
As Integer ' No error with line continuation.
End Class
</file>
</compilation>)
CompilationUtils.AssertTheseDiagnostics(compilation,
<errors>
BC30205: End of statement expected.
Public ReadOnly Property NumberOfResult1() String Integer JohnDoe WwwIIWww Wow
~~~~~~
BC30205: End of statement expected.
Public ReadOnly Property NumberOfResult2() Some unexpected tokens As Integer
~~~~
BC30205: End of statement expected.
Public ReadOnly Property NumberOfResult3() UnexpectedToken ' With comment.
~~~~~~~~~~~~~~~
BC30205: End of statement expected.
Public ReadOnly Property NumberOfResult4() UnexpectedToken _
~~~~~~~~~~~~~~~
</errors>)
End Sub
End Class