-
Notifications
You must be signed in to change notification settings - Fork 0
Engineering guidelines
Viktor Stojanović edited this page Aug 8, 2026
·
6 revisions
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.
This section describes the coding rules.
Use the default Visual Studio settings to format code.
- Use four spaces for indentation. Do not use tabs.
- Use
_camelCaseformat 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 ofstring _foo;). - Put opening braces
{on a new line.
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)));
}Use the var keyword when the compiler allows it.
Write doc comments for public APIs. You can also write doc comments for non-public APIs.
Do not use primary constructors.