Skip to end of metadata
Go to start of metadata

 

Table of Contents

Code formatting

Uncrustify code formatter

A C# compatible Uncrustify configuration is being investigated, however at the moment no such support is available.

Common rules

Curly Brackets

Curly brackets should always be on a new line

if statements

Curly brackets are always required, even for single-expression statements.

Naming conventions

General naming rules

  • Use meaningful variable and type names never use inappropriate language like crap, shit
  • All names and comments should be in American English.
  • Avoid non common abbreviations.
  • Do not write “2” and “4” as replacement for "to" and "for".

Namespaces

Name of a namespace should be in PascalCase.

Always use namespaces to indicate a larger subsystem of the engine, to avoid cluttering the root CryEngine namespace.

Examples

  • CryEngine.EntitySystem
  • CryEngine.FlowSystem
  • CryEngine.Serialization

Class name

Name of a class should be in PascalCase, without any prefixes.

Interface name

Name of an interface should be in PascalCase, prefixed with 'I'.

Enum names

Name of an enum should be descriptive and written in PascalCase. Enums and their values should not utilize prefixes.

Function name

Name of a function should be in PascalCase.

Always use Properties for simple get / set functionality.

Field name

Name of a field should always be prefixed with _ and a camelCase name. Wherever public fields are required, use Properties with automatically generated backing fields.

Property name

Name of a property should always use PascalCase without a prefix.

Whenever a property requires fields, opt for backing fields where possible.

Static class members

Use class members instead of separate managers for finding and manipulating instances.

Comments

Every method and property that's either public or protected must have a summary. Summaries are in XML style and always positioned on the line before the object they describe.

Files

File naming

The source file should always have the same name as the main type that resides inside it. Split out separate classes into multiple files.

Class layout

  • Define members in the following order:
    1. Fields
    2. Properties
    3. Methods
    4. Static Methods

Code quality

Unsafe

Our libraries can never contain unsafe code.

Loops

Use the correct loop for the proper context, for example simply iterating data in a container always use foreach.

  • No labels