| 资产 | 价值 |
|---|---|
| 规则 ID | IDE2002 |
| 标题 | 连续大括号之间不得有空行 |
| 类别 | Style |
| 子类别 | 语言规则(新行首选项) |
| 适用的语言 | C# |
| Options | csharp_style_allow_blank_lines_between_consecutive_braces_experimental |
注释
此规则是实验性的,可能会更改或删除。
概述
此样式规则强制要求连续大括号之间不应有空白行。 这有助于保持一致且干净的代码格式。
选项
选项指定希望规则强制实施的行为。 有关配置选项的信息,请参阅 Option 格式。
csharp_style_allow_blank_lines_between_consecutive_braces_experimental
| 资产 | 价值 | Description |
|---|---|---|
| 选项名称 | csharp_style_allow_blank_lines_between_consecutive_braces_experimental |
|
| 选项值 | true |
允许连续大括号之间的空白行 |
false |
不允许不同行的括号之间有空白行 | |
| 默认选项值 | true |
Example
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
public void Method()
{
if (true)
{
DoWork();
}
}
// csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
public void Method()
{
if (true)
{
DoWork();
}
}
禁止显示警告
如果只想取消单个冲突,请将预处理器指令添加到源文件以禁用,然后重新启用规则。
#pragma warning disable IDE2002
// The code that's violating the rule is on this line.
#pragma warning restore IDE2002
若要禁用文件、文件夹或项目的规则,请在none中将其严重性设置为。
[*.{cs,vb}]
dotnet_diagnostic.IDE2002.severity = none
若要禁用所有代码样式规则,请将类别Style的严重性设置为none配置文件中。
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
有关详细信息,请参阅 如何禁止显示代码分析警告。