Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
| Property | Value |
|---|---|
| Rule ID | IDE2003 |
| Title | Blank line required between block and subsequent statement |
| Category | Style |
| Subcategory | Language rules (new-line preferences) |
| Applicable languages | C# and Visual Basic |
| Options | dotnet_style_allow_statement_immediately_after_block_experimental |
Note
This rule is experimental and subject to change or removal.
Overview
This style rule enforces that there should be a blank line between a block statement and any subsequent statement at the same scope level. This improves code readability by visually separating different logical sections of code.
Options
Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.
dotnet_style_allow_statement_immediately_after_block_experimental
| Property | Value | Description |
|---|---|---|
| Option name | dotnet_style_allow_statement_immediately_after_block_experimental |
|
| Option values | true |
Allow subsequent statement to immediately follow block statement without a blank line in between |
false |
Require a blank line between a block statement and the subsequent statement | |
| Default option value | true |
Example
// dotnet_style_allow_statement_immediately_after_block_experimental = true
if (true)
{
DoWork();
}
return;
// dotnet_style_allow_statement_immediately_after_block_experimental = false
if (true)
{
DoWork();
}
return;
Suppress a warning
If you want to suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the rule.
#pragma warning disable IDE2003
// The code that's violating the rule is on this line.
#pragma warning restore IDE2003
To disable the rule for a file, folder, or project, set its severity to none in the configuration file.
[*.{cs,vb}]
dotnet_diagnostic.IDE2003.severity = none
To disable all of the code-style rules, set the severity for the category Style to none in the configuration file.
[*.{cs,vb}]
dotnet_analyzer_diagnostic.category-style.severity = none
For more information, see How to suppress code analysis warnings.