Welcome and thank you for your interest in contributing!
Project uses .NET Core 6.0 and 8.0 and it can be debugged using either Visual Studio 2022 or from within Visual Studio Code with C# extensions.
Fixes can be contributed using pull requests. Do note project is under MIT license and any contribution will inherit the same.
This repository uses K&R coding style. Please do make sure any contribution follows coding style already in use. If in doubt, just rely on autoformatting - both VS Code OmniSharp and Visual Studio 2017 editor config are supported.
LF line ending is strongly preferred. To have Git check it for you, configure
core.whitespace setting:
git config core.whitespace blank-at-eol,blank-at-eof,space-before-tab,cr-at-eol
All textual files should be encoded as UTF-8 without BOM.
For the source code files, the general rule to follow is K&R with a sparkling of Visual Studio defaults while using .NET corefx style for corner cases.
-
Use K&R braces, where each brace is placed on the same line as control statement. A single line "if" statement block is allowed but it has to be enclosed in braces.
-
Use four spaces of indentation (no tabs).
-
Use
_camelCasefor internal and private fields and usereadonlywhere possible. Prefix internal and private instance fields with_, static fields withs_and thread static fields witht_. When used on static fields,readonlyshould come afterstatic(e.g.static readonlynotreadonly static). Public fields should be used sparingly and should use PascalCasing with no prefix when used. -
Avoid
this.unless absolutely necessary. -
Always specify the visibility, even if it's the default (e.g.
private string _foonotstring _foo). Visibility should be the first modifier (e.g.public abstractnotabstract public). -
Namespace imports should be specified at the top of the file, outside of
namespacedeclarations, and should be sorted alphabetically, with the exception ofSystem.*namespaces, which are to be placed on top of all others. -
Avoid more than one empty line at any time. For example, do not have two blank lines between members of a type.
-
Avoid spurious free spaces. For example avoid
if (someVar == 0)..., where the dots mark the spurious free spaces. Consider enabling "View White Space (Ctrl+E,S)" if using Visual Studio to aid detection. -
If a file happens to differ in style from these guidelines (e.g. private members are named
m_memberrather than_member), the existing style in that file takes precedence. -
Use of
varis strongly preferred. -
Use language keywords instead of BCL types (e.g.
int,string,floatinstead ofInt32,String,Single, etc) for both type references as well as method calls (e.g.int.Parseinstead ofInt32.Parse). -
Use PascalCasing to name all our constant local variables and fields. The only exception is for interop code where the constant value should exactly match the name and value of the code you are calling via interop.
-
Use
nameof(...)instead of"..."whenever possible and relevant. -
Fields should be specified at the top within type declarations.
-
Non-ASCII characters should use literal characters but unicode escape sequences (
\uXXXX) are acceptable. -
When using labels (for goto), label is aligned to the leftmost position.
There is both .editorconfig for Visual Studio 2019 and above and
omnisharp.json for Visual Studio Code enabling auto-formatting conforming to
the above guidelines.