|
| 1 | +# EditorConfig is awesome: https://EditorConfig.org |
| 2 | +# .NET coding convention settings for EditorConfig |
| 3 | +# https://learn.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference |
| 4 | +# |
| 5 | +# This file comes from dotnet repositories: |
| 6 | +# https://github.com/dotnet/runtime/blob/master/.editorconfig |
| 7 | +# https://github.com/dotnet/roslyn/blob/master/.editorconfig |
| 8 | + |
| 9 | +# Top-most EditorConfig file |
| 10 | +root = true |
| 11 | + |
| 12 | +[*] |
| 13 | +charset = utf-8 |
| 14 | +# indent_size intentionally not specified in this section |
| 15 | +indent_style = space |
| 16 | +insert_final_newline = true |
| 17 | + |
| 18 | +# Source code |
| 19 | +[*.{cs,ps1,psd1,psm1}] |
| 20 | +indent_size = 4 |
| 21 | + |
| 22 | +# Shell scripts |
| 23 | +[*.sh] |
| 24 | +end_of_line = lf |
| 25 | +indent_size = 4 |
| 26 | + |
| 27 | +# Xml project files |
| 28 | +[*.{csproj,resx,ps1xml}] |
| 29 | +indent_size = 2 |
| 30 | + |
| 31 | +# Data serialization |
| 32 | +[*.{json,yaml,yml}] |
| 33 | +indent_size = 2 |
| 34 | + |
| 35 | +# Markdown |
| 36 | +[*.md] |
| 37 | +indent_size = 2 |
| 38 | + |
| 39 | +# Xml files |
| 40 | +[*.{resx,ruleset,stylecop,xml,xsd,xsl}] |
| 41 | +indent_size = 2 |
| 42 | + |
| 43 | +# Xml config files |
| 44 | +[*.{props,targets,config,nuspec}] |
| 45 | +indent_size = 2 |
| 46 | + |
| 47 | +[*.tsv] |
| 48 | +indent_style = tab |
| 49 | + |
| 50 | +# Dotnet code style settings: |
| 51 | +[*.cs] |
| 52 | +# Sort using and Import directives with System.* appearing first |
| 53 | +dotnet_sort_system_directives_first = true |
| 54 | + |
| 55 | +file_header_template = Copyright (c) Microsoft Corporation.\nLicensed under the MIT License. |
| 56 | + |
| 57 | +# Modifier preferences |
| 58 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion |
| 59 | + |
| 60 | +# Avoid "this." and "Me." if not necessary |
| 61 | +dotnet_style_qualification_for_field = false:suggestion |
| 62 | +dotnet_style_qualification_for_property = false:suggestion |
| 63 | +dotnet_style_qualification_for_method = false:suggestion |
| 64 | +dotnet_style_qualification_for_event = false:suggestion |
| 65 | + |
| 66 | +# Use language keywords instead of framework type names for type references |
| 67 | +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
| 68 | +dotnet_style_predefined_type_for_member_access = true:suggestion |
| 69 | + |
| 70 | +# Name all constant fields using PascalCase |
| 71 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion |
| 72 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields |
| 73 | +dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style |
| 74 | + |
| 75 | +dotnet_naming_symbols.constant_fields.applicable_kinds = field |
| 76 | +dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 77 | + |
| 78 | +dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 79 | + |
| 80 | +# Static fields should have s_ prefix |
| 81 | +dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion |
| 82 | +dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields |
| 83 | +dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style |
| 84 | + |
| 85 | +dotnet_naming_symbols.static_fields.applicable_kinds = field |
| 86 | +dotnet_naming_symbols.static_fields.required_modifiers = static |
| 87 | +dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected |
| 88 | + |
| 89 | +dotnet_naming_style.static_prefix_style.required_prefix = s_ |
| 90 | +dotnet_naming_style.static_prefix_style.capitalization = camel_case |
| 91 | + |
| 92 | +# Internal and private fields should be _camelCase |
| 93 | +dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion |
| 94 | +dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields |
| 95 | +dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style |
| 96 | + |
| 97 | +dotnet_naming_symbols.private_internal_fields.applicable_kinds = field |
| 98 | +dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal |
| 99 | + |
| 100 | +dotnet_naming_style.camel_case_underscore_style.required_prefix = _ |
| 101 | +dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case |
| 102 | + |
| 103 | +# Suggest more modern language features when available |
| 104 | +dotnet_style_object_initializer = true:suggestion |
| 105 | +dotnet_style_collection_initializer = true:suggestion |
| 106 | +dotnet_style_coalesce_expression = true:suggestion |
| 107 | +dotnet_style_null_propagation = true:suggestion |
| 108 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 109 | +dotnet_style_readonly_field = true:suggestion |
| 110 | +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion |
| 111 | +dotnet_style_prefer_inferred_tuple_names = true:suggestion |
| 112 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion |
| 113 | +dotnet_style_prefer_conditional_expression_over_return = true:silent |
| 114 | +dotnet_style_prefer_conditional_expression_over_assignment = true:silent |
| 115 | +dotnet_style_prefer_auto_properties = true:suggestion |
| 116 | +csharp_prefer_simple_default_expression = true:suggestion |
| 117 | + |
| 118 | +dotnet_code_quality_unused_parameters = non_public:suggestion |
| 119 | + |
| 120 | +# CSharp code style settings: |
| 121 | +[*.cs] |
| 122 | + |
| 123 | +csharp_preserve_single_line_blocks = true |
| 124 | +csharp_preserve_single_line_statements = false |
| 125 | +csharp_prefer_braces = true:silent |
| 126 | + |
| 127 | +csharp_prefer_static_local_function = true:suggestion |
| 128 | +csharp_prefer_simple_using_statement = false:none |
| 129 | +csharp_style_prefer_switch_expression = true:suggestion |
| 130 | +csharp_style_prefer_range_operator = false:none |
| 131 | +csharp_style_prefer_index_operator = false:none |
| 132 | +csharp_style_pattern_local_over_anonymous_function = false:none |
| 133 | + |
| 134 | +csharp_using_directive_placement = outside_namespace:suggestion |
| 135 | + |
| 136 | +# Indentation preferences |
| 137 | +csharp_indent_block_contents = true |
| 138 | +csharp_indent_braces = false |
| 139 | +csharp_indent_case_contents = true |
| 140 | +csharp_indent_case_contents_when_block = true |
| 141 | +csharp_indent_switch_labels = true |
| 142 | +csharp_indent_labels = one_less_than_current |
| 143 | + |
| 144 | +# Only use var when it's obvious what the variable type is |
| 145 | +csharp_style_var_for_built_in_types = false:none |
| 146 | +csharp_style_var_when_type_is_apparent = false:none |
| 147 | +csharp_style_var_elsewhere = false:suggestion |
| 148 | + |
| 149 | +# Expression-bodied members |
| 150 | +csharp_style_expression_bodied_local_functions = true:silent |
| 151 | + |
| 152 | +# Prefer method-like constructs to have a block body |
| 153 | +csharp_style_expression_bodied_methods = false:none |
| 154 | +csharp_style_expression_bodied_constructors = false:none |
| 155 | +csharp_style_expression_bodied_operators = false:none |
| 156 | + |
| 157 | +# Prefer property-like constructs to have an expression-body |
| 158 | +csharp_style_expression_bodied_properties = true:none |
| 159 | +csharp_style_expression_bodied_indexers = true:none |
| 160 | +csharp_style_expression_bodied_accessors = true:none |
| 161 | + |
| 162 | +# Suggest more modern language features when available |
| 163 | +csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
| 164 | +csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 165 | +csharp_style_inlined_variable_declaration = true:suggestion |
| 166 | +csharp_style_throw_expression = true:suggestion |
| 167 | +csharp_style_conditional_delegate_call = true:suggestion |
| 168 | + |
| 169 | +# Space preferences |
| 170 | +csharp_space_after_cast = false |
| 171 | +csharp_space_after_colon_in_inheritance_clause = true |
| 172 | +csharp_space_after_comma = true |
| 173 | +csharp_space_after_dot = false |
| 174 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 175 | +csharp_space_after_semicolon_in_for_statement = true |
| 176 | +csharp_space_around_binary_operators = before_and_after |
| 177 | +csharp_space_around_declaration_statements = do_not_ignore |
| 178 | +csharp_space_before_colon_in_inheritance_clause = true |
| 179 | +csharp_space_before_comma = false |
| 180 | +csharp_space_before_dot = false |
| 181 | +csharp_space_before_open_square_brackets = false |
| 182 | +csharp_space_before_semicolon_in_for_statement = false |
| 183 | +csharp_space_between_empty_square_brackets = false |
| 184 | +csharp_space_between_method_call_empty_parameter_list_parentheses = false |
| 185 | +csharp_space_between_method_call_name_and_opening_parenthesis = false |
| 186 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 187 | +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
| 188 | +csharp_space_between_method_declaration_name_and_open_parenthesis = false |
| 189 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 190 | +csharp_space_between_parentheses = false |
| 191 | +csharp_space_between_square_brackets = false |
| 192 | + |
| 193 | +# Newline settings |
| 194 | +csharp_new_line_before_open_brace = all |
| 195 | +csharp_new_line_before_else = true |
| 196 | +csharp_new_line_before_catch = true |
| 197 | +csharp_new_line_before_finally = true |
| 198 | +csharp_new_line_before_members_in_object_initializers = true |
| 199 | +csharp_new_line_before_members_in_anonymous_types = true |
| 200 | +csharp_new_line_between_query_expression_clauses = true |
0 commit comments