Prevent IDE0055 style analyzer when aligning code with spaces

Viewed 1855

I use a very common formatting technique that improves readability, by aligning code.

e.g. 1 with declarations (possible via csharp_space_around_declaration_statements)

var a    = foo;
var bc   = 123;
var some = thing;

e.g. 2 not with declarations

a    = foo;
bc   = 123;
some = thing;

But I'm using the roslyn analyzers, and that triggers IDE0055:Fix formatting (for the first two lines).

In .editorconfig, is there a dotnet_xxx or csharp_xxx config option (or combination) that allows this style?

1 Answers

Set csharp_space_around_declaration_statements = ignore in .editorconfig

This setting is located in Text editor -> C# -> Code Style -> Formatting -> Spacing -> ignore spaces in declaration statements

Although I don't know a way to disable autoformat in pattern matching:

static int Foo(int x, int y) => (x, y) switch
{
    (    0,     0) => 0,
    (int i,     0) => 11,
    (int i, int j) => i + j,
};
Related