root = true [*] indent_style = space indent_size = 4 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.{csproj,props,targets,xml}] indent_size = 2 [*.{json,yml,yaml}] indent_size = 2 [*.proto] indent_size = 2 [*.cs] # Namespace csharp_style_namespace_declarations = file_scoped:warning # Braces — Allman style csharp_new_line_before_open_brace = all # Usings dotnet_sort_system_directives_first = true csharp_using_directive_placement = outside_namespace:warning # var preferences — use var when type is apparent csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion csharp_style_var_elsewhere = true:suggestion # Expression bodies — prefer for simple members csharp_style_expression_bodied_methods = when_on_single_line:suggestion csharp_style_expression_bodied_constructors = false:suggestion csharp_style_expression_bodied_operators = when_on_single_line:suggestion csharp_style_expression_bodied_properties = true:suggestion csharp_style_expression_bodied_accessors = true:suggestion csharp_style_expression_bodied_lambdas = true:suggestion # Pattern matching csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion csharp_style_pattern_matching_over_as_with_null_check = true:suggestion # Null checking csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion # Modifier preferences — exclude interface members (netstandard2.1 compat) dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning # Field naming — _camelCase for private fields dotnet_naming_rule.private_fields_should_be_camel_case.severity = warning dotnet_naming_rule.private_fields_should_be_camel_case.symbols = private_fields dotnet_naming_rule.private_fields_should_be_camel_case.style = camel_case_underscore dotnet_naming_symbols.private_fields.applicable_kinds = field dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, private_protected dotnet_naming_symbols.private_fields.required_modifiers = dotnet_naming_style.camel_case_underscore.required_prefix = _ dotnet_naming_style.camel_case_underscore.capitalization = camel_case # Constants — PascalCase dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants dotnet_naming_rule.constants_should_be_pascal_case.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 # Interfaces — I prefix dotnet_naming_rule.interfaces_should_begin_with_i.severity = warning dotnet_naming_rule.interfaces_should_begin_with_i.symbols = interfaces dotnet_naming_rule.interfaces_should_begin_with_i.style = begins_with_i dotnet_naming_symbols.interfaces.applicable_kinds = interface dotnet_naming_style.begins_with_i.required_prefix = I dotnet_naming_style.begins_with_i.capitalization = pascal_case # Async methods — Async suffix dotnet_naming_rule.async_methods_should_end_with_async.severity = suggestion dotnet_naming_rule.async_methods_should_end_with_async.symbols = async_methods dotnet_naming_rule.async_methods_should_end_with_async.style = ends_with_async dotnet_naming_symbols.async_methods.applicable_kinds = method dotnet_naming_symbols.async_methods.required_modifiers = async dotnet_naming_style.ends_with_async.required_suffix = Async dotnet_naming_style.ends_with_async.capitalization = pascal_case