|
| 1 | +root = true |
| 2 | + |
| 3 | +[*] |
| 4 | +indent_style = space |
| 5 | + |
| 6 | +#-------------------------------------------------------------------------------------------------- |
| 7 | +# XML and JSON files |
| 8 | +#-------------------------------------------------------------------------------------------------- |
| 9 | +[*.{xml,csproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
| 10 | +indent_size = 2 |
| 11 | + |
| 12 | +[*.json] |
| 13 | +indent_size = 2 |
| 14 | + |
| 15 | +#-------------------------------------------------------------------------------------------------- |
| 16 | +# C++ |
| 17 | +#-------------------------------------------------------------------------------------------------- |
| 18 | +[*.{c,cpp,h,hpp,ixx}] |
| 19 | +indent_size = 4 |
| 20 | +charset = utf-8-bom |
| 21 | +trim_trailing_whitespace = true |
| 22 | +insert_final_newline = true |
| 23 | + |
| 24 | +#-------------------------------------------------------------------------------------------------- |
| 25 | +# C# |
| 26 | +#-------------------------------------------------------------------------------------------------- |
| 27 | +# See the following documentation for the C#/.NET-specific rules to follow: |
| 28 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/code-style-rule-options |
| 29 | +[*.{cs,csx}] |
| 30 | +indent_size = 4 |
| 31 | +charset = utf-8-bom |
| 32 | +trim_trailing_whitespace = true |
| 33 | +insert_final_newline = true |
| 34 | + |
| 35 | +#------------------------------------------------------------------------------ |
| 36 | +# Code style rules |
| 37 | +#------------------------------------------------------------------------------ |
| 38 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ |
| 39 | + |
| 40 | +#---------------------------------------------------------- |
| 41 | +# Language Rules |
| 42 | +#---------------------------------------------------------- |
| 43 | + |
| 44 | +# Self access qualification |
| 45 | +dotnet_style_qualification_for_field = false:none |
| 46 | +dotnet_style_qualification_for_property = false:none |
| 47 | +dotnet_style_qualification_for_method = false:none |
| 48 | +dotnet_style_qualification_for_event = false:none |
| 49 | + |
| 50 | +# Language keyword vs full type name |
| 51 | +# Predefined for members, etc does not create a message because the explicitly sized types are conveient in interop scenarios where the bit size matters. |
| 52 | +dotnet_style_predefined_type_for_locals_parameters_members = true:none |
| 53 | +dotnet_style_predefined_type_for_member_access = false:suggestion |
| 54 | + |
| 55 | +# Modifiers |
| 56 | +# csharp_preferred_modifier_order = # Default is fine. It isn't expected this would be overriden in the IDE. |
| 57 | +# We'd like this to be a warning, but it complains on partials in non-primary files. |
| 58 | +dotnet_style_require_accessibility_modifiers = always:none |
| 59 | +dotnet_style_readonly_field = true:suggestion |
| 60 | +csharp_prefer_static_local_function = true:suggestion |
| 61 | + |
| 62 | +# Parentheses |
| 63 | +dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:none |
| 64 | +dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:none |
| 65 | +dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:none |
| 66 | +dotnet_style_parentheses_in_other_operators = never_if_unnecessary:none |
| 67 | + |
| 68 | +# Expression-level preferences |
| 69 | +dotnet_style_object_initializer = true:suggestion |
| 70 | +# This is not enforced because there's too many situations where this hides the variable declaration in a way that harms understanding of the code. |
| 71 | +csharp_style_inlined_variable_declaration = true:none |
| 72 | +dotnet_style_collection_initializer = true:suggestion |
| 73 | +dotnet_style_prefer_auto_properties = true:none |
| 74 | +dotnet_style_explicit_tuple_names = true:warning |
| 75 | +csharp_prefer_simple_default_expression = true:suggestion |
| 76 | +dotnet_style_prefer_inferred_tuple_names = true:none |
| 77 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:none |
| 78 | +csharp_style_pattern_local_over_anonymous_function = true:warning |
| 79 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 80 | +dotnet_style_prefer_conditional_expression_over_assignment = true:none |
| 81 | +dotnet_style_prefer_conditional_expression_over_return = true:none |
| 82 | +dotnet_style_prefer_compound_assignment = true:suggestion |
| 83 | +dotnet_style_prefer_simplified_boolean_expressions = true:none |
| 84 | +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion |
| 85 | + |
| 86 | +# Null checking |
| 87 | +csharp_style_throw_expression = true:none |
| 88 | +dotnet_style_coalesce_expression = true:suggestion |
| 89 | +dotnet_style_null_propagation = true:suggestion |
| 90 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
| 91 | +# Not using safe navigation for event invocation has thread safety problems. |
| 92 | +csharp_style_conditional_delegate_call = true:warning |
| 93 | + |
| 94 | +# Use of `var` |
| 95 | +csharp_style_var_for_built_in_types = false:warning |
| 96 | +# Use target-typed new instead. |
| 97 | +csharp_style_var_when_type_is_apparent = false:warning |
| 98 | +csharp_style_var_elsewhere = false:warning |
| 99 | + |
| 100 | +# Expression-bodied members |
| 101 | +csharp_style_expression_bodied_constructors = true:suggestion |
| 102 | +csharp_style_expression_bodied_methods = true:suggestion |
| 103 | +csharp_style_expression_bodied_operators = true:suggestion |
| 104 | +csharp_style_expression_bodied_properties = true:suggestion |
| 105 | +csharp_style_expression_bodied_indexers = true:suggestion |
| 106 | +csharp_style_expression_bodied_accessors = true:suggestion |
| 107 | +csharp_style_expression_bodied_lambdas = true:suggestion |
| 108 | +csharp_style_expression_bodied_local_functions = true:suggestion |
| 109 | + |
| 110 | +# Pattern matching |
| 111 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 112 | +csharp_style_pattern_matching_over_is_with_cast_check = true:warning |
| 113 | +csharp_style_prefer_switch_expression = true:suggestion |
| 114 | +csharp_style_prefer_pattern_matching = true:none |
| 115 | +csharp_style_prefer_not_pattern = true:suggestion |
| 116 | + |
| 117 | +# Code block preferences |
| 118 | +csharp_prefer_braces = true:warning |
| 119 | +csharp_prefer_simple_using_statement = true:none |
| 120 | + |
| 121 | +# Using directive placement |
| 122 | +csharp_using_directive_placement = outside_namespace:warning |
| 123 | + |
| 124 | +# File header |
| 125 | +file_header_template = unset |
| 126 | + |
| 127 | +#---------------------------------------------------------- |
| 128 | +# Unnecessary code rules |
| 129 | +#---------------------------------------------------------- |
| 130 | +# Simplify member access -- These tend to be more annoying than anything |
| 131 | +dotnet_diagnostic.IDE0002.severity = none |
| 132 | +# Remove unnecessary cast -- Sometimes these clarify the intent of the code. |
| 133 | +dotnet_diagnostic.IDE0004.severity = suggestion |
| 134 | +csharp_style_unused_value_expression_statement_preference = discard_variable |
| 135 | +csharp_style_unused_value_assignment_preference = discard_variable |
| 136 | +dotnet_code_quality_unused_parameters = all |
| 137 | +# Remove unnecessary equality operator -- This covers things like `x == true`, sometimes these clarify the intent of the code. |
| 138 | +dotnet_diagnostic.IDE0100.severity = none |
| 139 | + |
| 140 | +#---------------------------------------------------------- |
| 141 | +# Formatting rules |
| 142 | +#---------------------------------------------------------- |
| 143 | +# (These are mostly Visual Studio defaults, and are simply here to enforce consistency.) |
| 144 | +dotnet_sort_system_directives_first = false |
| 145 | +dotnet_separate_import_directive_groups = false |
| 146 | + |
| 147 | +# Newlines |
| 148 | +csharp_new_line_before_open_brace = all |
| 149 | +csharp_new_line_before_else = true |
| 150 | +csharp_new_line_before_catch = true |
| 151 | +csharp_new_line_before_finally = true |
| 152 | +csharp_new_line_before_members_in_object_initializers = true |
| 153 | +csharp_new_line_before_members_in_anonymous_types = true |
| 154 | +csharp_new_line_between_query_expression_clauses = true |
| 155 | + |
| 156 | +# Indentation |
| 157 | +csharp_indent_case_contents = true |
| 158 | +csharp_indent_switch_labels = true |
| 159 | +csharp_indent_labels = flush_left |
| 160 | +csharp_indent_block_contents = true |
| 161 | +csharp_indent_braces = false |
| 162 | +csharp_indent_case_contents_when_block = false |
| 163 | + |
| 164 | +# Spacing |
| 165 | +csharp_space_after_cast = false |
| 166 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 167 | +csharp_space_between_parentheses = false |
| 168 | +csharp_space_before_colon_in_inheritance_clause = true |
| 169 | +csharp_space_after_colon_in_inheritance_clause = true |
| 170 | +csharp_space_around_binary_operators = before_and_after |
| 171 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 172 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 173 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 174 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 175 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 176 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 177 | +csharp_space_after_comma = true |
| 178 | +csharp_space_before_comma = false |
| 179 | +csharp_space_after_dot = false |
| 180 | +csharp_space_before_dot = false |
| 181 | +csharp_space_after_semicolon_in_for_statement = true |
| 182 | +csharp_space_before_semicolon_in_for_statement = false |
| 183 | +csharp_space_around_declaration_statements = false |
| 184 | +csharp_space_before_open_square_brackets = false |
| 185 | +csharp_space_between_empty_square_brackets = false |
| 186 | +csharp_space_between_square_brackets = false |
| 187 | + |
| 188 | +# Wrapping |
| 189 | +csharp_preserve_single_line_statements = false |
| 190 | +csharp_preserve_single_line_blocks = true |
| 191 | + |
| 192 | +#------------------------------------------------------------------------------ |
| 193 | +# Naming Conventions |
| 194 | +#------------------------------------------------------------------------------ |
| 195 | +# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules |
| 196 | + |
| 197 | +#---------------------------------------------------------- |
| 198 | +# Interfaces |
| 199 | +#---------------------------------------------------------- |
| 200 | +dotnet_naming_style.interface_style.capitalization = pascal_case |
| 201 | +dotnet_naming_style.interface_style.required_prefix = I |
| 202 | + |
| 203 | +dotnet_naming_symbols.interface_symbols.applicable_kinds = interface |
| 204 | +dotnet_naming_symbols.interface_symbols.applicable_accessibilities = * |
| 205 | + |
| 206 | +dotnet_naming_rule.interface_rule.symbols = interface_symbols |
| 207 | +dotnet_naming_rule.interface_rule.style = interface_style |
| 208 | +dotnet_naming_rule.interface_rule.severity = suggestion |
| 209 | + |
| 210 | +#---------------------------------------------------------- |
| 211 | +# Type Parameters |
| 212 | +#---------------------------------------------------------- |
| 213 | +dotnet_naming_style.type_parameter_style.capitalization = pascal_case |
| 214 | +dotnet_naming_style.type_parameter_style.required_prefix = T |
| 215 | + |
| 216 | +dotnet_naming_symbols.type_parameter_symbols.applicable_kinds = type_parameter |
| 217 | +dotnet_naming_symbols.type_parameter_symbols.applicable_accessibilities = * |
| 218 | + |
| 219 | +dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_symbols |
| 220 | +dotnet_naming_rule.type_parameter_rule.style = type_parameter_style |
| 221 | +dotnet_naming_rule.type_parameter_rule.severity = suggestion |
| 222 | + |
| 223 | +#---------------------------------------------------------- |
| 224 | +# Async Methods |
| 225 | +#---------------------------------------------------------- |
| 226 | +dotnet_naming_style.async_method_style.capitalization = pascal_case |
| 227 | +dotnet_naming_style.async_method_style.required_suffix = Async |
| 228 | + |
| 229 | +dotnet_naming_symbols.async_method_symbols.applicable_kinds = method, local_function |
| 230 | +dotnet_naming_symbols.async_method_symbols.applicable_accessibilities = * |
| 231 | +dotnet_naming_symbols.async_method_symbols.required_modifiers = async |
| 232 | + |
| 233 | +dotnet_naming_rule.async_method_rule.symbols = async_method_symbols |
| 234 | +dotnet_naming_rule.async_method_rule.style = async_method_style |
| 235 | +dotnet_naming_rule.async_method_rule.severity = suggestion |
| 236 | + |
| 237 | +#---------------------------------------------------------- |
| 238 | +# General PascalCase Symbols |
| 239 | +#---------------------------------------------------------- |
| 240 | +dotnet_naming_style.pascal_style.capitalization = pascal_case |
| 241 | + |
| 242 | +dotnet_naming_symbols.pascal_symbols.applicable_kinds = namespace, class, struct, interface, enum, property, method, field, event, delegate, type_parameter, local_function |
| 243 | +dotnet_naming_symbols.pascal_symbols.applicable_accessibilities = * |
| 244 | + |
| 245 | +dotnet_naming_rule.pascal_rule.symbols = pascal_symbols |
| 246 | +dotnet_naming_rule.pascal_rule.style = pascal_style |
| 247 | +dotnet_naming_rule.pascal_rule.severity = suggestion |
| 248 | + |
| 249 | +#---------------------------------------------------------- |
| 250 | +# General camelCase Symbols |
| 251 | +#---------------------------------------------------------- |
| 252 | +dotnet_naming_style.camel_style.capitalization = camel_case |
| 253 | + |
| 254 | +dotnet_naming_symbols.camel_symbols.applicable_kinds = parameter, local |
| 255 | +dotnet_naming_symbols.camel_symbols.applicable_accessibilities = * |
| 256 | + |
| 257 | +dotnet_naming_rule.camel_rule.symbols = camel_symbols |
| 258 | +dotnet_naming_rule.camel_rule.style = camel_style |
| 259 | +dotnet_naming_rule.camel_rule.severity = suggestion |
0 commit comments