Skip to content

no-unneeded-base-prefix

C#stylefix: safedefault: offcsharp/stylecop

Reports base.M() or base[i] where the type does not override the member, so this binds to the same one. The fix writes this.

base. says that the call goes to the parent on purpose, and a reader looks for the override that makes this necessary. When there is none, this.M() is the same call, and the base is a misleading hint.

Reported
...
public (int, int) Pair() => (1, 2);
...
base.Run();
...
After the fix
...
public (int, int) Pair() => (1, 2);
...
this.Run();
...
csharp:
lint:
rules:
no-unneeded-base-prefix: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line no-unneeded-base-prefix 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 SA1100 full