.editorconfig 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ###############################
  2. # Core EditorConfig Options #
  3. ###############################
  4. root = true
  5. # All files
  6. [*]
  7. indent_style = space
  8. # Code files
  9. [*.{cs,csx}]
  10. indent_size = 4
  11. insert_final_newline = false
  12. charset = utf-8-bom
  13. # Xml project files
  14. [*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
  15. indent_size = 2
  16. # Xml config files
  17. [*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
  18. indent_size = 2
  19. # JSON files
  20. [*.{json,travis.yml}]
  21. indent_size = 2
  22. # JS and CSS
  23. [*.{js,css}]
  24. indent_style = space
  25. indent_size = 2
  26. # min files don't reformatting
  27. [*.min.*]
  28. trim_trailing_whitespace = false
  29. insert_final_newline = false
  30. ###############################
  31. # .NET Coding Conventions #
  32. ###############################
  33. [*.{cs,vb}]
  34. # Organize usings
  35. dotnet_sort_system_directives_first = true
  36. dotnet_separate_import_directive_groups = false
  37. # this. preferences
  38. dotnet_style_qualification_for_field = false:suggestion
  39. dotnet_style_qualification_for_property = false:suggestion
  40. dotnet_style_qualification_for_method = false:suggestion
  41. dotnet_style_qualification_for_event = false:suggestion
  42. # Language keywords vs BCL types preferences
  43. dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
  44. dotnet_style_predefined_type_for_member_access = true:suggestion
  45. # Parentheses preferences
  46. dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
  47. dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
  48. dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
  49. dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
  50. # Modifier preferences
  51. dotnet_style_require_accessibility_modifiers = always:suggestion
  52. dotnet_style_readonly_field = false:suggestion
  53. # Expression-level preferences
  54. dotnet_style_object_initializer = true:suggestion
  55. dotnet_style_collection_initializer = true:suggestion
  56. dotnet_style_explicit_tuple_names = true:suggestion
  57. dotnet_style_null_propagation = true:suggestion
  58. dotnet_style_coalesce_expression = true:suggestion
  59. dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
  60. dotnet_style_prefer_inferred_tuple_names = true:suggestion
  61. dotnet_style_prefer_inferred_anonymous_type_member_names = false:suggestion
  62. dotnet_style_prefer_auto_properties = true:silent
  63. dotnet_style_prefer_conditional_expression_over_assignment = true:silent
  64. dotnet_style_prefer_conditional_expression_over_return = true:silent
  65. ###############################
  66. # Naming Conventions #
  67. ###############################
  68. # Style Definitions
  69. dotnet_naming_style.pascal_case_style.capitalization = pascal_case
  70. dotnet_naming_style.camel_case_style.capitalization = camel_case
  71. dotnet_naming_style.upper_case_style.capitalization = all_upper
  72. dotnet_naming_style.upper_case_style.word_separator = _
  73. dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I
  74. dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case
  75. dotnet_naming_style.private_field_style.required_prefix = _
  76. dotnet_naming_style.private_field_style.capitalization = camel_case
  77. # Use all upper for constant fields
  78. dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = warning
  79. dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
  80. dotnet_naming_rule.constant_fields_should_be_pascal_case.style = upper_case_style
  81. dotnet_naming_symbols.constant_fields.applicable_kinds = field
  82. dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
  83. dotnet_naming_symbols.constant_fields.required_modifiers = const
  84. # Use PascalCase for public fields
  85. dotnet_naming_rule.pascal_case_for_public_fields.severity = warning
  86. dotnet_naming_rule.pascal_case_for_public_fields.symbols = public_fields
  87. dotnet_naming_rule.pascal_case_for_public_fields.style = pascal_case_style
  88. dotnet_naming_symbols.public_fields.applicable_kinds = field
  89. dotnet_naming_symbols.public_fields.applicable_accessibilities = public
  90. # Interfaces must be PascalCase and have an I prefix
  91. dotnet_naming_rule.interface_rule.severity = warning
  92. dotnet_naming_rule.interface_rule.symbols = interface_group
  93. dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style
  94. dotnet_naming_symbols.interface_group.applicable_kinds = interface
  95. # Private fields must be camelCase and have an _ prefix
  96. dotnet_naming_rule.private_field_with_.severity = warning
  97. dotnet_naming_rule.private_field_with_.symbols = private_fields
  98. dotnet_naming_rule.private_field_with_.style = private_field_style
  99. dotnet_naming_symbols.private_fields.applicable_accessibilities = private,protected
  100. dotnet_naming_symbols.private_fields.applicable_kinds = field
  101. # Async methods should have "Async" suffix
  102. dotnet_naming_rule.async_methods_end_in_async.severity = suggestion
  103. dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods
  104. dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
  105. dotnet_naming_symbols.any_async_methods.applicable_kinds = method
  106. dotnet_naming_symbols.any_async_methods.applicable_accessibilities = *
  107. dotnet_naming_symbols.any_async_methods.required_modifiers = async
  108. dotnet_naming_style.end_in_async.required_prefix =
  109. dotnet_naming_style.end_in_async.required_suffix = Async
  110. dotnet_naming_style.end_in_async.capitalization = pascal_case
  111. dotnet_naming_style.end_in_async.word_separator =
  112. # Classes, structs, methods, enums, events, properties, namespaces, delegates must be PascalCase
  113. dotnet_naming_rule.general_naming.severity = warning
  114. dotnet_naming_rule.general_naming.symbols = general
  115. dotnet_naming_rule.general_naming.style = pascal_case_style
  116. dotnet_naming_symbols.general.applicable_kinds = class,struct,enum,property,method,event,delegate,namespace
  117. dotnet_naming_symbols.general.applicable_accessibilities = *
  118. # Use PascalCase for type parameters
  119. dotnet_naming_rule.pascal_case_for_type_parameters.severity = suggestion
  120. dotnet_naming_rule.pascal_case_for_type_parameters.symbols = type_parameters
  121. dotnet_naming_rule.pascal_case_for_type_parameters.style = pascal_case_style
  122. dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter
  123. # Everything else is camelCase
  124. dotnet_naming_rule.everything_else_naming.severity = warning
  125. dotnet_naming_rule.everything_else_naming.symbols = everything_else
  126. dotnet_naming_rule.everything_else_naming.style = camel_case_style
  127. dotnet_naming_symbols.everything_else.applicable_kinds = *
  128. dotnet_naming_symbols.everything_else.applicable_accessibilities = *
  129. ###############################
  130. # C# Code Style Rules #
  131. ###############################
  132. [*.cs]
  133. # var preferences
  134. csharp_style_var_for_built_in_types = true:suggestion
  135. csharp_style_var_when_type_is_apparent = true:suggestion
  136. csharp_style_var_elsewhere = true:suggestion
  137. # Expression-bodied members
  138. csharp_style_expression_bodied_methods = false:suggestion
  139. csharp_style_expression_bodied_constructors = false:suggestion
  140. csharp_style_expression_bodied_operators = false:suggestion
  141. csharp_style_expression_bodied_properties = true:suggestion
  142. csharp_style_expression_bodied_indexers = true:suggestion
  143. csharp_style_expression_bodied_accessors = true:suggestion
  144. # Pattern-matching preferences
  145. csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
  146. csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
  147. # Null-checking preferences
  148. csharp_style_throw_expression = true:suggestion
  149. csharp_style_conditional_delegate_call = true:suggestion
  150. # Modifier preferences
  151. csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
  152. # Expression-level preferences
  153. csharp_prefer_braces = false:suggestion
  154. csharp_style_deconstructed_variable_declaration = true:suggestion
  155. csharp_prefer_simple_default_expression = true:suggestion
  156. csharp_style_pattern_local_over_anonymous_function = true:suggestion
  157. csharp_style_inlined_variable_declaration = true:suggestion
  158. csharp_style_prefer_primary_constructors = false:suggestion
  159. dotnet_style_prefer_collection_expression = false:suggestion
  160. ###############################
  161. # C# Formatting Rules #
  162. ###############################
  163. # New line preferences
  164. csharp_new_line_before_open_brace = all
  165. csharp_new_line_before_else = true
  166. csharp_new_line_before_catch = true
  167. csharp_new_line_before_finally = true
  168. csharp_new_line_before_members_in_object_initializers = true
  169. csharp_new_line_before_members_in_anonymous_types = true
  170. csharp_new_line_between_query_expression_clauses = true
  171. # Indentation preferences
  172. csharp_indent_case_contents = true
  173. csharp_indent_switch_labels = true
  174. csharp_indent_labels = no_change
  175. # Space preferences
  176. csharp_space_after_cast = false
  177. csharp_space_after_keywords_in_control_flow_statements = true
  178. csharp_space_between_method_call_parameter_list_parentheses = false
  179. csharp_space_between_method_declaration_parameter_list_parentheses = false
  180. csharp_space_between_parentheses = false
  181. csharp_space_before_colon_in_inheritance_clause = true
  182. csharp_space_after_colon_in_inheritance_clause = true
  183. csharp_space_around_binary_operators = before_and_after
  184. csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
  185. csharp_space_between_method_call_name_and_opening_parenthesis = false
  186. csharp_space_between_method_call_empty_parameter_list_parentheses = false
  187. csharp_space_after_comma = true
  188. csharp_space_after_dot = false
  189. # Wrapping preferences
  190. csharp_preserve_single_line_statements = false
  191. csharp_preserve_single_line_blocks = true
  192. csharp_style_namespace_declarations = file_scoped:suggestion