SA1500 - Visual-Stylecop/Visual-StyleCop GitHub Wiki
TypeName |
CurlyBracketsForMultiLineStatementsMustNotShareLine |
CheckId |
SA1500 |
Category |
Layout Rules |
The opening or closing curly bracket within a C# statement, element, or expression is not placed on its own line.
A violation of this rule occurs when the opening or closing curly bracket within a statement, element, or expression is not placed on its own line. For example:
public object Method()
{
lock (this) {
return this.value;
}
}
When StyleCop checks this code, a violation of this rule will occur because the opening curly bracket of the lock statement is placed on the same line as the lock keyword, rather than being placed on its own line, as follows:
public object Method()
{
lock (this)
{
return this.value;
}
}
A violation will also occur if the closing curly bracket shares a line with other code. For example:
public object Method()
{
lock (this)
{
return this.value; }
}
To fix a violation of this rule, ensure that both the opening and closing curly brackets are placed on their own line, and do not share the line with any other code, other than comments.
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1500:CurlyBracketsForMultiLineStatementsMustNotShareLine", Justification = "Reviewed.")]