Naming Class
ID |
csharp.naming_class |
Severity |
info |
Remediation Complexity |
trivial |
Remediation Risk |
medium |
Remediation Effort |
low |
Resource |
Naming Convention |
Language |
CSharp |
Tags |
naming |
Description
Reports class, struct, record and enum names that do not follow the C# PascalCase
convention. A type name must start with an uppercase letter and contain no underscores.
Interfaces are not checked here: by convention C# interface names start with I
(IPascalCase) and are covered by a dedicated rule.
Units carrying a generated-code marker (// <auto-generated> header or [GeneratedCode] attribute) are skipped — tool-emitted names are not hand-maintained.
Rationale
Consistent type naming is one of the strongest readability signals in a codebase.
The .NET design guidelines specify PascalCase for all type names, and tooling, frameworks
and other developers all rely on that expectation. A type called order_item or
orderItem stands out as foreign and slows down everyone reading the code.
public class OrderItem { } // OK
public class order_item { } // FLAW — lowercase and underscore
public struct point2D { } // FLAW — starts lowercase
public enum color_mode { } // FLAW — lowercase and underscore
public interface IRepository { } // OK — interfaces use the IPascalCase rule