-
Notifications
You must be signed in to change notification settings - Fork 23
SA1501
TypeName |
StatementMustNotBeOnSingleLine |
CheckId |
SA1501 |
Category |
Layout Rules |
A C# statement containing opening and closing curly brackets is written completely on a single line.
A violation of this rule occurs when a statement that is wrapped in opening and closing curly brackets is written on a single 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 entire lock statement is written on one line. The statement should be written across multiple lines, with the opening and closing curly brackets each on their own line, as follows:
public object Method()
{
lock (this)
{
return this.value;
}
}
To fix a violation of this rule, rewrite the statement so that it expands across multiple lines.
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1501:StatementMustNotBeOnSingleLine", 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