|
| 1 | +# EditorConfig is awesome:http://EditorConfig.org |
| 2 | + |
| 3 | +# top-most EditorConfig file |
| 4 | +root = true |
| 5 | + |
| 6 | +# Don't use tabs for indentation. |
| 7 | +[*] |
| 8 | +insert_final_newline = false |
| 9 | +end_of_line = crlf |
| 10 | +indent_style = space |
| 11 | + |
| 12 | +# Code files |
| 13 | +[*.{cs,csx,vb,vbx}] |
| 14 | +indent_size = 4 |
| 15 | +charset = utf-8-bom |
| 16 | + |
| 17 | +# XML files |
| 18 | +[*.{xml}] |
| 19 | +indent_size = 2 |
| 20 | +indent_style = space |
| 21 | + |
| 22 | +# Xml project files |
| 23 | +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] |
| 24 | +indent_size = 2 |
| 25 | + |
| 26 | +# Xml config files |
| 27 | +[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
| 28 | +indent_size = 2 |
| 29 | + |
| 30 | +# JSON files |
| 31 | +[*.json] |
| 32 | +indent_size = 2 |
| 33 | + |
| 34 | +# Appveyor yml files |
| 35 | +[{*.yml}] |
| 36 | +indent_style = space |
| 37 | +indent_size = 2 |
| 38 | + |
| 39 | +#################################################################################################################### |
| 40 | + |
| 41 | +# Dotnet code style settings: |
| 42 | +[*.{cs,vb}] |
| 43 | + |
| 44 | +# Naming conventions |
| 45 | + |
| 46 | +# Public methods, properties, fields etc must be PascalCase |
| 47 | + |
| 48 | +dotnet_naming_rule.public_members_must_be_capitalized.symbols = public_symbols |
| 49 | +dotnet_naming_symbols.public_symbols.applicable_kinds = property,method,field,event,delegate,class,struct,interface,enum |
| 50 | +dotnet_naming_symbols.public_symbols.applicable_accessibilities = public |
| 51 | + |
| 52 | +dotnet_naming_rule.public_members_must_be_capitalized.style = first_word_upper_case_style |
| 53 | +dotnet_naming_style.first_word_upper_case_style.capitalization = pascal_case |
| 54 | + |
| 55 | +dotnet_naming_rule.public_members_must_be_capitalized.severity = error |
| 56 | + |
| 57 | +# Local variables (declared inside a method) must be camelCase |
| 58 | + |
| 59 | +dotnet_naming_rule.private_local_fields_must_be_lower.symbols = local_symbols |
| 60 | +dotnet_naming_symbols.local_symbols.applicable_kinds = method,field |
| 61 | +dotnet_naming_symbols.local_symbols.applicable_accessibilities = local |
| 62 | + |
| 63 | +dotnet_naming_rule.private_local_fields_must_be_lower.style = first_letter_lower_case_style |
| 64 | +dotnet_naming_style.first_letter_lower_case_style.capitalization = camel_case |
| 65 | + |
| 66 | +dotnet_naming_rule.private_local_fields_must_be_lower.severity = error |
| 67 | + |
| 68 | +#################################################################################################################### |
| 69 | + |
| 70 | +# Sort using and Import directives with System.* appearing first |
| 71 | +dotnet_sort_system_directives_first = false |
| 72 | + |
| 73 | +#################################################################################################################### |
| 74 | + |
| 75 | +# "This." and "Me." qualifiers |
| 76 | + |
| 77 | +dotnet_style_qualification_for_field = false:error |
| 78 | +dotnet_style_qualification_for_property = false:error |
| 79 | +dotnet_style_qualification_for_method = false:error |
| 80 | +dotnet_style_qualification_for_event = false:error |
| 81 | + |
| 82 | +#################################################################################################################### |
| 83 | + |
| 84 | +# Language keywords instead of framework type names for type references |
| 85 | + |
| 86 | +dotnet_style_predefined_type_for_locals_parameters_members = true:error |
| 87 | +dotnet_style_predefined_type_for_member_access = true:error |
| 88 | + |
| 89 | +#################################################################################################################### |
| 90 | + |
| 91 | +# Modifier preferences |
| 92 | + |
| 93 | +dotnet_style_require_accessibility_modifiers = always |
| 94 | +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async |
| 95 | +visual_basic_preferred_modifier_order = Partial, Default, Private, Protected, Public, Friend, NotOverridable, Overridable, MustOverride, Overloads, Overrides, MustInherit, NotInheritable, Static, Shared, Shadows, ReadOnly, WriteOnly, Dim, Const,WithEvents, Widening, Narrowing, Custom, Async |
| 96 | + |
| 97 | +#################################################################################################################### |
| 98 | + |
| 99 | +# Expression-level preferences |
| 100 | + |
| 101 | +dotnet_style_object_initializer = true:error |
| 102 | +dotnet_style_collection_initializer = true:error |
| 103 | +dotnet_style_explicit_tuple_names = true:error |
| 104 | +dotnet_style_coalesce_expression = true:error |
| 105 | +dotnet_style_null_propagation = true:error |
| 106 | +dotnet_style_prefer_inferred_tuple_names = true:error |
| 107 | +dotnet_style_prefer_inferred_anonymous_type_member_names = true:error |
| 108 | + |
| 109 | +#################################################################################################################### |
| 110 | + |
| 111 | +# Suggest more modern language features when available |
| 112 | +dotnet_style_object_initializer = true:suggestion |
| 113 | +dotnet_style_collection_initializer = true:suggestion |
| 114 | +dotnet_style_coalesce_expression = true:suggestion |
| 115 | +dotnet_style_null_propagation = true:suggestion |
| 116 | +dotnet_style_explicit_tuple_names = true:suggestion |
| 117 | + |
| 118 | +#################################################################################################################### |
| 119 | +#################################################################################################################### |
| 120 | +#################################################################################################################### |
| 121 | +#################################################################################################################### |
| 122 | + |
| 123 | +# CSharp code style settings: |
| 124 | +[*.cs] |
| 125 | + |
| 126 | +#################################################################################################################### |
| 127 | + |
| 128 | +# Implicit and explicit types |
| 129 | + |
| 130 | +# Prefer var x = 5 over int x = 5; |
| 131 | +csharp_style_var_for_built_in_types = true:error |
| 132 | +# Prefer var obj = new Customer(); over Customer obj = new Customer(); |
| 133 | +csharp_style_var_when_type_is_apparent = true:error |
| 134 | +# Prefer var f = this.Init(); over bool f = this.Init(); |
| 135 | +csharp_style_var_elsewhere = true:error |
| 136 | + |
| 137 | +#################################################################################################################### |
| 138 | + |
| 139 | +# Expression-bodied members |
| 140 | + |
| 141 | +# Prefer public int GetAge() => this.Age; over public int GetAge() { return this.Age; } |
| 142 | +csharp_style_expression_bodied_methods = true:none |
| 143 | +# Prefer public Customer(int age) => Age = age; over public Customer(int age) { Age = age; } |
| 144 | +csharp_style_expression_bodied_constructors = true:error |
| 145 | +# Same as above but with operators |
| 146 | +csharp_style_expression_bodied_operators = true:error |
| 147 | + |
| 148 | +# Prefer public int Age => _age; over public int Age { get { return _age; }} |
| 149 | +csharp_style_expression_bodied_properties = true:error |
| 150 | +# Prefer public T this[int i] => _value[i]; over public T this[int i] { get { return _values[i]; } } |
| 151 | +csharp_style_expression_bodied_indexers = true:error |
| 152 | +# Prefer public int Age { get => _age; set => _age = value; } over public int Age { get { return _age; } set { _age = value; } } |
| 153 | +csharp_style_expression_bodied_accessors = true:error |
| 154 | + |
| 155 | +#################################################################################################################### |
| 156 | + |
| 157 | +# Pattern matching |
| 158 | + |
| 159 | +# Prefer if (o is int i) {...} over if (o is int) {var i = (int)o; ... } |
| 160 | +csharp_style_pattern_matching_over_is_with_cast_check = true:error |
| 161 | +# Prefer if (o is string s) {...} over var s = o as string; if (s != null) {...} |
| 162 | +csharp_style_pattern_matching_over_as_with_null_check = true:error |
| 163 | + |
| 164 | +#################################################################################################################### |
| 165 | + |
| 166 | +# Inlined variable declarations |
| 167 | + |
| 168 | +# Prefer if (int.TryParse(value, out int i) {...} over int i; if (int.TryParse(value, out i) {...} |
| 169 | +csharp_style_inlined_variable_declaration = true:error |
| 170 | + |
| 171 | +#################################################################################################################### |
| 172 | + |
| 173 | +# Expression level |
| 174 | + |
| 175 | +csharp_prefer_simple_default_expression = true:error |
| 176 | +csharp_style_deconstructed_variable_declaration = true:suggestion |
| 177 | +csharp_style_pattern_local_over_anonymous_function = true:suggestion |
| 178 | + |
| 179 | +#################################################################################################################### |
| 180 | + |
| 181 | +# Null checking preferences |
| 182 | + |
| 183 | +# Prefer ?? over if (x == null) |
| 184 | +csharp_style_throw_expression = true:warning |
| 185 | +# Prefer x?.Whatever() over if (x == null) |
| 186 | +csharp_style_conditional_delegate_call = true:error |
| 187 | + |
| 188 | +#################################################################################################################### |
| 189 | + |
| 190 | +# Code block preferences |
| 191 | + |
| 192 | +#Prefer if (test) this.Display(); over if (test) { this.Display(); } |
| 193 | +csharp_prefer_braces = false:suggestion |
| 194 | + |
| 195 | +#################################################################################################################### |
| 196 | +#################################################################################################################### |
| 197 | + |
| 198 | +# Newline settings |
| 199 | + |
| 200 | +csharp_new_line_before_open_brace = all |
| 201 | +csharp_new_line_before_else = true |
| 202 | +csharp_new_line_before_catch = true |
| 203 | +csharp_new_line_before_finally = true |
| 204 | +csharp_new_line_before_members_in_object_initializers = true |
| 205 | +csharp_new_line_before_members_in_anonymous_types = true |
| 206 | +csharp_new_line_between_query_expression_clauses = true |
| 207 | + |
| 208 | +#################################################################################################################### |
| 209 | + |
| 210 | +# Indentation options |
| 211 | + |
| 212 | +csharp_indent_case_contents = true |
| 213 | +csharp_indent_switch_labels = true |
| 214 | +csharp_indent_labels= flush_left |
| 215 | + |
| 216 | +#################################################################################################################### |
| 217 | + |
| 218 | +# Spacing Options |
| 219 | + |
| 220 | +csharp_space_after_cast = false |
| 221 | +csharp_space_after_keywords_in_control_flow_statements = true |
| 222 | +csharp_space_between_method_declaration_parameter_list_parentheses = false |
| 223 | +csharp_space_between_method_call_parameter_list_parentheses = false |
| 224 | + |
| 225 | +#################################################################################################################### |
| 226 | + |
| 227 | +# Wrapping options |
| 228 | + |
| 229 | +csharp_preserve_single_line_statements = true |
| 230 | +csharp_preserve_single_line_blocks = true |
| 231 | + |
| 232 | +#################################################################################################################### |
| 233 | +#################################################################################################################### |
| 234 | +#################################################################################################################### |
| 235 | +#################################################################################################################### |
0 commit comments