Edit

Share via


Blank line not allowed after arrow expression clause token (IDE2006)

Property Value
Rule ID IDE2006
Title Blank line not allowed after arrow expression clause token
Category Style
Subcategory Language rules (new-line preferences)
Applicable languages C#
Options csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental

Note

This rule is experimental and subject to change or removal.

Overview

This style rule enforces that there should not be blank lines after the arrow (=>) token in expression-bodied members, lambda expressions, or switch expressions. The expression should immediately follow the arrow without any blank lines.

Options

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

csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental

Property Value Description
Option name csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental
Option values true Allow a blank line after the token in an arrow expression clause
false Require expression to immediately follow token in an arrow expression clause
Default option value true

Example

// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true
public int Method() =>
    9 + 1;
// csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
public int Method()
    => 9 + 1;

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

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

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