Skip to content

separate-attributes

C#stylefix: safedefault: offcsharp/stylecop

Reports an attribute list with several attributes: [A, B] is [A] and [B]. Lists on parameters and type parameters are not reported. The fix is not offered when the list has a comment in it.

One attribute to a list gives each its own line, so a diff shows exactly the attribute that was added or removed and a comment can be put on one.

Reported
[assembly: A, B]
class C {
[A(), B]
void F([A, B] int p) { }
[A, // why
B]
int x;
...
}
csharp:
lint:
rules:
separate-attributes: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line separate-attributes 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 SA1133 full