Skip to content

Code Style Document

Valk edited this page Jul 29, 2025 · 65 revisions

If the following looks overwhelming to you, you can ignore it, I will try my best to refactor your PRs to conform to these standards.

Formatting

  • Indentation: 4 spaces.
  • Line Endings: LF.
  • Curly Braces: Always expand unless the expression(s) / statement(s) are short.
  • Using Directives: Above namespace.

Naming

  • PascalCase: Types, methods, properties, constants, events.
  • camelCase: Private fields, local variables, method args.
  • Private fields: Always prefix with an underscore.
  • Events: Avoid prefixing events with On as subscribers should use this instead.

Language Features

  • var Keyword: Never use unless the type is absurdly long.
  • C# Events: Always use over Godot signals.
  • Explicit Private Modifiers: Always specify private.
  • File Scoped Namespaces: Always use.

Static

  • Public Functions: Avoid if possible.
  • Private Functions: Use when possible.
  • Events: Never use unless you set them to null on tree exit.

Order of Code

  1. Godot Exports
  2. Events
  3. Public Properties
  4. Public Fields
  5. Private Properties
  6. Private Fields
  7. Godot Overrides
  8. Public Functions
  9. Private Functions
  10. Private Static Functions

Principles

Please familiarize yourself with these principles.

Clone this wiki locally