-
Notifications
You must be signed in to change notification settings - Fork 22
SA1500
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.")]
- - SA0102 - Clean Install
- - Download
- - Documentation Rules - Layout Rules - Maintainability Rules - Naming Rules - Ordering Rules - Readability Rules - Spacing Rules - Suppressions
- - Adding a custom StyleCop settings page - Adding custom rule settings - Authoring a custom styleCop rule - Authoring rules metadata - Custom CSharp Language Service - Custom MSBuild Integration - Hosting StyleCop in a Custom Environment - Installing a Custom Rule - Integrating StyleCop Into Build Environments - Integrating StyleCop into MSBuild - Writing Custom Rules for StyleCop