Skip to content

file-name-matches-type

C#styleno fixdefault: offcsharp/stylecop

Reports a file whose name, up to its first dot and ignoring case, is not the name of the first type in the file; a generic type may also be written Name{T,U}. Not checked when that type is partial. No fix.

A file named after its type is found by the name from the file tree, from a stack trace and from a search. A file whose name says something else sends the reader to the wrong place.

To fix, rename the file or the type.

Reported
class Orders { }
csharp:
lint:
rules:
file-name-matches-type: warn # off (default), warn, error

Enabled by the presets: csharp/stylecop.

Suppress one line with sudsy-disable-next-line file-name-matches-type 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 SA1649 full