Edit

Share via


Avoid multiple blank lines (IDE2000)

Property Value
Rule ID IDE2000
Title Avoid multiple blank lines
Category Style
Subcategory Language rules (new-line preferences)
Applicable languages C# and Visual Basic
Options dotnet_style_allow_multiple_blank_lines_experimental

Note

This rule is experimental and subject to change or removal.

Overview

This style rule flags the presence of multiple consecutive blank lines in source code. Having multiple blank lines can reduce code readability and is generally considered poor formatting practice.

Options

Options specify the behavior that you want the rule to enforce. For information about configuring options, see Option format.

dotnet_style_allow_multiple_blank_lines_experimental

Property Value Description
Option name dotnet_style_allow_multiple_blank_lines_experimental
Option values true Allow multiple consecutive blank lines
false Don't allow consecutive blank lines
Default option value true

Example

// dotnet_style_allow_multiple_blank_lines_experimental = true
if (true)
{
    DoWork();
}


return;
// dotnet_style_allow_multiple_blank_lines_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 IDE2000
// The code that's violating the rule is on this line.
#pragma warning restore IDE2000

To disable the rule for a file, folder, or project, set its severity to none in the configuration file.

[*.{cs,vb}]
dotnet_diagnostic.IDE2000.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.

See also