belav / csharpier

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

Long expression IsPattern breaking #430

Open belav opened 2 years ago

belav commented 2 years ago

The following

        if (
            someLongName____________________________________________________ is
            { } anotherLongName______________________
        ) {
            return;
        }

Is more readable as


        if (
            someLongName____________________________________________________
            is { } anotherLongName______________________
        ) {
            return;
        }
belav commented 2 years ago

real world example


            if (
                parameterCustomAttributes.OfType<IFromRouteMetadata>().FirstOrDefault() is
                { } routeAttribute
            ) {
belav commented 2 years ago

make sure to test with

        if (
            context.ActionDescriptor is ControllerActionDescriptor
            {
                ActionName: "Post" or "Patch" or "Delete"
            }
        ) { }
        if (
            context.ActionDescriptor is ControllerActionDescriptor
            {
                ActionName: "MuchLongerStringValue"
                    or "MuchLongerStringValue"
                    or "MuchLongerStringValue"
            }
        ) { }