TypeName | SA1410RemoveDelegateParenthesisWhenPossible |
CheckId | SA1410 |
Category | Maintainability Rules |
A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis.
When an anonymous method does not contain any method parameters, the parenthesis around the parameters are optional.
A violation of this rule occurs when the parenthesis are present on an anonymous method call which takes no method parameters. For example:
this.Method(delegate() { return 2; });
The parenthesis are unnecessary and should be removed:
this.Method(delegate { return 2; });
Remove the unnecessary parenthesis after the delegate keyword.
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1410:RemoveDelegateParenthesisWhenPossible", Justification = "Reviewed.")]
#pragma warning disable SA1410 // RemoveDelegateParenthesisWhenPossible
#pragma warning restore SA1410 // RemoveDelegateParenthesisWhenPossible