215 lines
11 KiB
INI
215 lines
11 KiB
INI
###############################
|
||
# 核心编辑器配置选项 #
|
||
###############################
|
||
root = true
|
||
# All files
|
||
[*]
|
||
indent_style = space
|
||
|
||
# XML project files
|
||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
|
||
indent_size = 2
|
||
|
||
# XML config files
|
||
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
|
||
indent_size = 2
|
||
[*.cs]
|
||
end_of_line = lf #指定换行符的类型,可以是lf(Unix/Linux)、crlf(Windows)或cr(老式的Mac OS)。
|
||
# Code files
|
||
[*.{cs,csx,vb,vbx}]
|
||
indent_size = 4
|
||
insert_final_newline = true
|
||
charset = utf-8 #设置文件字符集为utf-8,在 Linux 系统中,通常推荐使用 UTF-8 而不是 UTF-8 with BOM。添加 BOM 可能会干扰那些不期望在文件开头出现非 ASCII 字节的软件对 UTF-8 的使用。
|
||
###############################
|
||
# .NET 编码约定 #
|
||
###############################
|
||
[*.{cs,vb}]
|
||
|
||
# 组织 using 指令,将系统引用放在前面
|
||
dotnet_sort_system_directives_first = true
|
||
|
||
# this. 语法的偏好设置
|
||
dotnet_style_qualification_for_field = false:silent # 对字段使用 this. 语法时,不强制要求
|
||
dotnet_style_qualification_for_property = false:silent # 对属性使用 this. 语法时,不强制要求
|
||
dotnet_style_qualification_for_method = false:silent # 对方法使用 this. 语法时,不强制要求
|
||
dotnet_style_qualification_for_event = false:silent # 对事件使用 this. 语法时,不强制要求
|
||
|
||
# 语言关键字与 BCL(基类库)类型的偏好设置
|
||
dotnet_style_predefined_type_for_locals_parameters_members = true:silent # 推荐在局部变量、参数和成员中使用语言关键字而不是 BCL 类型
|
||
dotnet_style_predefined_type_for_member_access = true:silent # 推荐在成员访问中使用语言关键字而不是 BCL 类型
|
||
|
||
# 括号的偏好设置
|
||
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent # 推荐在算术二元运算符周围始终使用括号以增强清晰度
|
||
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent # 推荐在关系二元运算符周围始终使用括号以增强清晰度
|
||
dotnet_style_parentheses_in_other_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:silent # 针对非接口成员,推荐添加访问修饰符
|
||
dotnet_style_readonly_field = true:suggestion # 推荐将字段声明为只读
|
||
dotnet_style_object_initializer = true:suggestion # 推荐使用对象初始化器
|
||
dotnet_style_collection_initializer = true:suggestion # 推荐使用集合初始化器
|
||
dotnet_style_explicit_tuple_names = true:suggestion # 推荐使用显式的元组成员命名
|
||
dotnet_style_null_propagation = true:suggestion # 推荐使用 null 条件运算符(?.)进行空引用检查
|
||
dotnet_style_coalesce_expression = true:suggestion # 推荐使用空值合并运算符(??)
|
||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent # 在检查是否为 null 时,推荐使用 is 运算符而不是引用相等方法
|
||
dotnet_style_prefer_inferred_tuple_names = true:suggestion # 推荐使用推断的元组成员命名
|
||
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion # 推荐使用推断的匿名类型成员命名
|
||
dotnet_style_prefer_auto_properties = true:silent # 推荐使用自动属性
|
||
dotnet_style_prefer_conditional_expression_over_assignment = true:silent # 推荐使用条件表达式而不是赋值表达式
|
||
dotnet_style_prefer_conditional_expression_over_return = true:silent # 推荐使用条件表达式而不是 return 语句
|
||
|
||
###############################
|
||
# 命名约定 #
|
||
###############################
|
||
|
||
# 样式定义
|
||
dotnet_naming_style.pascal_case_style.capitalization = pascal_case # 使用 PascalCase 风格
|
||
|
||
# 命名规则:常量字段应使用 PascalCase 风格
|
||
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion # 规则严重程度为建议
|
||
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields # 适用于 constant_fields 符号
|
||
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style # 风格为 PascalCase
|
||
|
||
# 常量字段的符号定义
|
||
dotnet_naming_symbols.constant_fields.applicable_kinds = field # 适用于字段
|
||
dotnet_naming_symbols.constant_fields.applicable_accessibilities = * # 适用于所有可见性(public、internal、private 等)
|
||
dotnet_naming_symbols.constant_fields.required_modifiers = const # 必须具有 const 修饰符
|
||
|
||
###############################
|
||
# C# 编码约定 #
|
||
###############################
|
||
[*.cs]
|
||
|
||
# var 的偏好设置
|
||
csharp_style_var_for_built_in_types = true:silent # 当变量的类型是内置类型时,使用 var
|
||
csharp_style_var_when_type_is_apparent = true:silent # 当变量类型明显时,使用 var
|
||
csharp_style_var_elsewhere = true:silent # 在其他情况下,也使用 var
|
||
|
||
# 表达式主体成员的偏好设置
|
||
csharp_style_expression_bodied_methods = false:silent # 不使用表达式主体的方法
|
||
csharp_style_expression_bodied_constructors = false:silent # 不使用表达式主体的构造函数
|
||
csharp_style_expression_bodied_operators = false:silent # 不使用表达式主体的运算符
|
||
csharp_style_expression_bodied_properties = true:silent # 使用表达式主体的属性
|
||
csharp_style_expression_bodied_indexers = true:silent # 使用表达式主体的索引器
|
||
csharp_style_expression_bodied_accessors = true:silent # 使用表达式主体的访问器
|
||
|
||
# 模式匹配的偏好设置
|
||
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion # 推荐使用模式匹配而非 is 与类型转换检查
|
||
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion # 推荐使用模式匹配而非 as 与 null 检查
|
||
|
||
# 空检查的偏好设置
|
||
csharp_style_throw_expression = true:suggestion # 推荐使用 throw 表达式
|
||
csharp_style_conditional_delegate_call = true:suggestion # 推荐使用条件委托调用
|
||
|
||
# 修饰符的偏好设置
|
||
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async:suggestion # 修饰符的推荐顺序
|
||
|
||
# 表达式级别的偏好设置
|
||
csharp_prefer_braces = true:silent # 推荐使用大括号,即使在可能省略的情况下
|
||
csharp_style_deconstructed_variable_declaration = true:suggestion # 推荐使用解构变量声明
|
||
csharp_prefer_simple_default_expression = true:suggestion # 推荐使用简化的默认值表达式
|
||
csharp_style_prefer_local_over_anonymous_function = true:suggestion # 推荐使用本地函数而非匿名函数
|
||
csharp_style_inlined_variable_declaration = true:suggestion # 推荐内联变量声明
|
||
|
||
###############################
|
||
# C# 格式化规则 #
|
||
###############################
|
||
# 新行偏好设置
|
||
|
||
# 在大括号前添加新行(适用于所有情况)
|
||
csharp_new_line_before_open_brace = all
|
||
|
||
# 在 "else" 关键字前添加新行
|
||
csharp_new_line_before_else = true
|
||
|
||
# 在 "catch" 关键字前添加新行
|
||
csharp_new_line_before_catch = true
|
||
|
||
# 在 "finally" 关键字前添加新行
|
||
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
|
||
|
||
# 缩进偏好设置
|
||
|
||
# 缩进 switch 语句的内容
|
||
csharp_indent_case_contents = true
|
||
|
||
# 缩进 switch 语句的标签
|
||
csharp_indent_switch_labels = true
|
||
|
||
# 缩进左对齐 switch 语句的标签
|
||
csharp_indent_labels = flush_left
|
||
|
||
# 空间首选项
|
||
# 禁止在强制类型转换后添加空格
|
||
csharp_space_after_cast = false
|
||
|
||
# 在控制流语句(如 if、for、while)的关键字后添加空格
|
||
csharp_space_after_keywords_in_control_flow_statements = true
|
||
|
||
# 在方法调用的参数列表的括号内禁止添加空格
|
||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||
|
||
# 在方法声明的参数列表的括号内禁止添加空格
|
||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||
|
||
# 在圆括号内禁止添加空格
|
||
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_empty_parameter_list_parentheses = false
|
||
|
||
# 在方法调用的方法名和左括号之间禁止添加空格
|
||
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||
|
||
# 在方法调用的空参数列表的括号内禁止添加空格
|
||
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||
|
||
# 包装偏好设置
|
||
csharp_preserve_single_line_statements = true # 保留单行语句的换行风格
|
||
csharp_preserve_single_line_blocks = true # 保留单行块的换行风格
|
||
# C# using 指令的放置偏好设置
|
||
csharp_using_directive_placement = outside_namespace:silent # 在命名空间外部放置 using 指令,不强制要求
|
||
|
||
# 表达式主体的 Lambda 表达式的偏好设置
|
||
csharp_style_expression_bodied_lambdas = true:silent # 推荐使用表达式主体的 Lambda 表达式,不强制要求
|
||
|
||
# 表达式主体的本地函数的偏好设置
|
||
csharp_style_expression_bodied_local_functions = false:silent # 不推荐使用表达式主体的本地函数,不强制要求
|
||
|
||
# 简化 using 语句的偏好设置
|
||
csharp_prefer_simple_using_statement = true:suggestion # 推荐使用简化的 using 语句,建议使用
|
||
|
||
# 命名空间声明风格的偏好设置
|
||
csharp_style_namespace_declarations = block_scoped:silent # 使用块级作用域的命名空间声明风格,不强制要求
|
||
|
||
# 方法组转换的偏好设置
|
||
csharp_style_prefer_method_group_conversion = true:silent # 推荐使用方法组转换,不强制要求
|
||
|
||
# 首选顶层语句的偏好设置
|
||
csharp_style_prefer_top_level_statements = true:silent # 推荐使用顶层语句,不强制要求
|
||
|
||
# 首选主构造函数的偏好设置
|
||
csharp_style_prefer_primary_constructors = true:suggestion # 推荐使用主构造函数,建议使用
|
||
|
||
# 使用静态本地函数的偏好设置
|
||
csharp_prefer_static_local_function = true:suggestion # 推荐使用静态本地函数,建议使用
|