belav / csharpier

CSharpier is an opinionated code formatter for c#.
https://csharpier.com
MIT License
1.43k stars 99 forks source link

Keep property with property #1108

Open bbaia opened 11 months ago

bbaia commented 11 months ago

Using the latest 0.26.7 that reverted https://github.com/belav/csharpier/issues/1010, there are some inconsistencies in the intentation when it starts with multiple fields

Input:

var result = myContext.MyDbSet.Where(x => x.IsOK).Select(x => x.Property).ToList();

Output:

var result = myContext
    .MyDbSet.Where(x => x.IsOK)
    .Select(x => x.Property)
    .ToList();

Expected behavior:

var result = myContext.MyDbSet
    .Where(x => x.IsOK)
    .Select(x => x.Property)
    .ToList();

or

var result = myContext.MyDbSet.Where(x => x.IsOK)
    .Select(x => x.Property)
    .ToList();
belav commented 11 months ago

Based on how I remember this working, and how prettier works, I would expect it to look like this.

var result = myContext.MyDbSet.Where((x) => x.IsOK)
  .Select((x) => x.Property)
  .ToList();

I went back a couple of versions, and the current behavior is consistent with 0.26.0, but older versions were different.


// 0.26.0
var result________________________________ = myContext
    .MyDbSet.Where(x => x.IsOK)
    .Select(x => x.Property)
    .ToList();

// 0.25.0 + 0.24.0
var result________________________________ = myContext.MyDbSet
    .Where(x => x.IsOK)
    .Select(x => x.Property)
    .ToList();