csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Spread (in collection expression) are not formatted

Open jods4 opened this issue 1 year ago • 0 comments

Input:

List<KeyValuePair<string, string>> list =
[..    attribute.Targets.Select(target =>    KeyValuePair.Create(target, context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null)).Where(kvp => kvp.Value != null)];

Output:

List<KeyValuePair<string, string>> list =
[
    ..    attribute.Targets.Select(target =>    KeyValuePair.Create(target, context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null)).Where(kvp => kvp.Value != null)
];

Expected behavior: The spread doesn't seem to be formatted at all. For example, extra spaces after the .. or after => are not condensed. The line is extremely long but it's not broken.

I would expect something like

List<KeyValuePair<string, string>> list =
[
    ..attribute
        .Targets.Select(target =>
            KeyValuePair.Create(
                target,
                context.EntityDefinitions.TryGetValue(target, out var type) ? type.ClassName : null
            )
        )
        .Where(kvp => kvp.Value != null)
];

jods4 avatar Feb 08 '24 13:02 jods4