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