Skip to content

Latest commit

 

History

History
51 lines (37 loc) · 1.14 KB

SA1411.md

File metadata and controls

51 lines (37 loc) · 1.14 KB

SA1411

TypeName SA1411AttributeConstructorMustNotUseUnnecessaryParenthesis
CheckId SA1411
Category Maintainability Rules

Cause

An attribute declaration does not contain any parameters, yet it still includes parenthesis.

Rule description

When an attribute declaration does not contain any parameters, the parenthesis around the parameters are optional.

A violation of this rule occurs when unnecessary parenthesis have been used in an attribute constructor. For example:

[Serializable()]

The parenthesis are unnecessary and should be removed:

[Serializable]

How to fix violations

Remove the unnecessary parenthesis.

How to suppress violations

[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1411:AttributeConstructorMustNotUseUnnecessaryParenthesis", Justification = "Reviewed.")]
#pragma warning disable SA1411 // AttributeConstructorMustNotUseUnnecessaryParenthesis
#pragma warning restore SA1411 // AttributeConstructorMustNotUseUnnecessaryParenthesis