ReSharper 2024.1 Help

Code Inspection: Parentheses are redundant if attribute has no arguments

Category

Redundancies in Code

ID

RedundantAttributeParentheses

EditorConfig

resharper_redundant_attribute_parentheses_highlighting

Default severity

Hint

Language

C#, VB.NET

Requires SWA

No

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. ReSharper suggests removing empty parentheses to make code more concise.

[ProgramTestClass()] public class ProgramTests { /* ... */ }
[ProgramTestClass] public class ProgramTests { /* ... */ }
Last modified: 15 April 2024