Skip to content
ptittof57 edited this page Aug 15, 2015 · 6 revisions
<title>SA1510: ChainedStatementBlocksMustNotBePrecededByBlankLine</title> <script src="script/helpstudio.js" type="text/javascript"></script> <script src="script/StandardText.js" type="text/jscript"></script>
<script type="text/jscript">WritePageTop(document.title);</script>

TypeName

ChainedStatementBlocksMustNotBePrecededByBlankLine

CheckId

SA1510

Category

Layout Rules

Cause

Chained C# statements are separated by a blank line.

Rule Description

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.

Some types of C# statements can only be used when chained to the bottom of another statement. Examples include catch and finally statements, which must always be chained to the bottom of a try-statement. Another example is an else-statement, which must always be chained to the bottom of an if-statement, or to another else-statement. These types of chained statements must not be separated by a blank line. For example:

try

{

this.SomeMethod();

}

catch (Exception ex)

{

Console.WriteLine(ex.ToString());

}

How to Fix Violations

To fix a violation of this rule, remove any blank lines between the chained statements.

How to Suppress Violations

[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1510:ChainedStatementBlocksMustNotBePrecededByBlankLine", Justification = "Reviewed.")]
Clone this wiki locally