在将代码与空格对齐时阻止IDE0055样式分析器



我使用了一种非常常见的格式化技术,通过对齐代码来提高可读性。

例如1个声明(可能通过csharp_space_around_declaration_statements)

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

例如,2个没有声明

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

但我使用的是roslyn分析器,它会触发IDE0055:Fix formatting(对于前两行)。

.editorconfig中,是否存在允许此样式的dotnet_xxxcsharp_xxx配置选项(或组合)?

.editorconfig中设置csharp_space_around_declaration_statements = ignore

此设置位于Text editor -> C# -> Code Style -> Formatting -> Spacing -> ignore spaces in declaration statements

虽然我不知道在模式匹配中禁用自动格式化的方法:

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

最新更新