当使用.editorconfig配置格式化并启用自动格式化(或运行dotnet format
)时,有没有什么方法可以 suppress 特定代码区域/块的格式化?
例如,我有一个定义了1000个常量的文件,这些常量以整齐的列对齐.对于这样的例外,我想使用如下内容
class Example
{
#preserve-format
// A block I want automatic formatting to just ignore
const int A = 123;
const int Longer = 234;
const int ...
...
#end-preserve-format
// Formatter works normally here
public void Foo()
{
}
}
有没有什么可以做到这一点?