| TypeName | SA1513ClosingBraceMustBeFollowedByBlankLine |
| CheckId | SA1513 |
| Category | Layout Rules |
A closing brace within a C# element, statement, or expression is not followed 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 a closing brace is not followed by a blank line. For example, the following code would generate one instance of this violation, since there is one place where a closing brace is not followed by a blank line.
if (condition)
{
DoSomething();
}
return value;Braces that are part of an expression or pattern (for example, switch expressions or property patterns introduced in
C# 8.0) do not require a blank line when the brace is immediately followed by continuation tokens like =>, ,, or
;. The same applies when the brace is directly followed by a logical operator (such as && or ||) or by a pattern
designation (e.g., } patternVar) that continues the same expression.
To fix a violation of this rule, ensure a blank line follows closing braces.
[SuppressMessage("StyleCop.CSharp.LayoutRules", "SA1513:ClosingBraceMustBeFollowedByBlankLine", Justification = "Reviewed.")]#pragma warning disable SA1513 // ClosingBraceMustBeFollowedByBlankLine
#pragma warning restore SA1513 // ClosingBraceMustBeFollowedByBlankLine