SA1410.md
December 3, 2025 ยท View on GitHub
SA1410
| TypeName | SA1410RemoveDelegateParenthesisWhenPossible |
| CheckId | SA1410 |
| Category | Maintainability Rules |
Cause
A call to a C# anonymous method does not contain any method parameters, yet the statement still includes parenthesis.
Rule description
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; });
this.Method(static delegate() { return 2; });
The parenthesis are unnecessary and should be removed:
this.Method(delegate { return 2; });
this.Method(static delegate { return 2; });
How to fix violations
Remove the unnecessary parenthesis after the delegate keyword.
How to suppress violations
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1410:RemoveDelegateParenthesisWhenPossible", Justification = "Reviewed.")]
#pragma warning disable SA1410 // RemoveDelegateParenthesisWhenPossible
#pragma warning restore SA1410 // RemoveDelegateParenthesisWhenPossible