-
Notifications
You must be signed in to change notification settings - Fork 367
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.
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 should follow the following structure for consistency:
#region Constants
public const float BLA = 42f;
#endregion
#region Events
public event EventHandler MyEvent;
#endregion
#region Public properties/fields
public bool Toggle;
public string Name { get { return name; } }
#endregion
#region Private/protected variables,
private string name = "undefined";
#endregion
#region Public methods
public void DoSomething() {}
#endregion
#region Unity methods (Awake, Update, etc.)
private void Awake() {}
#endregion
#region Internal methods
internal void DoSomethingInternal() {}
#endregion
#region Protected functions
protected void doSomethingProtected() {}
#endregion
#region Private functions
private void doSomethingPrivate() {}
#endregion
#region Event handlers.
private void eventHandler(object this, EventArgs e) {}
#endregion