Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent IDE0055 style analyzer when aligning code with spaces

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?

like image 368
lonix Avatar asked Aug 31 '25 03:08

lonix


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,
};
like image 86
JL0PD Avatar answered Sep 02 '25 17:09

JL0PD