A combination of,
The main differences compared to RehanSaeed/EditorConfig is in the following,
Adapted from dotnet/runtime
- We use
_camelCase
for internal and private fields and usereadonly
where possible. Prefix internal and private instance fields with_
, static fields withs_
and thread static fields witht_
. When used on static fields,readonly
should come afterstatic
(e.g.static readonly
notreadonly static
). Public fields should be used sparingly and should use PascalCasing with no prefix when used. - We avoid
this.
unless absolutely necessary. - Namespace imports should be specified at the top of the file, outside of
namespace
declarations, and should be sorted alphabetically, with the exception ofSystem.*
namespaces, which are to be placed on top of all others. - Prefers the use of conditional expression for assignment and return.
- We only use
var
when the type is explicitly named on the right-hand side, typically due to eithernew
or an explicit cast, e.g.var stream = new FileStream(...)
notvar stream = OpenStandardInput()
.- Similarly, target-typed
new()
can only be used when the type is explicitly named on the left-hand side, in a variable definition statement or a field definition statement. e.g.FileStream stream = new(...);
, but notstream = new(...);
(where the type was specified on a previous line).
- Similarly, target-typed
csharp_indent_labels
set toone_less_than_current
: See optionscsharp_indent_case_contents_when_block
set totrue
: See optionscsharp_space_around_declaration_statements
set todo_not_ignore
(❔as per this, the options areignore
,false
but most dotnet repos set todo_not_ignore
).- We use PascalCasing to name all our constant local variables and fields.