Code Standards & Conventions
Sources
docs/code-style-guidelines.md— Full naming and formatting rulesdocs/standards.md— Performance, memory, and quality standardsdocs/branch-and-pr-standards.md— Git workflow and PR conventionsCLAUDE.md— Condensed project rules
Naming Conventions
| Scope | Style | Example |
|-------|-------|---------|
| Namespaces, classes, structs, interfaces, enums, public methods/properties/fields | PascalCase | BillboardSystem, Update() |
| Non-public fields/properties, parameters, locals | camelCase | exposedCameraData, cameraPosition |
| Constants, static readonly | ALL_UPPER_SNAKE_CASE | MINIMUM_DISTANCE_TO_ROTATE_SQR |
| Interfaces | I prefix | IExposedCameraData |
| Async methods | Async suffix | InitializeAsync, LoginAsync |
| Events | Past tense, no On prefix | ViewShowingComplete |
| Unused parameters | _, __, ___ | Update(float _) |
Exception: serialized JSON DTO fields keep their wire-format casing — see Serialized JSON DTOs below.
Names state what the code knows or decides, never what it assumes happens elsewhere. A flag, field or parameter is named for the fact it holds or the behaviour it switches, not for an outcome some other layer may or may not produce. DeployCmd.CreatesProfile overstated what the client can know (it cannot tell whether a deploy creates the profile; it only knows the last fetch found none) and became WasLastProfileMissing; once the condition grew beyond "missing", it was renamed after the behaviour it controls, FillEmptyEmoteWheel. When the meaning of a value changes, rename it with its doc comment and the tests that mention it.
Namespaces are domain names, not folder paths — never suppress a folder-namespace mismatch with // ReSharper disable once CheckNamespace; fix the namespace or leave the warning visible. Full rule: docs/code-style-guidelines.md § Namespaces.
Member Ordering
Within a class, group members in this order:
- Enums / delegates
- Fields
- Properties
- Events
- Methods
- Nested classes
Within each group, order by visibility: public → internal → protected internal → protected → private.
Field ordering within visibility:
const/static readonlystaticreadonly- Regular public fields
[SerializeField]fields- Non-public fields
Method ordering:
- Constructor / setup
- Destructor / Dispose
- Public APIs
- Unity callbacks
- Internal methods
- Protected methods
- Private helpers (placed after the methods that call them)
Code Example — Member Ordering
From BillboardSystem.cs:
public partial class BillboardSystem : BaseUnityLoopSystem
{
// 1. Constants first
private const float MINIMUM_DISTANCE_TO_ROTATE_SQR = 0.25f * 0.25f;
// 2. Readonly fields
private readonly IExposedCameraData exposedCameraData;
// 3. Constructor (internal visibility — see CLAUDE.md §1)
internal BillboardSystem(World world, IExposedCameraData exposedCameraData) : base(world)
{
this.exposedCameraData = exposedCameraData;
}
// 4. Override method (Update is the system's main entry point)
protected override void Update(float t)
{
// ...
UpdateRotationQuery(World, cameraPosition, cameraRotationAxisZ);
}
// 5. Private helper — placed after the method that calls it
[Query]
private void UpdateRotation(
[Data] in Vector3 cameraPosition,
[Data] in Quaternion cameraRotationAxisZ,
ref TransformComponent transform,
in PBBillboard billboard)
{
// ...
}
}
Formatting
- Indentation: 4 spaces (no tabs)
- Braces: Allman/BSD style — opening brace on new line
var: Only when type is evident from the right side- No LINQ — allocates too much memory; use loops
- String interpolation: Use
$""not+concatenation - Expression-bodied properties: Same line. Expression-bodied methods: new line.
- Unity callbacks: Always use braces (even single-line)
- Follow