Skip to content

Latest commit

 

History

History
48 lines (36 loc) · 1.59 KB

File metadata and controls

48 lines (36 loc) · 1.59 KB

SA1112

TypeName SA1112ClosingParenthesisMustBeOnLineOfOpeningParenthesis
CheckId SA1112
Category Readability Rules

Cause

The closing parenthesis or bracket in a call to a C# method or indexer, or the declaration of a method or indexer, is not placed on the same line as the opening bracket when the element does not take any parameters.

Rule description

A violation of this rule occurs when a method or indexer does not take any parameters and the closing bracket of a call or declaration for the method or indexer is not placed on the same line as the opening bracket. The following example shows correct placement of the closing parenthesis:

This rule applies to calls to constructors and object creation expressions, including target-typed new() expressions in C# 9. When no arguments are provided, the closing parenthesis should remain on the same line as the opening parenthesis following new.

public string GetName()
{
    return this.name.Trim();
}

How to fix violations

To fix a violation of this rule, ensure that the closing bracket is placed on the same line as the opening bracket.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.ReadabilityRules", "SA1112:ClosingParenthesisMustBeOnLineOfOpeningParenthesis", Justification = "Reviewed.")]
#pragma warning disable SA1112 // ClosingParenthesisMustBeOnLineOfOpeningParenthesis
#pragma warning restore SA1112 // ClosingParenthesisMustBeOnLineOfOpeningParenthesis