Skip to content
ptittof57 edited this page Aug 15, 2015 · 6 revisions
<title>SA1516: ElementsMustBeSeparatedByBlankLine</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

ElementsMustBeSeparatedByBlankLine

CheckId

SA1516

Category

Layout Rules

Cause

Adjacent C# elements are not 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.

A violation of this rule occurs when two adjacent element are not separated by a blank line. For example:

public void Method1()

{

}

public bool Property

{

get { return true; }

}

In the example above, the method and property are not separated by a blank line, so a violation of this rule would occur.

            <p style="font-family: 'Courier New';"><SPAN style="COLOR: blue;">public</SPAN><SPAN style="COLOR: blue"> event</SPAN> <span style="color:2b91af">EventHandler</span> SomeEvent</SPAN><br />

{
add
{
// add event subscriber here
}<o:p>
</o:p> remove
{
// remove event subscriber here
}<o:p>
</o:p> }

In the example above, the add and remove of the event need to be separated by a blank line because the add is multiline.

How to Fix Violations>How to Fix Violations

To fix a violation of this rule, add a blank line between the adjacent elements.

How to Suppress Violations

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