Naming things - GameLabGraz/Maroon GitHub Wiki

Folders and Files

  • Top level directories are kebab-case
  • Directory names and file names are PascalCase, e.g. MyFile.cs
  • Where possible the file name should be the same as the name of the main class in the file, e.g. MyClass.cs
  • In general, prefer one core class per file

Capitalization Conventions

To differentiate words in an identifier, capitalize the first letter of each word in the identifier. Do not use underscores to differentiate words.

Capitalize the first character of each word (including acronyms over two letters in length), as shown in the following examples: PropertyDescriptor, HtmlTag

C# Coding Style

Names of classes, methods, enumerations, public fields, public properties, namespaces:
PascalCase

Names of local variables, parameters:
camelCase

Names of private, protected, internal and protected internal fields and properties:
_camelCase

For casing, a “word” is anything written without internal spaces, including acronyms. For example, MyRpc instead of MyRPC.

Names of interfaces start with I, e.g. IInterface.

Inspiration

These conventions are mainly based on the Microsoft .NET Framework Design Guidelines.
These are noteworthy pages of these guidelines:

The conventions for C# are also based on the Microsoft C# conventions:

Other popular conventions and guidelines (which are similar, but have some conflicting rules):

Note

Microsoft themselves seem to have conflicting rules too:

  • Microsoft Capitalization Conventions:
    Do not use underscores to differentiate words, or for that matter, anywhere in identifiers.
  • Microsoft C# Coding Conventions:
    Use camel casing ("camelCasing") when naming private or internal fields, and prefix them with _.
  • 🤔