While I don't want to be overly-strict on coding style, there are specific standards to apply. The standards in place aren't meant to cause headache. They are to keep the project consistent and predictable.
- All classes must exist in a logical namespace matching the folder structure.
- Internal API code should be placed in
S1API.Internalsub-namespaces.
namespace S1API.Internal.Utils { ... }- In general, naming follows the default Jetbrains Rider suggestions.
- PascalCase is to be utilized for class names, methods, properties, and non-private fields.
- camelCase is to be used for local variables and private fields.
- Prefix private fields with
_.
private int _myInteger;
public float AddFloats(float floatOne, float floatTwo) => ...- Internal classes must be marked as
internalto prevent confusion for modders. - Modder-facing API classes, methods, properties, and fields should use
public.
public static string GenerateString(int length) { ... }- Explicit usage of access methods at all times.
- Arrow functions (
=>) are used for simple methods and properties. They are to be placed below the declaration and indented once. - Use
readonlyorconstfor immutable values. - Nullable variables should be declared as so using
?.
- All modder-facing API declarations must have an associated summary.
/// <summary>
/// Destroys all game objects in the world.
/// </summary>
public void DestroyGameWorld() { ... }- Use
#if (MONO)and#elif (IL2CPP)for platform-specific logic. - Wrap and alias
usingstatements to provide platform-agonstic support.
- Do not leak Il2Cpp types across the API.
- Utilize
CrossTypehelper methods when possible instead of repeating logic.