Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

using System;
using System.Linq;
using ICSharpCode.Decompiler.IL.Transforms;
using Microsoft.CodeAnalysis.CSharp.Symbols;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
Expand Down Expand Up @@ -11132,5 +11133,29 @@ public void Class_IncompleteArgumentList_06(bool @struct)
}
EOF();
}

[Fact, WorkItem("https://github.com/dotnet/roslyn/issues/23877")]
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);

UsingNode(result);

M(SyntaxKind.AttributeArgumentList);
{
M(SyntaxKind.OpenParenToken);
M(SyntaxKind.CloseParenToken);
}
EOF();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Globalization;
using System.Linq;
using System.Text;
using ICSharpCode.Decompiler.IL.Transforms;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Text;
Expand Down
Loading