Skip to main content

Formatting

Vertical Spacing

The max number of consective vertical spaces (or blank lines) is one (1).

Example

private int health;
private int mana;

private int armorClass;

Avoid vertical spacing in between if and else.

Example

if (maxPower > 10) {
  // Do something
}
else if (maxPower == 10) {
  // Do something
}
else {
  // Do something
}

Opening Curly Bracket

All opening curly brackets ({) should be on the same with the previous syntax.

Examples

if (IsHit) {
  // Do something
}
public class RaceCar {
  // Do something
}
switch (MessageType) {
  case MessageType.Local:
    // Do something
    break;
}

Scoping

Always use open ({) and closed (}) even if it's just a one-liner.

Example

if (!IsActive) {
  return;
}

If Statement

There should be a single space after the if keywords.

Example

if (IsHit) {
  // Do something
}

If-Else Statement

The Opening Curly Bracket rule should be followed on else statement.

Examples

if (maxPower >= 10) {
  // Do something
}
else {
  // Do something
}
if (maxPower > 10) {
  // Do something
}
else if (maxPower == 10) {
  // Do something
}
else {
  // Do something
}

End Of File

The very last character of any source file is a break line - meaning there should be a blank line at the very bottom.

Example

namespace Common {
  public class Car() {
    public void Run() {
      // Do something
    }
  }
}
            // <-- this is the last line that is blank / empty