csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Improved breaking for ExpressionBody in Parenthesized Lambda

Open belav opened this issue 4 years ago • 2 comments

I feel like we could clean up how this breaks

entity.HasKey(
    e =>
        new
        {
            e.BusinessEntityID,
            e.PersonID,
            e.ContactTypeID
        }
);
// could instead be something like
entity.HasKey(e => new 
    {
        e.BusinessEntityID,
        e.PersonID,
        e.ContactTypeID
    }
);

belav avatar Apr 23 '21 23:04 belav

Lambda in method formatting should probably be a separate issue than lambda formatting. So, it should probably be something closer to:

entity.HasKey(
    e => new 
    {
        e.BusinessEntityID,
        e.PersonID,
        e.ContactTypeID
    }
);

or at least work the same way as:

var e => new 
    {
        e.BusinessEntityID,
        e.PersonID,
        e.ContactTypeID
    }
);

shocklateboy92 avatar Apr 24 '21 18:04 shocklateboy92

This will most likely require conditional groups somewhere. At least prettier uses them. See call-arguments.js These are some of the related cases with possible desired formatting.

        entity.HasKey(e => new
        {
            e.BusinessEntityID,
            e.PersonID,
            e.ContactTypeID________________________________________________
        });

// prettier differs from this
        entity.HasKey(
            e => new
            {
                e.BusinessEntityID,
                e.PersonID,
                e.ContactTypeID________________________________________________
            },
            two
        );

        entity.HasKey((e) =>
        {
            return new
            {
                One = e.BusinessEntityID,
                Two = e.PersonID,
                Three = e.ContactTypeID________________________________________________
            };
        });

        var variableDeclarator = conditionalAccessExpression?.invocationExpression(
            o => someLongValue___________________________________
        );

        var y = someList.Where(
            o =>
                someLongValue_______________________
                && theseShouldNotIndent_________________
                && theseShouldNotIndent_________________
                    > butThisOneShould_________________________________________
        );

belav avatar Sep 06 '21 20:09 belav