Skip to content

Engineering guidelines

Viktor Stojanović edited this page Aug 7, 2026 · 6 revisions

Copyright & License

All source code files (src/*.cs) require this exact header:

// Copyright (c) 2026 Viktor Stojanović. All rights reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

Coding guidelines

Coding style - general

Use the default Visual Studio settings to format code.

  • Use four spaces for indentation. Do notuse tabs.
  • Use _camelCase format for private fields.
  • Do not use this. unless it is required.
  • Write the visibility for every member, including default members (for example, private string _foo; instead of string _foo;).
  • Put opening braces { on a new line.

Usage of var keyword

Use the var keyword when the compiler allows it.

Use C# type keywords in favor of .NET type names

When a type has a C# keyword, use the keyword instead of the .NET type name.

For example, this example is correct:

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T* Allocate<T>(long count) where T : unmanaged
{
    return (T*)NativeMemory.Alloc((nuint)(count * sizeof(T)));
}

This example is incorrect:

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public T* Allocate<T>(Int64 count) where T : unmanaged
{
    return (T*)NativeMemory.Alloc((UIntPtr)(count * sizeof(T)));
}

Documentation (doc) comments

Write doc comments for public APIs. You can also write doc comments for non-public APIs.

Clone this wiki locally