Skip to content

Extra newline added when using a collection expression with { get; } #1063

@SapiensAnatis

Description

@SapiensAnatis

I see some of the formatting issues with C# 12 collection expressions were fixed in #1047 but I think I have found another one.

I'm using version 0.26.4 and have found that the following code:

public List<HttpRequestMessage> Requests { get; } =
    [
        new()
        {
            Content = new StringContent("content"),
            Headers = { { "header", "value" } },
            Method = HttpMethod.Post
        }
    ];

will get formatted to

public List<HttpRequestMessage> Requests { get; } =

    [
        new()
        {
            Content = new StringContent("content"),
            Headers = { { "header", "value" } },
            Method = HttpMethod.Post
        }
    ];

i.e. it leaves a blank line between the property declaration and the value. This isn't consistent with the behaviour for fields or auto-properties (=>) which don't add a blank line so I assume it's unintentional.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions