csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

BinaryExpression - better breaking for single binary expressions.

Open belav opened this issue 3 years ago • 0 comments

We have logic that keeps the right side of a binary expression on the same line as the left side.

There are cases where we don't really want this to happen. Can we handle this better somehow? Prettier currently does not.

        _resourcesRelativePath =
            _resourcesRelativePath.Replace(Path.AltDirectorySeparatorChar, '.')
                .Replace(Path.DirectorySeparatorChar, '.') + ".";
// would be easier to understand as
        _resourcesRelativePath =
            _resourcesRelativePath.Replace(Path.AltDirectorySeparatorChar, '.')
                .Replace(Path.DirectorySeparatorChar, '.')
            + ".";

        testAppInfo.Scenarios = createIndividualHosts.ToDictionary(
            kvp => kvp.Key,
            kvp =>
                kvp.Value.host.Services.GetRequiredService<IServer>()
                    .Features.Get<IServerAddressesFeature>()
                    .Addresses.FirstOrDefault()
                    .Replace("127.0.0.1", "localhost") + kvp.Value.basePath
        );
// would be easier to understand as
        testAppInfo.Scenarios = createIndividualHosts.ToDictionary(
            kvp => kvp.Key,
            kvp =>
                kvp.Value.host.Services.GetRequiredService<IServer>()
                    .Features.Get<IServerAddressesFeature>()
                    .Addresses.FirstOrDefault()
                    .Replace("127.0.0.1", "localhost")
                + kvp.Value.basePath
        );

// these are better the way they currently are
        testAppInfo.Scenarios = createIndividualHosts.ToDictionary(
            kvp => kvp.Key,
            kvp =>
                CallMethod(
                    jlaskldfjlasdklfalskdfjaskdf,
                    jalsdfjkaslkdjfljaksdfljkasdf,
                    jlasdjfkasldkfaskjfkasd
                ) + kvp.Value.basePath

        if (
            CallSomeMethod(
                someParameter_____________________________________,
                someParameter_____________________________________
            ) == 0
        ) { }

//  not sure what to do with this, also affected by invocations and variables
        var notIdealSee355 =
            variable.Replace(someParameter_______________________, '.')
                .Replace(someParameter_______________________, '.') + ".";

belav avatar Jul 17 '21 16:07 belav