Repository navigation
Expand file tree
/
Copy path.editorconfig
More file actions
547 lines (499 loc) · 29.1 KB
/
Copy path.editorconfig
File metadata and controls
547 lines (499 loc) · 29.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# ============================================================================
# VelaShell .editorconfig
#
# 分成两部分:
# 1. 「通用部分」—— 与仓库无关的现代 C#(C# 12 ~ C# 15 / .NET 11)风格,可以整段复制到新项目当默认配置。
# 2. 「仓库特定」—— 只对本仓库成立的分析器取舍(文件末尾,带 banner)。
#
# 严重级别的用法(这决定了 IDE 提示、代码清理和构建三处各看到什么):
# warning 代码已经全部符合,新写的不符合就该被看见。构建里要生效需在 MSBuild 打开
# EnforceCodeStyleInBuild;IDE 里始终生效。
# suggestion 想逐步推进的现代化写法:IDE 里显示「…」提示,代码清理会自动套用。
# silent 交给代码清理去套用、但不想在编辑器里看见任何提示的偏好。
# none 对本仓库是错的规则,代码清理也不会碰。
# 同一条规则同时给了 `选项 = 值:级别` 和 `dotnet_diagnostic.IDExxxx.severity`,两边级别必须一致:
# 两者都在时谁优先取决于工具(VS 看选项后缀,dotnet format 看 dotnet_diagnostic,.NET 9+ 的
# EnforceCodeStyleInBuild 构建看选项后缀),写成一样就不用关心。命名规则(IDE1006)例外:
# 不在全局给它 dotnet_diagnostic,那会把每条命名规则各自的级别压成同一个;代价是命名只在 IDE 里查,
# 不进构建。
# ============================================================================
root = true
# ============================================================================
# 通用部分
# ============================================================================
[*]
charset = utf-8
# 仓库以 LF 入库,.gitattributes 的 `* text=auto eol=lf` 让各平台工作区也签出成 LF。
# 别退回只写 text=auto:Git for Windows 默认 core.autocrlf=true,工作区会变 CRLF,而格式化器在
# 需要重建空白的位置(如 `=>` 与表达式之间夹一行注释)按这里的 lf 写换行,那些 CRLF 就被报成
# IDE0055,CI 的 windows-latest 在 -warnaserror 下编不过。也不要为此改成 crlf。
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{cs,csx,vb,vbx}]
indent_style = space
indent_size = 4
tab_width = 4
# XML 系(项目文件、Avalonia 视图、资源)与 JSON 统一 2 空格:嵌套深,4 空格很快就顶到右边。
[*.{json,jsonc,xml,axaml,xaml,resx,csproj,props,targets,slnx,nuspec,config,runsettings,manifest}]
indent_style = space
indent_size = 2
[*.{yml,yaml}]
indent_style = space
indent_size = 2
# Markdown 的行尾两个空格是硬换行,不能被 trim 掉。
[*.md]
trim_trailing_whitespace = false
# 老式 .sln 由 VS 生成,用 Tab。
[*.sln]
indent_style = tab
# 在 Linux runner 上执行的脚本必须是 LF,否则 shebang 变成 "/usr/bin/env^M"(与 .gitattributes 一致)。
[*.{sh,spec,spec.in}]
end_of_line = lf
[AppRun]
end_of_line = lf
# Windows PowerShell 5.1 把无 BOM 的 .ps1 当 ANSI 读,非 ASCII 字符串直接乱码报错;pwsh 7 两者都认。
[*.{ps1,psm1,psd1}]
charset = utf-8-bom
end_of_line = crlf
[*.{cmd,bat}]
end_of_line = crlf
# ----------------------------------------------------------------------------
# C# —— 语言与表达式风格
# ----------------------------------------------------------------------------
[*.cs]
# ---- using 与命名空间 ----
dotnet_sort_system_directives_first = true
dotnet_separate_import_directive_groups = false
csharp_using_directive_placement = outside_namespace:warning
# 文件范围命名空间是 C# 10 起的默认形态;整仓已是如此,退回块作用域只会多一层缩进。
csharp_style_namespace_declarations = file_scoped:warning
# 命名空间与目录对应关系由人来定(插件目录、测试夹具都有例外),不让分析器改名。
dotnet_style_namespace_match_folder = false
# ---- this. 与内置类型 ----
# 扩展方法调用(this.RaiseAndSetIfChanged / this.WhenAnyValue)语法上必须带 this,分析器不会碰它们。
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_predefined_type_for_locals_parameters_members = true:warning
dotnet_style_predefined_type_for_member_access = true:warning
# ---- 括号 ----
# 混合运算符时保留澄清用的括号;IDE0047 在仓库里已 NoWarn,保持 silent 免得两边打架。
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
# ---- 修饰符 ----
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
dotnet_style_readonly_field = true:warning
# 顺序取自 Roslyn 默认,含 C# 11 的 file/required 与 C# 15 的 closed。
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,closed,sealed,override,readonly,unsafe,required,volatile,async:warning
csharp_prefer_static_local_function = true:warning
# 不捕获任何东西的 lambda 标成 static,避免误捕获 this;逐步推进。
csharp_prefer_static_anonymous_function = true:suggestion
csharp_style_prefer_readonly_struct = true:warning
csharp_style_prefer_readonly_struct_member = true:warning
# ---- 表达式级偏好 ----
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
# 集合表达式(C# 12)是整仓的主写法;loosely_match 让 List<T> 字段也能用 [] 初始化。
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
dotnet_style_prefer_simplified_interpolation = true:suggestion
dotnet_style_prefer_compound_assignment = true:suggestion
# if/else 换三元是口味问题:仓库里 100+ 处 return 分支刻意写成 if/else,不让分析器和清理碰。
dotnet_style_prefer_conditional_expression_over_assignment = false:silent
dotnet_style_prefer_conditional_expression_over_return = false:silent
# foreach 里的隐式向下转型看不见,强类型集合上禁止依赖它。
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed:warning
csharp_style_implicit_object_creation_when_type_is_apparent = true:warning
csharp_style_inlined_variable_declaration = true:warning
csharp_prefer_simple_default_expression = true:warning
csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_style_prefer_index_operator = true:suggestion
csharp_style_prefer_range_operator = true:suggestion
csharp_style_prefer_tuple_swap = true:warning
csharp_style_prefer_utf8_string_literals = true:warning
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
# 丢弃未用返回值(`_ = list.Remove(x);`)整仓有 2400+ 处会被改写,纯噪声,关掉。
csharp_style_unused_value_expression_statement_preference = discard_variable:none
# 不需要的 lambda 包装(x => Foo(x))直接写方法组。
csharp_style_prefer_method_group_conversion = true:suggestion
# C# 14:lambda 参数带 ref/out/in 修饰符时可以省类型;C# 14:nameof(List<>)。
csharp_style_prefer_implicitly_typed_lambda_expression = true:suggestion
csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion
# C# 14:能用 field 关键字化简的属性访问器(IDE0360)。
csharp_style_prefer_simple_property_accessors = true:suggestion
# 预览语言特性:带标签的 break/continue 替代 goto(IDE0410);语言版本不支持时分析器不会触发。
csharp_style_prefer_labeled_jump_statements = true:suggestion
dotnet_prefer_system_hash_code = true:suggestion
# ---- null 检查 ----
dotnet_style_coalesce_expression = true:warning
dotnet_style_null_propagation = true:warning
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
csharp_style_throw_expression = true:warning
csharp_style_conditional_delegate_call = true:warning
csharp_style_prefer_null_check_over_type_check = true:warning
# ---- var ----
# 内置类型与右侧看不出类型时写明类型,右侧已经是 new/强转/字面量时用 var。
csharp_style_var_for_built_in_types = false:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = false:suggestion
# ---- 表达式体成员 ----
# 一行放得下就用 =>。只让清理套用,不提示。
csharp_style_expression_bodied_methods = when_on_single_line:silent
csharp_style_expression_bodied_constructors = when_on_single_line:silent
csharp_style_expression_bodied_operators = when_on_single_line:silent
csharp_style_expression_bodied_properties = when_on_single_line:silent
csharp_style_expression_bodied_indexers = when_on_single_line:silent
csharp_style_expression_bodied_accessors = when_on_single_line:silent
csharp_style_expression_bodied_lambdas = when_on_single_line:silent
csharp_style_expression_bodied_local_functions = when_on_single_line:silent
# ---- 模式匹配 ----
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
csharp_style_pattern_matching_over_as_with_null_check = true:warning
csharp_style_prefer_switch_expression = true:suggestion
csharp_style_prefer_pattern_matching = true:suggestion
csharp_style_prefer_not_pattern = true:warning
csharp_style_prefer_extended_property_pattern = true:warning
# ---- 代码块 ----
# 单语句体允许省花括号(`if (x) return;` 是仓库惯用写法),跨多行的语句体必须加。
csharp_prefer_braces = when_multiline:silent
csharp_prefer_simple_using_statement = true:warning
# lock 语句一律用 System.Threading.Lock(C# 13),object 锁没有作用域检查。
csharp_prefer_system_threading_lock = true:warning
# 只做参数捕获的构造函数改主构造函数(C# 12);已有 350+ 处,余下的逐步推进。
csharp_style_prefer_primary_constructors = true:suggestion
# 顶级语句只在新建控制台程序时有意义,静默;已有显式 Main 的项目不受影响。
csharp_style_prefer_top_level_statements = true:silent
# ---- 参数与成员的使用情况 ----
dotnet_code_quality_unused_parameters = all:suggestion
dotnet_remove_unnecessary_suppression_exclusions = none
# ---- 文件头 ----
file_header_template = unset
# ----------------------------------------------------------------------------
# C# —— 排版(csharp_* 格式化选项,由 IDE0055 / 代码清理「设置文档格式」执行)
# ----------------------------------------------------------------------------
# 换行:Allman 风格,所有花括号独占一行。
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# 缩进
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = one_less_than_current
csharp_indent_block_contents = true
csharp_indent_braces = false
csharp_indent_case_contents_when_block = true
# 空格
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_declaration_name_and_open_parenthesis = false
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_after_comma = true
csharp_space_before_comma = false
csharp_space_after_dot = false
csharp_space_before_dot = false
csharp_space_after_semicolon_in_for_statement = true
csharp_space_before_semicolon_in_for_statement = false
csharp_space_around_declaration_statements = false
csharp_space_before_open_square_brackets = false
csharp_space_between_empty_square_brackets = false
csharp_space_between_square_brackets = false
# 换行保留:{ get; set; } 这类单行块保留;`try { x(); } catch { }`、`if (...) return;` 这类刻意写成一行的语句也保留,
# 设成 false 会把整仓 140 多处这种写法强行拆行。
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
# 长条件折行时运算符放行首,一眼看出这一行是接上一行的。
dotnet_style_operator_placement_when_wrapping = beginning_of_line
# 空行纪律(IDE2000-IDE2006)。多余空行让清理删掉;`=>` 后换行(680+ 处)与单行嵌入语句是仓库惯用写法,放行。
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:silent
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:silent
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:silent
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
# ----------------------------------------------------------------------------
# C# —— 命名(IDE1006)。规则按书写顺序匹配,先具体后宽泛。
# ----------------------------------------------------------------------------
# 接口 IFoo
dotnet_naming_rule.interfaces_begin_with_i.severity = warning
dotnet_naming_rule.interfaces_begin_with_i.symbols = interfaces
dotnet_naming_rule.interfaces_begin_with_i.style = begins_with_i
# 类型参数 TFoo
dotnet_naming_rule.type_parameters_begin_with_t.severity = warning
dotnet_naming_rule.type_parameters_begin_with_t.symbols = type_parameters
dotnet_naming_rule.type_parameters_begin_with_t.style = begins_with_t
# 类型 PascalCase
dotnet_naming_rule.types_pascal_case.severity = warning
dotnet_naming_rule.types_pascal_case.symbols = types
dotnet_naming_rule.types_pascal_case.style = pascal_case
# 常量字段 PascalCase(任何可见性)。局部 const 归局部变量规则管:仓库里 `const double kb = 1024` 这类写法是 camelCase。
dotnet_naming_rule.constants_pascal_case.severity = warning
dotnet_naming_rule.constants_pascal_case.symbols = constants
dotnet_naming_rule.constants_pascal_case.style = pascal_case
# 私有 static readonly 字段 PascalCase —— 它们在用法上等同常量(Timeout、Gate、DefaultTypeface)
dotnet_naming_rule.private_static_readonly_fields_pascal_case.severity = warning
dotnet_naming_rule.private_static_readonly_fields_pascal_case.symbols = private_static_readonly_fields
dotnet_naming_rule.private_static_readonly_fields_pascal_case.style = pascal_case
# 其余私有/内部字段 _camelCase
dotnet_naming_rule.private_fields_underscore_camel_case.severity = warning
dotnet_naming_rule.private_fields_underscore_camel_case.symbols = private_fields
dotnet_naming_rule.private_fields_underscore_camel_case.style = underscore_camel_case
# 公开字段 PascalCase(Avalonia 的 StyledProperty / AttachedProperty 就是这类)
dotnet_naming_rule.public_fields_pascal_case.severity = warning
dotnet_naming_rule.public_fields_pascal_case.symbols = public_fields
dotnet_naming_rule.public_fields_pascal_case.style = pascal_case
# 属性 / 方法 / 事件 PascalCase
dotnet_naming_rule.members_pascal_case.severity = warning
dotnet_naming_rule.members_pascal_case.symbols = members
dotnet_naming_rule.members_pascal_case.style = pascal_case
# 局部函数 PascalCase
dotnet_naming_rule.local_functions_pascal_case.severity = suggestion
dotnet_naming_rule.local_functions_pascal_case.symbols = local_functions
dotnet_naming_rule.local_functions_pascal_case.style = pascal_case
# 局部变量与参数 camelCase
dotnet_naming_rule.locals_and_parameters_camel_case.severity = suggestion
dotnet_naming_rule.locals_and_parameters_camel_case.symbols = locals_and_parameters
dotnet_naming_rule.locals_and_parameters_camel_case.style = camel_case
# 符号
dotnet_naming_symbols.interfaces.applicable_kinds = interface
dotnet_naming_symbols.interfaces.applicable_accessibilities = *
dotnet_naming_symbols.type_parameters.applicable_kinds = type_parameter
dotnet_naming_symbols.type_parameters.applicable_accessibilities = *
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum, delegate
dotnet_naming_symbols.types.applicable_accessibilities = *
dotnet_naming_symbols.constants.applicable_kinds = field
dotnet_naming_symbols.constants.applicable_accessibilities = *
dotnet_naming_symbols.constants.required_modifiers = const
dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = static, readonly
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_symbols.public_fields.applicable_kinds = field
dotnet_naming_symbols.public_fields.applicable_accessibilities = public, protected, protected_internal
dotnet_naming_symbols.members.applicable_kinds = property, event, method
dotnet_naming_symbols.members.applicable_accessibilities = *
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
dotnet_naming_symbols.local_functions.applicable_accessibilities = *
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = local, parameter
dotnet_naming_symbols.locals_and_parameters.applicable_accessibilities = *
# 样式
dotnet_naming_style.begins_with_i.required_prefix = I
dotnet_naming_style.begins_with_i.capitalization = pascal_case
dotnet_naming_style.begins_with_t.required_prefix = T
dotnet_naming_style.begins_with_t.capitalization = pascal_case
dotnet_naming_style.pascal_case.capitalization = pascal_case
dotnet_naming_style.camel_case.capitalization = camel_case
dotnet_naming_style.underscore_camel_case.required_prefix = _
dotnet_naming_style.underscore_camel_case.capitalization = camel_case
# ----------------------------------------------------------------------------
# IDE 诊断级别 —— 给编译器(EnforceCodeStyleInBuild)与 dotnet format 看的那一份,
# 与上面各选项的级别一一对应。没列的 IDE 规则保持 Roslyn 默认。
# ----------------------------------------------------------------------------
# 简化 / 清理类:代码里不该留下这些
# 名称与成员访问的化简(System.Text.Json.JsonValueKind.Null → JsonValueKind.Null)不能进构建,只做提示;仓库里现存约 90 处。
dotnet_diagnostic.IDE0001.severity = suggestion
dotnet_diagnostic.IDE0002.severity = suggestion
dotnet_diagnostic.IDE0004.severity = warning
# 未用的 using —— 需要 GenerateDocumentationFile=true 才能在构建期报出,本仓库已开。
dotnet_diagnostic.IDE0005.severity = warning
dotnet_diagnostic.IDE0035.severity = warning
dotnet_diagnostic.IDE0051.severity = warning
dotnet_diagnostic.IDE0052.severity = warning
dotnet_diagnostic.IDE0059.severity = suggestion
dotnet_diagnostic.IDE0060.severity = suggestion
dotnet_diagnostic.IDE0079.severity = suggestion
dotnet_diagnostic.IDE0080.severity = warning
dotnet_diagnostic.IDE0100.severity = warning
dotnet_diagnostic.IDE0110.severity = warning
dotnet_diagnostic.IDE0240.severity = warning
dotnet_diagnostic.IDE0241.severity = warning
# 风格类
dotnet_diagnostic.IDE0003.severity = warning
dotnet_diagnostic.IDE0009.severity = warning
dotnet_diagnostic.IDE0007.severity = suggestion
dotnet_diagnostic.IDE0008.severity = suggestion
dotnet_diagnostic.IDE0010.severity = silent
dotnet_diagnostic.IDE0011.severity = silent
dotnet_diagnostic.IDE0016.severity = warning
dotnet_diagnostic.IDE0017.severity = suggestion
dotnet_diagnostic.IDE0018.severity = warning
dotnet_diagnostic.IDE0019.severity = warning
dotnet_diagnostic.IDE0020.severity = warning
dotnet_diagnostic.IDE0021.severity = silent
dotnet_diagnostic.IDE0022.severity = silent
dotnet_diagnostic.IDE0023.severity = silent
dotnet_diagnostic.IDE0024.severity = silent
dotnet_diagnostic.IDE0025.severity = silent
dotnet_diagnostic.IDE0026.severity = silent
dotnet_diagnostic.IDE0027.severity = silent
dotnet_diagnostic.IDE0028.severity = suggestion
dotnet_diagnostic.IDE0029.severity = warning
dotnet_diagnostic.IDE0030.severity = warning
dotnet_diagnostic.IDE0031.severity = warning
dotnet_diagnostic.IDE0032.severity = suggestion
dotnet_diagnostic.IDE0033.severity = suggestion
dotnet_diagnostic.IDE0034.severity = warning
dotnet_diagnostic.IDE0036.severity = warning
dotnet_diagnostic.IDE0037.severity = suggestion
dotnet_diagnostic.IDE0038.severity = warning
dotnet_diagnostic.IDE0039.severity = suggestion
dotnet_diagnostic.IDE0040.severity = warning
dotnet_diagnostic.IDE0041.severity = warning
dotnet_diagnostic.IDE0042.severity = suggestion
dotnet_diagnostic.IDE0044.severity = warning
dotnet_diagnostic.IDE0045.severity = silent
dotnet_diagnostic.IDE0046.severity = silent
dotnet_diagnostic.IDE0047.severity = silent
dotnet_diagnostic.IDE0048.severity = silent
dotnet_diagnostic.IDE0049.severity = warning
dotnet_diagnostic.IDE0053.severity = silent
dotnet_diagnostic.IDE0054.severity = suggestion
dotnet_diagnostic.IDE0055.severity = warning
dotnet_diagnostic.IDE0056.severity = suggestion
dotnet_diagnostic.IDE0057.severity = suggestion
dotnet_diagnostic.IDE0058.severity = none
dotnet_diagnostic.IDE0061.severity = silent
dotnet_diagnostic.IDE0062.severity = warning
dotnet_diagnostic.IDE0063.severity = warning
dotnet_diagnostic.IDE0065.severity = warning
dotnet_diagnostic.IDE0066.severity = suggestion
dotnet_diagnostic.IDE0070.severity = suggestion
dotnet_diagnostic.IDE0071.severity = suggestion
dotnet_diagnostic.IDE0072.severity = silent
dotnet_diagnostic.IDE0074.severity = suggestion
dotnet_diagnostic.IDE0075.severity = suggestion
dotnet_diagnostic.IDE0078.severity = suggestion
dotnet_diagnostic.IDE0082.severity = suggestion
dotnet_diagnostic.IDE0083.severity = warning
dotnet_diagnostic.IDE0090.severity = warning
dotnet_diagnostic.IDE0120.severity = suggestion
dotnet_diagnostic.IDE0130.severity = none
dotnet_diagnostic.IDE0150.severity = warning
dotnet_diagnostic.IDE0160.severity = none
dotnet_diagnostic.IDE0161.severity = warning
dotnet_diagnostic.IDE0170.severity = warning
dotnet_diagnostic.IDE0180.severity = warning
dotnet_diagnostic.IDE0200.severity = suggestion
dotnet_diagnostic.IDE0210.severity = silent
dotnet_diagnostic.IDE0211.severity = none
dotnet_diagnostic.IDE0220.severity = warning
dotnet_diagnostic.IDE0230.severity = warning
dotnet_diagnostic.IDE0250.severity = warning
dotnet_diagnostic.IDE0251.severity = warning
dotnet_diagnostic.IDE0260.severity = warning
dotnet_diagnostic.IDE0270.severity = warning
dotnet_diagnostic.IDE0280.severity = suggestion
dotnet_diagnostic.IDE0290.severity = suggestion
dotnet_diagnostic.IDE0300.severity = suggestion
dotnet_diagnostic.IDE0301.severity = suggestion
dotnet_diagnostic.IDE0302.severity = suggestion
dotnet_diagnostic.IDE0303.severity = suggestion
dotnet_diagnostic.IDE0304.severity = suggestion
dotnet_diagnostic.IDE0305.severity = suggestion
dotnet_diagnostic.IDE0306.severity = suggestion
dotnet_diagnostic.IDE0320.severity = suggestion
dotnet_diagnostic.IDE0330.severity = warning
dotnet_diagnostic.IDE0340.severity = suggestion
dotnet_diagnostic.IDE0350.severity = suggestion
dotnet_diagnostic.IDE0360.severity = suggestion
# 多余的 !、unsafe、async 修饰符(Roslyn 5.x 新增)。
dotnet_diagnostic.IDE0370.severity = suggestion
dotnet_diagnostic.IDE0380.severity = suggestion
dotnet_diagnostic.IDE0390.severity = suggestion
dotnet_diagnostic.IDE0391.severity = suggestion
dotnet_diagnostic.IDE0410.severity = suggestion
dotnet_diagnostic.IDE1005.severity = warning
dotnet_diagnostic.IDE2000.severity = suggestion
dotnet_diagnostic.IDE2001.severity = silent
dotnet_diagnostic.IDE2002.severity = silent
dotnet_diagnostic.IDE2003.severity = silent
dotnet_diagnostic.IDE2004.severity = silent
dotnet_diagnostic.IDE2005.severity = silent
dotnet_diagnostic.IDE2006.severity = silent
# ============================================================================
# 仓库特定
# ============================================================================
# ============================================================================
# 性能分析器(CA1xxx)
#
# 这些规则默认是"隐藏"或"建议"级,不会出现在构建输出里 —— 等于白装。这里按仓库实际
# 情况分成三档:开成警告(有价值且已清零)、显式关闭(对本仓库是噪声或会引入 bug)、
# 以及未列出的(保持默认)。
#
# 复现完整清单:
# dotnet build VelaShell.slnx -t:Rebuild -p:AnalysisModePerformance=All
# ============================================================================
# ---- 开成警告:已全部清零,新增即失败 ----------------------------------------
# 私有/内部成员的返回类型用具体类型,省掉接口派发。
dotnet_diagnostic.CA1859.severity = warning
# 常量数组作实参会每次调用重新分配一个数组,应提为 static readonly。
dotnet_diagnostic.CA1861.severity = warning
# 未使用的私有字段 —— 死代码,顺带白占对象大小。
dotnet_diagnostic.CA1823.severity = warning
# StringBuilder.Append 单字符用 char 重载,不走字符串路径。
dotnet_diagnostic.CA1834.severity = warning
# 可索引集合上别用 LINQ(First/Last/Count),索引器不建枚举器。
dotnet_diagnostic.CA1826.severity = warning
# static readonly 能写成 const 的就写 const。
dotnet_diagnostic.CA1802.severity = warning
# 密封内部类型,便于 JIT 去虚化。
dotnet_diagnostic.CA1852.severity = warning
# 不访问实例数据的成员标 static。
# 注:对隐式接口实现会误报(见 NullUiApi.NoopPanel.PlacementRatio,改了编译不过),
# 遇到时按现场判断,不要照搬。
dotnet_diagnostic.CA1822.severity = warning
# ---- 显式关闭:对本仓库不适用 ------------------------------------------------
# CA2007「考虑调用 ConfigureAwait」—— 5400+ 条。本仓库是 GUI 应用:UI 层的 await
# 恰恰需要回到 UI 线程,加 ConfigureAwait(false) 是错的;库层(Core/Infrastructure)
# 已经在该加的地方逐处加了。全局开启只会淹没真正的信号。
dotnet_diagnostic.CA2007.severity = none
# CA2000「离开作用域前释放对象」—— 400+ 条,几乎全是误报:Avalonia 控件的生命周期
# 归可视树管,DI 容器注册的实例归容器管,分析器都看不出来。
dotnet_diagnostic.CA2000.severity = none
# CA1863「缓存 CompositeFormat」—— 本仓库的格式串来自 ResourceManager,每次按
# CurrentUICulture 现取(见 Core/Resources/Strings)。缓存进静态字段会把语言冻结在
# 首次使用那一刻,运行时切语言直接失效 —— 这条建议在这里是 bug 而不是优化。
dotnet_diagnostic.CA1863.severity = none
# CA1819「属性不应返回数组」—— 是 API 设计规则而非性能规则,而本仓库多处刻意返回
# 数组/Span 以避免拷贝(终端网格、协议缓冲)。
dotnet_diagnostic.CA1819.severity = none
# RXUISG0016「把属性换成 [Reactive] 的通知属性」—— ReactiveUI 源生成器对 ReactiveObject 上
# 每个普通属性都提一次。本仓库被它点名的几乎全是不需要通知的:视图注入的回调(Func / Action)、
# init 属性、排序用的分数等内部状态。换成通知属性只是白白多一次 PropertyChanged,
# 真要绑定到界面的属性已经逐个写成 RaiseAndSetIfChanged。
dotnet_diagnostic.RXUISG0016.severity = none
# ---- Win32 互操作结构体 ------------------------------------------------------
# STARTUPINFOEX / PROCESS_INFORMATION 的字段名(cb、lpReserved、dwX、hProcess…)与 WM_* 消息常量
# 照抄 Windows SDK,对着文档能一眼对上;这几个文件不套命名规则。
[{src/VelaShell.Infrastructure/Pty/ConPtyShellStream.cs,src/VelaShell/Views/Win32WindowChrome.cs,src/VelaShell/Views/WindowMoveDrag.cs,src/VelaShell/Program.cs,src/VelaShell.PluginHost/PluginHostShellWindow.cs}]
dotnet_diagnostic.IDE1006.severity = none
# ---- 测试项目的放宽 --------------------------------------------------------
[tests/**.cs]
# CA1861「常量数组作实参应提为 static readonly」在断言里是负优化:
# Assert.AreSequenceEqual(new[] { "a", "b" }, actual) 就该这么写 —— 把期望值搬到类字段上,
# 读的人要来回跳才能知道这条断言在比什么,而"重复调用重复分配"在只跑一次的用例里不存在。
dotnet_diagnostic.CA1861.severity = none
# 测试里的命名更自由(中文、下划线分隔的用例名),只提示不告警。
dotnet_diagnostic.IDE1006.severity = suggestion