Skip to content

Coding Guidelines

Alexander Klee edited this page Aug 27, 2021 · 3 revisions

Coding Conventions

In general we follow the C# Coding Conventions. We use EditorConfig to help contributors adhere to these conventions.

Quality assurance

CI workflows use dotnet format with the .editorconfig from staging branch prior to build and test steps.

Enforced rules

The following rules have the severity=error, which will prevent the build from passing.

# Avoid "this." and "Me." if not necessary
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_event = false:error

# Use language keywords instead of framework type names for type references
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error

# IDE0040: Add accessibility modifiers
dotnet_diagnostic.IDE0040.severity = error

# Prefer "var" everywhere
dotnet_diagnostic.IDE0007.severity = error
csharp_style_var_for_built_in_types = false:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error

# Prefer property-like constructs to have an expression-body
csharp_style_expression_bodied_properties = true:error
csharp_style_expression_bodied_indexers = true:error
csharp_style_expression_bodied_accessors = true:error

# Suggest more modern language features when available
csharp_style_pattern_matching_over_is_with_cast_check = true:error
csharp_style_pattern_matching_over_as_with_null_check = true:error
csharp_style_throw_expression = true:error
Clone this wiki locally