Formatter formats collection expression with trailing comma incorrectly
- Dominant language
- C#
- Stars
- 20.7k
- Forks
- 4.3k
- PR merge metrics
- PR metrics pending
Description
### Environment data
VS Code version: 1.95.2, `e8653663e8840adaf45af01eab5c627a5af81807`, x64
C# Extension version: v2.56.31
### Steps to reproduce
1. Create or open a C# project.
2. Add the following code wherever syntactically applicable:
```cs
void M()
{
int[] arr =
[
0,
];
}
```
3. Ensure the file uses 4 spaces for indentations and `editor.formatOnSave` is enabled.
4. Save the file.
### Expected behavior
```cs
void M()
{
int[] arr =
[
0,
];
}
```
### Actual behavior
```cs
void M()
{
int[] arr =
[
0,
];
}
```
Contributor guide
Research direction
Reproduce this in a C# project with four-space indentation and editor.formatOnSave enabled, then compare the formatter's output for the collection expression with a trailing comma against the expected result. Trace the formatter behavior for this syntax and verify that the closing bracket is aligned correctly without changing the intended trailing comma.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100