.editorconfig 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # OmegaAi BackEnd 统一代码格式规范
  2. # 说明:本文件为后端所有微服务共享的代码格式基准。
  3. # 规则以「仅统一格式、不强制重命名」为原则 —— 属性名/方法名与 DB 列名、OmegaRouter URL 字典、前端 match 强绑定,不做自动改名。
  4. root = true
  5. # ============ 基础编码 ============
  6. [*]
  7. end_of_line = lf
  8. indent_style = space
  9. indent_size = 4
  10. trim_trailing_whitespace = true
  11. insert_final_newline = true
  12. # ============ C# 格式规则 ============
  13. [*.cs]
  14. # --- 命名规则:不强制自动重命名(IDE1006)---
  15. dotnet_diagnostic.IDE1006.severity = none
  16. # 保持 block-scoped 命名空间,不自动改为 file-scoped(避免整体重排缩进)
  17. dotnet_diagnostic.IDE0161.severity = none
  18. # 不自动补 private/readonly 等修饰符,避免无关改动
  19. dotnet_diagnostic.IDE0040.severity = none
  20. dotnet_diagnostic.IDE0044.severity = none
  21. # 不自动改 var / 显式类型
  22. dotnet_diagnostic.IDE0007.severity = none
  23. dotnet_diagnostic.IDE0008.severity = none
  24. # 不自动调整未使用参数
  25. dotnet_diagnostic.IDE0060.severity = none
  26. # --- using 指令:System 优先 + 分组排序 ---
  27. dotnet_sort_system_directives_first = true
  28. dotnet_separate_import_directive_groups = true
  29. # --- 大括号:Allman 风格(另起一行)---
  30. csharp_new_line_before_open_brace = all
  31. csharp_new_line_before_else = true
  32. csharp_new_line_before_catch = true
  33. csharp_new_line_before_finally = true
  34. csharp_new_line_before_members_in_object_initializers = true
  35. csharp_new_line_before_members_in_anonymous_types = true
  36. csharp_new_line_between_query_expression_clauses = true
  37. # --- 缩进 ---
  38. csharp_indent_block_contents = true
  39. csharp_indent_braces = false
  40. csharp_indent_case_contents = true
  41. csharp_indent_case_contents_when_block = true
  42. csharp_indent_switch_labels = true
  43. csharp_indent_labels = one_less_than_current
  44. # --- 空格 ---
  45. csharp_space_after_cast = false
  46. csharp_space_after_keywords_in_control_flow_statements = true
  47. csharp_space_between_method_declaration_parameter_list_parentheses = false
  48. csharp_space_between_method_call_parameter_list_parentheses = false
  49. csharp_space_between_parentheses = false
  50. csharp_space_around_binary_operators = before_and_after
  51. csharp_space_after_colon_in_inheritance_clause = true
  52. csharp_space_before_colon_in_inheritance_clause = true
  53. csharp_space_after_comma = true
  54. csharp_space_before_comma = false
  55. csharp_space_after_dot = false
  56. csharp_space_before_dot = false
  57. csharp_space_after_semicolon_in_for_statement = true
  58. csharp_space_before_semicolon_in_for_statement = false
  59. csharp_space_around_declaration_statements = ignore
  60. # --- 表达式级 ---
  61. csharp_style_var_elsewhere = false
  62. csharp_style_expression_bodied_methods = false:silent
  63. csharp_style_expression_bodied_constructors = false:silent
  64. csharp_style_expression_bodied_operators = false:silent
  65. csharp_style_expression_bodied_properties = true:suggestion