SA1411.md
May 1, 2018 ยท View on GitHub
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