Skip to content

Commit 0b1739b

Browse files
Add regression test for ParseAttributeArgumentList with invalid input (fixes #8699) (#80705)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: CyrusNajmabadi <4564579+CyrusNajmabadi@users.noreply.github.com> Co-authored-by: Cyrus Najmabadi <cyrus.najmabadi@gmail.com>
1 parent 7198c8f commit 0b1739b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/Compilers/CSharp/Test/Syntax/Parsing/DeclarationParsingTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11132,5 +11132,28 @@ public void Class_IncompleteArgumentList_06(bool @struct)
1113211132
}
1113311133
EOF();
1113411134
}
11135+
11136+
[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23877")]
11137+
public void TestParseAttributeArgumentListWithInvalidString()
11138+
{
11139+
// Regression test for issue where ParseAttributeArgumentList would throw NullReferenceException
11140+
// when given an invalid string without parentheses
11141+
var result = SyntaxFactory.ParseAttributeArgumentList("somethingWithoutBrackets");
11142+
11143+
Assert.NotNull(result);
11144+
result.GetDiagnostics().Verify(
11145+
// (1,1): error CS1073: Unexpected token 'somethingWithoutBrackets'
11146+
// somethingWithoutBrackets
11147+
Diagnostic(ErrorCode.ERR_UnexpectedToken, "").WithArguments("somethingWithoutBrackets").WithLocation(1, 1));
11148+
11149+
UsingNode(result);
11150+
11151+
M(SyntaxKind.AttributeArgumentList);
11152+
{
11153+
M(SyntaxKind.OpenParenToken);
11154+
M(SyntaxKind.CloseParenToken);
11155+
}
11156+
EOF();
11157+
}
1113511158
}
1113611159
}

0 commit comments

Comments
 (0)