Skip to content

Code Conventions

Valentin Simonov edited this page Feb 5, 2014 · 2 revisions

If you are going to contribute to the project please read this document and follow guidelines.
Let's keep the code clean and consistent.

Naming styles

Mostly following MSDN C# guidelines.

  • Types and namespaces: UpperCamelCase,
  • Interfaces: IUpperCamelCase,
  • Public methods, properties, fields, events: UpperCamelCase,
  • Private/protected methods, properties, fields: lowerCamelCase (no damn prefixes),
  • Static readonly/const fields: ALL_UPPER.


  • 4 spaces instead of tabs,
  • Curly braces mostly must be on the next line,
  • No space between method names and braces in method calls.

Class layout

Class layout should follow the following structure for consistency:

#region Constants
public const float BLA = 42f;

#region Events
public event EventHandler MyEvent;

#region Public properties/fields
public bool Toggle;
public string Name { get { return name; } }

#region Private/protected variables,
private string name = "undefined";

#region Public methods
public void DoSomething() {}

#region Unity methods (Awake, Update, etc.)
private void Awake() {}

#region Internal methods
internal void DoSomethingInternal() {}

#region Protected functions
protected void doSomethingProtected() {}

#region Private functions
private void doSomethingPrivate() {}

#region Event handlers.
private void eventHandler(object this, EventArgs e) {}
You can’t perform that action at this time.