.editorconfig 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. # Remove the line below if you want to inherit .editorconfig settings from higher directories
  2. root = true
  3. [*]
  4. #### Core EditorConfig Options ####
  5. # Set default charset
  6. charset = utf-8
  7. # Indentation and spacing
  8. indent_size = 4
  9. indent_style = space
  10. tab_width = 4
  11. # New line preferences
  12. end_of_line = lf
  13. insert_final_newline = true
  14. # Markdown, JSON, YAML, props and csproj files
  15. [*.{md,json,yml,props,csproj}]
  16. # Indentation and spacing
  17. indent_size = 2
  18. tab_width = 2
  19. # C# files
  20. [*.cs]
  21. #### .NET Coding Conventions ####
  22. # Organize usings
  23. dotnet_separate_import_directive_groups = false
  24. dotnet_sort_system_directives_first = false
  25. # this. and Me. preferences
  26. dotnet_style_qualification_for_event = false:silent
  27. dotnet_style_qualification_for_field = false:silent
  28. dotnet_style_qualification_for_method = false:silent
  29. dotnet_style_qualification_for_property = false:silent
  30. # Language keywords vs BCL types preferences
  31. dotnet_style_predefined_type_for_locals_parameters_members = true:silent
  32. dotnet_style_predefined_type_for_member_access = true:silent
  33. # Parentheses preferences
  34. dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
  35. dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
  36. dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
  37. dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
  38. # Modifier preferences
  39. dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
  40. # Expression-level preferences
  41. dotnet_style_coalesce_expression = true:suggestion
  42. dotnet_style_collection_initializer = true:suggestion
  43. dotnet_style_explicit_tuple_names = true:suggestion
  44. dotnet_style_null_propagation = true:suggestion
  45. dotnet_style_object_initializer = true:suggestion
  46. dotnet_style_prefer_auto_properties = true:silent
  47. dotnet_style_prefer_compound_assignment = true:suggestion
  48. dotnet_style_prefer_conditional_expression_over_assignment = true:silent
  49. dotnet_style_prefer_conditional_expression_over_return = true:silent
  50. dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
  51. dotnet_style_prefer_inferred_tuple_names = true:suggestion
  52. dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
  53. dotnet_style_prefer_simplified_interpolation = true:suggestion
  54. # Field preferences
  55. dotnet_style_readonly_field = true:suggestion
  56. # Parameter preferences
  57. dotnet_code_quality_unused_parameters = all:silent
  58. #### C# Coding Conventions ####
  59. # Namespace preferences
  60. csharp_style_namespace_declarations = block_scoped:warning
  61. resharper_csharp_namespace_body = block_scoped
  62. # var preferences
  63. csharp_style_var_elsewhere = false:silent
  64. csharp_style_var_for_built_in_types = false:silent
  65. csharp_style_var_when_type_is_apparent = false:silent
  66. # Expression-bodied members
  67. csharp_style_expression_bodied_accessors = true:silent
  68. csharp_style_expression_bodied_constructors = false:silent
  69. csharp_style_expression_bodied_indexers = true:silent
  70. csharp_style_expression_bodied_lambdas = true:silent
  71. csharp_style_expression_bodied_local_functions = false:silent
  72. csharp_style_expression_bodied_methods = false:silent
  73. csharp_style_expression_bodied_operators = false:silent
  74. csharp_style_expression_bodied_properties = true:silent
  75. # Pattern matching preferences
  76. csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
  77. csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
  78. csharp_style_prefer_switch_expression = false:silent
  79. # Null-checking preferences
  80. csharp_style_conditional_delegate_call = true:suggestion
  81. # Modifier preferences
  82. csharp_prefer_static_local_function = true:suggestion
  83. csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent
  84. csharp_style_prefer_readonly_struct = true
  85. csharp_style_prefer_method_group_conversion = true
  86. # Code-block preferences
  87. csharp_prefer_braces = true:silent
  88. csharp_prefer_simple_using_statement = true:suggestion
  89. # Expression-level preferences
  90. csharp_prefer_simple_default_expression = true:suggestion
  91. csharp_style_deconstructed_variable_declaration = true:suggestion
  92. csharp_style_inlined_variable_declaration = true:suggestion
  93. csharp_style_pattern_local_over_anonymous_function = true:suggestion
  94. csharp_style_prefer_index_operator = true:suggestion
  95. csharp_style_prefer_range_operator = true:suggestion
  96. csharp_style_throw_expression = true:suggestion
  97. csharp_style_unused_value_assignment_preference = discard_variable:suggestion
  98. csharp_style_unused_value_expression_statement_preference = discard_variable:silent
  99. csharp_style_implicit_object_creation_when_type_is_apparent = true
  100. # 'using' directive preferences
  101. csharp_using_directive_placement = outside_namespace:silent
  102. #### C# Formatting Rules ####
  103. # New line preferences
  104. csharp_new_line_before_catch = true
  105. csharp_new_line_before_else = true
  106. csharp_new_line_before_finally = true
  107. csharp_new_line_before_members_in_anonymous_types = true
  108. csharp_new_line_before_members_in_object_initializers = true
  109. csharp_new_line_before_open_brace = all
  110. csharp_new_line_between_query_expression_clauses = true
  111. # Indentation preferences
  112. csharp_indent_block_contents = true
  113. csharp_indent_braces = false
  114. csharp_indent_case_contents = true
  115. csharp_indent_case_contents_when_block = true
  116. csharp_indent_labels = one_less_than_current
  117. csharp_indent_switch_labels = true
  118. # Space preferences
  119. csharp_space_after_cast = false
  120. csharp_space_after_colon_in_inheritance_clause = true
  121. csharp_space_after_comma = true
  122. csharp_space_after_dot = false
  123. csharp_space_after_keywords_in_control_flow_statements = true
  124. csharp_space_after_semicolon_in_for_statement = true
  125. csharp_space_around_binary_operators = before_and_after
  126. csharp_space_before_colon_in_inheritance_clause = true
  127. csharp_space_before_comma = false
  128. csharp_space_before_dot = false
  129. csharp_space_before_open_square_brackets = false
  130. csharp_space_before_semicolon_in_for_statement = false
  131. csharp_space_between_empty_square_brackets = false
  132. csharp_space_between_method_call_empty_parameter_list_parentheses = false
  133. csharp_space_between_method_call_name_and_opening_parenthesis = false
  134. csharp_space_between_method_call_parameter_list_parentheses = false
  135. csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
  136. csharp_space_between_method_declaration_name_and_open_parenthesis = false
  137. csharp_space_between_method_declaration_parameter_list_parentheses = false
  138. csharp_space_between_parentheses = false
  139. csharp_space_between_square_brackets = false
  140. # Wrapping preferences
  141. csharp_preserve_single_line_blocks = true
  142. csharp_preserve_single_line_statements = false
  143. #### Naming styles ####
  144. # Naming rules
  145. dotnet_naming_rule.interfaces_should_be_prefixed_with_I.severity = suggestion
  146. dotnet_naming_rule.interfaces_should_be_prefixed_with_I.symbols = interface
  147. dotnet_naming_rule.interfaces_should_be_prefixed_with_I.style = IPascalCase
  148. dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
  149. dotnet_naming_rule.types_should_be_pascal_case.symbols = types
  150. dotnet_naming_rule.types_should_be_pascal_case.style = PascalCase
  151. dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
  152. dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
  153. dotnet_naming_rule.non_field_members_should_be_pascal_case.style = PascalCase
  154. dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.symbols = private_static_readonly_fields
  155. dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.severity = suggestion
  156. dotnet_naming_rule.private_static_readonly_fields_should_be_camel_case_and_prefixed_with__.style = _camelCase
  157. dotnet_naming_rule.local_constants_should_be_pascal_case.symbols = local_constants
  158. dotnet_naming_rule.local_constants_should_be_pascal_case.severity = suggestion
  159. dotnet_naming_rule.local_constants_should_be_pascal_case.style = PascalCase
  160. # Symbol specifications
  161. dotnet_naming_symbols.interface.applicable_kinds = interface
  162. dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
  163. dotnet_naming_symbols.interface.required_modifiers =
  164. dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
  165. dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
  166. dotnet_naming_symbols.types.required_modifiers =
  167. dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
  168. dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
  169. dotnet_naming_symbols.non_field_members.required_modifiers =
  170. dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
  171. dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private
  172. dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static, readonly
  173. dotnet_naming_symbols.local_constants.applicable_kinds = local
  174. dotnet_naming_symbols.local_constants.applicable_accessibilities = local
  175. dotnet_naming_symbols.local_constants.required_modifiers = const
  176. # Naming styles
  177. dotnet_naming_style._camelCase.required_prefix = _
  178. dotnet_naming_style._camelCase.required_suffix =
  179. dotnet_naming_style._camelCase.word_separator =
  180. dotnet_naming_style._camelCase.capitalization = camel_case
  181. dotnet_naming_style.PascalCase.required_prefix =
  182. dotnet_naming_style.PascalCase.required_suffix =
  183. dotnet_naming_style.PascalCase.word_separator =
  184. dotnet_naming_style.PascalCase.capitalization = pascal_case
  185. dotnet_naming_style.IPascalCase.required_prefix = I
  186. dotnet_naming_style.IPascalCase.required_suffix =
  187. dotnet_naming_style.IPascalCase.word_separator =
  188. dotnet_naming_style.IPascalCase.capitalization = pascal_case
  189. # TODO:
  190. # .NET 8 migration (new warnings are caused by the NET 8 C# compiler and analyzer)
  191. # The following info messages might need to be fixed in the source code instead of hiding the actual message
  192. # Without the following lines, dotnet format would fail
  193. # Disable "Collection initialization can be simplified"
  194. dotnet_diagnostic.IDE0028.severity = none
  195. dotnet_diagnostic.IDE0300.severity = none
  196. dotnet_diagnostic.IDE0301.severity = none
  197. dotnet_diagnostic.IDE0302.severity = none
  198. dotnet_diagnostic.IDE0305.severity = none
  199. # Disable "'new' expression can be simplified"
  200. dotnet_diagnostic.IDE0090.severity = none
  201. # Disable "Use primary constructor"
  202. dotnet_diagnostic.IDE0290.severity = none
  203. # Disable "Member '' does not access instance data and can be marked as static"
  204. dotnet_diagnostic.CA1822.severity = none
  205. # Disable "Change type of field '' from '' to '' for improved performance"
  206. dotnet_diagnostic.CA1859.severity = none
  207. # Disable "Prefer 'static readonly' fields over constant array arguments if the called method is called repeatedly and is not mutating the passed array"
  208. dotnet_diagnostic.CA1861.severity = none
  209. # Disable "Prefer using 'string.Equals(string, StringComparison)' to perform a case-insensitive comparison, but keep in mind that this might cause subtle changes in behavior, so make sure to conduct thorough testing after applying the suggestion, or if culturally sensitive comparison is not required, consider using 'StringComparison.OrdinalIgnoreCase'"
  210. dotnet_diagnostic.CA1862.severity = none
  211. [src/Ryujinx/UI/ViewModels/**.cs]
  212. # Disable "mark members as static" rule for ViewModels
  213. dotnet_diagnostic.CA1822.severity = none
  214. [src/Ryujinx.HLE/HOS/Services/**.cs]
  215. # Disable "mark members as static" rule for services
  216. dotnet_diagnostic.CA1822.severity = none
  217. [src/Ryujinx.Tests/Cpu/*.cs]
  218. # Disable naming rules for CPU tests
  219. dotnet_diagnostic.IDE1006.severity = none