.editorconfig 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. # root = true
  2. # Severities:
  3. # error (error)
  4. # warning (warning)
  5. # suggestion (info)
  6. # silent (hint)
  7. # none (suppressed)
  8. # default
  9. [*]
  10. indent_style = space
  11. end_of_line = lf
  12. charset = utf-8
  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. # Csharp files
  20. [*.{cs,csx,vb,vbx}]
  21. indent_size = 4
  22. tab_width = 4
  23. insert_final_newline = true
  24. # Coding style
  25. [*.cs]
  26. ### Language Rules ###
  27. ## 'this' and 'Me' preferences (IDE0003 and IDE0009) ##
  28. dotnet_style_qualification_for_field = false
  29. dotnet_style_qualification_for_property = false
  30. dotnet_style_qualification_for_method = false
  31. dotnet_style_qualification_for_event = false
  32. ## Use language keywords instead of framework type names for type references (IDE0049) ##
  33. dotnet_style_predefined_type_for_locals_parameters_members = true
  34. dotnet_style_predefined_type_for_member_access = true
  35. ## Modifier Preferences ##
  36. csharp_preferred_modifier_order = public, private, protected, internal, static, extern, new, virtual, abstract, sealed, override, readonly, unsafe, volatile, async:silent
  37. dotnet_style_require_accessibility_modifiers = for_non_interface_members
  38. dotnet_style_readonly_field = true
  39. csharp_prefer_static_local_function = true
  40. # Make struct fields writable (IDE0064)
  41. dotnet_diagnostic.IDE0064.severity = warning
  42. ## Parentheses preferences (IDE0047 and IDE0048) ##
  43. dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary
  44. dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary
  45. dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary
  46. dotnet_style_parentheses_in_other_operators = never_if_unnecessary
  47. ## Expression-level preferences ##
  48. # Add missing cases to switch statement
  49. dotnet_diagnostic.IDE0010.severity = silent
  50. dotnet_style_object_initializer = true
  51. dotnet_style_collection_initializer = true
  52. dotnet_style_prefer_auto_properties = true
  53. dotnet_style_explicit_tuple_names = true
  54. dotnet_style_prefer_inferred_tuple_names = true
  55. dotnet_style_prefer_inferred_anonymous_type_member_names = true
  56. dotnet_style_prefer_conditional_expression_over_assignment = true
  57. dotnet_style_prefer_conditional_expression_over_return = true
  58. dotnet_style_prefer_compound_assignment = true
  59. # Use 'System.HashCode.Combine'
  60. # dotnet_diagnostic.IDE0070.severity = suggestion
  61. dotnet_style_prefer_simplified_interpolation = true
  62. dotnet_style_prefer_simplified_boolean_expressions = true
  63. # Convert typeof to nameof
  64. # dotnet_diagnostic.IDE0082.severity = warning
  65. csharp_style_inlined_variable_declaration = true
  66. csharp_prefer_simple_default_expression = true
  67. # was csharp_style_pattern_local_over_anonymous_function
  68. csharp_style_prefer_local_over_anonymous_function = true
  69. csharp_style_deconstructed_variable_declaration = true
  70. csharp_style_prefer_index_operator = true
  71. csharp_style_prefer_range_operator = true
  72. csharp_style_implicit_object_creation_when_type_is_apparent = true
  73. ## Null-checking preferences ##
  74. dotnet_style_coalesce_expression = true
  75. dotnet_style_null_propagation = true
  76. dotnet_style_prefer_is_null_check_over_reference_equality_method = true
  77. # NOTE: These two don't work
  78. csharp_style_throw_expression = true
  79. csharp_style_conditional_delegate_call = true
  80. ## Require file header (IDE0073) ##
  81. file_header_template = unset
  82. ## 'var' preferences (IDE0007 and IDE0008) ##
  83. csharp_style_var_for_built_in_types = true
  84. csharp_style_var_when_type_is_apparent = true
  85. csharp_style_var_elsewhere = true
  86. ## Expression-bodied-members ##
  87. csharp_style_expression_bodied_constructors = true
  88. csharp_style_expression_bodied_methods = true
  89. csharp_style_expression_bodied_operators = true
  90. csharp_style_expression_bodied_properties = true
  91. csharp_style_expression_bodied_indexers = true
  92. csharp_style_expression_bodied_accessors = true
  93. csharp_style_expression_bodied_lambdas = true
  94. csharp_style_expression_bodied_local_functions = true
  95. ## Pattern matching preferences ##
  96. csharp_style_pattern_matching_over_as_with_null_check = true
  97. csharp_style_pattern_matching_over_is_with_cast_check = true
  98. csharp_style_prefer_switch_expression = true
  99. csharp_style_prefer_pattern_matching = true
  100. csharp_style_prefer_not_pattern = true
  101. ## Code block preferences ##
  102. csharp_prefer_braces = false:suggestion
  103. csharp_prefer_simple_using_statement = true
  104. ## 'using' directive preferences ##
  105. csharp_using_directive_placement = outside_namespace
  106. ### Unnecessary Code Rules ###
  107. csharp_style_unused_value_expression_statement_preference = discard_variable
  108. # Remove unnecessary expression value
  109. dotnet_diagnostic.IDE0058.severity = none
  110. csharp_style_unused_value_assignment_preference = discard_variable
  111. dotnet_code_quality_unused_parameters = all
  112. ### Formatting Rules ###
  113. ## Organize usings ##
  114. dotnet_sort_system_directives_first = true
  115. dotnet_separate_import_directive_groups = false
  116. ## Namespace options ##
  117. dotnet_style_namespace_match_folder = true
  118. csharp_style_namespace_declarations = file_scoped
  119. ### Undocumented Rules ###
  120. # prefer is null rather than is {}
  121. csharp_style_prefer_null_check_over_type_check = true
  122. # prefer (a, b) = (b, a)
  123. csharp_style_prefer_tuple_swap = true
  124. # prefer e is MethodCallExpression { Method.Name: "MethodName" }
  125. csharp_style_prefer_extended_property_pattern = true
  126. # options are (end|beginning)_of_line
  127. dotnet_style_operator_placement_when_wrapping = beginning_of_line
  128. csharp_style_prefer_method_group_conversion = true
  129. ## Experimental Rules ##
  130. dotnet_style_allow_statement_immediately_after_block_experimental = false
  131. dotnet_style_allow_multiple_blank_lines_experimental = false
  132. csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
  133. csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
  134. csharp_style_allow_embedded_statements_on_same_line_experimental = false