csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

Don't reformat tabular data.

Open belav opened this issue 3 years ago • 4 comments

There are cases where we want to keep the original formatting on arrays

        private static readonly char[] _Base64Code = {
            '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J',
            'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V',
            'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
            'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
            'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9'
        };

Keeping this as is will be much more readable than putting every char on its own line.

belav avatar Jan 31 '22 22:01 belav

One concern, how do we decide that it is tabular? If each line has the same number of arguments? What happens if someone adds a new argument to the first line? Do they need to rearrange the whole line?

Other examples https://github.com/dlech/SshAgentLib/blob/07c4d17f6648d13378dee274ebc8efa3c9b78144/SshAgentLib/Crypto/BCrypt.cs#L355

google java format discussion https://github.com/google/google-java-format/issues/137#issuecomment-436319566

belav avatar Jan 31 '22 22:01 belav

This kind of situations is given as examples for // prettier-ignore.

It's hard to decide when a collection should be printed with a fixed number of items per line. It's probably best to just let user indicate // csharpier-ignore if they're writing matrices, a sudoku solver or similar.

Aside: do you have a date planned for the next release? I'd like to try csharpier and provide feedback based on large, complex projects but I'm waiting for the new configurable tabs to land in released version.

jods4 avatar May 19 '22 13:05 jods4

Aside: do you have a date planned for the next release?

I can make sure it gets out this weekend. I've been releasing less often because I haven't had as much time to work on csharpier. But I think releasing more regularly even if there is less in each release makes more sense.

belav avatar May 20 '22 15:05 belav

WorkAroundExists :-)

        private static readonly char[] _Base64Code = {
            new []{ '.', '/', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J' },
            new []{ 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V' },
            new []{ 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' },
            new []{ 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't' },
            new []{ 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5' },
            new []{ '6', '7', '8', '9' }
        }.SelectMany(_ => _).ToArray();

SK-Genius avatar Jan 19 '24 11:01 SK-Genius