Skip to content

no-empty-attribute-parens

C#stylefix: safedefault: offcsharp/stylecop

Reports an attribute with empty parentheses: [Foo()] is [Foo]. Parentheses with a comment in them are not reported. The fix removes the parentheses.

The parentheses add two characters and no meaning: the attribute is constructed in both cases with its parameterless constructor.

Reported
...
class C {
[A(), B]
void F([A, B] int p) { }
[A, // why
...
csharp:
lint:
rules:
no-empty-attribute-parens: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line no-empty-attribute-parens in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
StyleCop SA1411 full