-
Notifications
You must be signed in to change notification settings - Fork 22
SA1516
TypeName |
ElementsMustBeSeparatedByBlankLine |
CheckId |
SA1516 |
Category |
Layout Rules |
Adjacent C# elements are not separated by a blank line.
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.
To fix a violation of this rule, add a blank line between the adjacent elements.
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1516:ElementsMustBeSeparatedByBlankLine", 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