root = true

[*]
charset = utf-8
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 4

[*.{json,yml,yaml,csproj,props,targets,xaml}]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.cs]
# Namespaces
csharp_style_namespace_declarations = file_scoped:warning

# using directives
dotnet_sort_system_directives_first = true
csharp_using_directive_placement = outside_namespace:warning

# var preferences
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion

# Expression-bodied members
csharp_style_expression_bodied_methods = when_on_single_line:suggestion
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Pattern matching / modern language
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_prefer_primary_constructors = false:suggestion

# null handling
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# this. qualification
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion

# Readonly
dotnet_style_readonly_field = true:suggestion

# Braces / blocks
csharp_prefer_braces = true:suggestion
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true

# Naming: private fields -> _camelCase
dotnet_naming_rule.private_fields_underscore.severity = suggestion
dotnet_naming_rule.private_fields_underscore.symbols = private_fields
dotnet_naming_rule.private_fields_underscore.style = underscore_prefix
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
dotnet_naming_style.underscore_prefix.capitalization = camel_case
dotnet_naming_style.underscore_prefix.required_prefix = _

# Constants -> PascalCase
dotnet_naming_rule.constants_pascal.severity = suggestion
dotnet_naming_rule.constants_pascal.symbols = constants
dotnet_naming_rule.constants_pascal.style = pascal_case
dotnet_naming_symbols.constants.applicable_kinds = field
dotnet_naming_symbols.constants.required_modifiers = const
dotnet_naming_style.pascal_case.capitalization = pascal_case

# CA1716: allow member/parameter names that happen to be VB/other-language
# keywords (Resume, template, ...). Octadock is a C#-only application.
dotnet_diagnostic.CA1716.severity = none

# Interfaces -> IPascalCase
dotnet_naming_rule.interfaces_i_prefix.severity = warning
dotnet_naming_rule.interfaces_i_prefix.symbols = interfaces
dotnet_naming_rule.interfaces_i_prefix.style = i_prefix
dotnet_naming_symbols.interfaces.applicable_kinds = interface
dotnet_naming_style.i_prefix.capitalization = pascal_case
dotnet_naming_style.i_prefix.required_prefix = I

# Relax doc-comment + async naming noise on tests
[tests/**.cs]
dotnet_diagnostic.CS1591.severity = none
dotnet_diagnostic.CA1707.severity = none
dotnet_diagnostic.VSTHRD200.severity = none
