Skip to content
15 changes: 15 additions & 0 deletions src/Compilers/CSharp/Test/Syntax/Syntax/SyntaxFactoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,5 +714,20 @@ public void TestParseMethodsKeepParseOptionsInTheTree()
var typeName = SyntaxFactory.ParseTypeName("", options: parseOptions);
Assert.Same(parseOptions, typeName.SyntaxTree.Options);
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/8699")]
public void TestParseAttributeArgumentListWithInvalidString()
{
// Regression test for issue where ParseAttributeArgumentList would throw NullReferenceException
// when given an invalid string without parentheses
var result = SyntaxFactory.ParseAttributeArgumentList("somethingWithoutBrackets");

Assert.NotNull(result);
Assert.True(result.GetDiagnostics().Any(), "Expected diagnostics for invalid input");

// Verify the structure is as expected - should have missing open/close parens and errors
Assert.True(result.OpenParenToken.IsMissing);
Assert.True(result.CloseParenToken.IsMissing);
}
}
}
Loading