Rider Help

Code Inspection: Parentheses are redundant if attribute has no arguments

Attributes in C# are classes, and they are called by invoking their constructors. If an attribute's constructor has no parameters, C# allows you to specify it without parentheses when you call it. Rider suggests removing empty parentheses to make code more concise.

Suboptimal codeAfter the quick-fix
[ProgramTestClass()] public class ProgramTests { /* ... */ }
[ProgramTestClass] public class ProgramTests { /* ... */ }
Last modified: 11 October 2017

See Also