提交 17392e34 编写于 作者: A AlekseyTs

Make assert condition in ScanInterpolatedStringPunctuation more precise.

Fixes #6341.
上级 c4a7c8de
......@@ -31,7 +31,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Syntax.InternalSyntax
' Another } may follow the close brace of an interpolation if the interpolation lacked a format clause.
' This is because the normal escaping rules only apply when parsing the format string.
Debug.Assert(Not CanGet(1) OrElse Peek(offset + 1) <> c OrElse IsRightCurlyBracket(c), "Escape sequence not detected.")
Debug.Assert(Not CanGet(offset + 1) OrElse Peek(offset + 1) <> c OrElse Not (IsLeftCurlyBracket(c) OrElse IsDoubleQuote(c)), "Escape sequence not detected.")
Dim scanTrailingTrivia As Boolean
......
' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
Imports Roslyn.Test.Utilities
Public Class InterpolatedStringParsingTests
Inherits BasicTestBase
......@@ -858,4 +860,66 @@ End Module")
End Module")
End Sub
<Fact, WorkItem(6341, "https://github.com/dotnet/roslyn/issues/6341")>
Public Sub LineBreakInInterpolation_1()
Parse(
"Module Program
Sub Main()
Dim x = $""{ " + vbCr + vbCr + "1
}""
End Sub
End Module"
).AssertTheseDiagnostics(
<expected>
BC30625: 'Module' statement must end with a matching 'End Module'.
Module Program
~~~~~~~~~~~~~~
BC30026: 'End Sub' expected.
Sub Main()
~~~~~~~~~~
BC30201: Expression expected.
Dim x = $"{
~
BC30370: '}' expected.
Dim x = $"{
~
BC30801: Labels that are numbers must be followed by colons.
1
~~
BC30648: String constants must end with a double quote.
}"
~~
</expected>)
End Sub
<Fact, WorkItem(6341, "https://github.com/dotnet/roslyn/issues/6341")>
Public Sub LineBreakInInterpolation_2()
Parse(
"Module Program
Sub Main()
Dim x = $""{ 1 " + vbCr + vbCr + "
}""
End Sub
End Module"
).AssertTheseDiagnostics(
<expected>
BC30625: 'Module' statement must end with a matching 'End Module'.
Module Program
~~~~~~~~~~~~~~
BC30026: 'End Sub' expected.
Sub Main()
~~~~~~~~~~
BC30370: '}' expected.
Dim x = $"{ 1
~
BC30648: String constants must end with a double quote.
}"
~~
</expected>)
End Sub
End Class
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册