Skip to content

Latest commit

 

History

History
55 lines (40 loc) · 1.37 KB

SA1508.md

File metadata and controls

55 lines (40 loc) · 1.37 KB

SA1508

TypeName SA1508ClosingBracesMustNotBePrecededByBlankLine
CheckId SA1508
Category Layout Rules

Cause

A closing brace within a C# element, statement, or expression is preceded 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 a closing brace is preceded by a blank line. For example:

public bool Enabled
{
    get 
    { 
        return this.enabled; 

    }

}

The code above would generate two instances of this violation, since there are two places where closing braces are preceded by blank lines.

How to fix violations

To fix a violation of this rule, remove the blank line preceding the closing brace.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1508:ClosingBracesMustNotBePrecededByBlankLine", Justification = "Reviewed.")]
#pragma warning disable SA1508 // ClosingBracesMustNotBePrecededByBlankLine
#pragma warning restore SA1508 // ClosingBracesMustNotBePrecededByBlankLine