TypeName | SA1509OpeningBracesMustNotBePrecededByBlankLine |
CheckId | SA1509 |
Category | Layout Rules |
An opening brace within a C# element, statement, or expression is preceded by a blank line.
To improve the readability of the code, StyleCop requires blank lines in certain situations, and prohibits blank lines in other situations. This results in a consistent visual pattern across the code, which can improve recognition and readability of unfamiliar code.
In general, a violation of this rule occurs when an opening brace is preceded by a blank line. For example, the following above would generate two instances of this violation, since there are two places where opening braces are preceded by blank lines.
public bool Enabled
{
get
{
return this.enabled;
}
}
An exception to this rule occurs when the opening brace is preceded by a closing brace. When this occurs, a blank line will be required by SA1513. The following example shows correct use of blank lines:
public bool Enabled
{
get
{
{
}
{
return this.enabled;
}
}
}
To fix a violation of this rule, remove the blank line preceding the opening brace.
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1509:OpeningBracesMustNotBePrecededByBlankLine", Justification = "Reviewed.")]
#pragma warning disable SA1509 // OpeningBracesMustNotBePrecededByBlankLine
#pragma warning restore SA1509 // OpeningBracesMustNotBePrecededByBlankLine