From a5975c49fe9d6282220e5ccf92471a6fa1f91c2e Mon Sep 17 00:00:00 2001 From: Youssef1313 Date: Sun, 6 Mar 2022 10:37:11 +0200 Subject: [PATCH] Add test for whitespace before !! token --- .../Syntax/Parsing/DeclarationParsingTests.cs | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs index f6c25667d5b3e..ff8361e258f6d 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs @@ -7239,10 +7239,16 @@ class C where T : struct? {} EOF(); } - [Fact] - public void TestMethodDeclarationNullValidation() - { - UsingStatement(@"void M(string name!!) { }", options: TestOptions.RegularPreview); + [Theory] + [InlineData("!!", false)] + [InlineData(" !!", false)] + [InlineData("!!", true)] + [InlineData(" !!", true)] + [WorkItem(59580, "https://github.com/dotnet/roslyn/issues/59580")] + public void TestMethodDeclarationNullValidation(string exclamationExclamationToken, bool isTypeNullable) + { + string type = isTypeNullable ? "string?" : "string"; + UsingStatement($@"void M({type} name{exclamationExclamationToken}) {{ }}", options: TestOptions.RegularPreview); N(SyntaxKind.LocalFunctionStatement); { N(SyntaxKind.PredefinedType); @@ -7255,9 +7261,17 @@ public void TestMethodDeclarationNullValidation() N(SyntaxKind.OpenParenToken); N(SyntaxKind.Parameter); { + if (isTypeNullable) + { + N(SyntaxKind.NullableType); + } N(SyntaxKind.PredefinedType); { N(SyntaxKind.StringKeyword); + if (isTypeNullable) + { + N(SyntaxKind.QuestionToken); + } } N(SyntaxKind.IdentifierToken, "name"); N(SyntaxKind.ExclamationExclamationToken); @@ -7270,6 +7284,7 @@ public void TestMethodDeclarationNullValidation() N(SyntaxKind.CloseBraceToken); } } + EOF(); } [Fact]