Skip to content

Commit 6a7067a

Browse files
committed
更新格式化
1 parent eeb30e2 commit 6a7067a

1 file changed

Lines changed: 204 additions & 0 deletions

File tree

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
# EditorConfig is awesome:http://EditorConfig.org
2+
3+
# top-most EditorConfig file
4+
root = true
5+
6+
# Don't use tabs for indentation.
7+
[*]
8+
indent_style = space
9+
# (Please don't specify an indent_size here; that has too many unintended consequences.)
10+
11+
# Code files
12+
[*.{cs,csx,vb,vbx}]
13+
indent_size = 4
14+
insert_final_newline = true
15+
charset = utf-8-bom
16+
17+
# Xml project files
18+
[*.{xml,csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
19+
indent_size = 2
20+
indent_style = space
21+
tab_width = 2
22+
23+
# JSON files
24+
[*.json]
25+
indent_size = 2
26+
27+
[*.{sh}]
28+
end_of_line = lf
29+
indent_size = 2
30+
31+
# Dotnet code style settings:
32+
[*.{cs,vb}]
33+
34+
# 组织 Using
35+
dotnet_separate_import_directive_groups = true
36+
dotnet_sort_system_directives_first = true
37+
file_header_template = unset
38+
39+
# Avoid "this." and "Me." if not necessary
40+
dotnet_style_qualification_for_field = false:suggestion
41+
dotnet_style_qualification_for_property = false:suggestion
42+
dotnet_style_qualification_for_method = false:suggestion
43+
dotnet_style_qualification_for_event = false:suggestion
44+
45+
# Use language keywords instead of framework type names for type references
46+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
47+
dotnet_style_predefined_type_for_member_access = true:suggestion
48+
49+
# 括号首选项
50+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
51+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
52+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
53+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
54+
55+
# 修饰符首选项
56+
dotnet_style_require_accessibility_modifiers = for_non_interface_members
57+
58+
# Suggest more modern language features when available
59+
dotnet_style_object_initializer = true:suggestion
60+
dotnet_style_collection_initializer = true:suggestion
61+
dotnet_style_coalesce_expression = true:suggestion
62+
dotnet_style_null_propagation = true:suggestion
63+
dotnet_style_explicit_tuple_names = true:suggestion
64+
65+
# Non-private static fields are PascalCase
66+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
67+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
68+
dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
69+
70+
dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
71+
dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected internal, private protected
72+
dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
73+
74+
dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
75+
76+
# Constants are PascalCase
77+
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
78+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
79+
dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
80+
81+
dotnet_naming_symbols.constants.applicable_kinds = field, local
82+
dotnet_naming_symbols.constants.required_modifiers = const
83+
84+
dotnet_naming_style.constant_style.capitalization = pascal_case
85+
86+
# Static fields are camelCase and start with s_
87+
dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
88+
dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
89+
dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
90+
91+
dotnet_naming_symbols.static_fields.applicable_kinds = field
92+
dotnet_naming_symbols.static_fields.required_modifiers = static
93+
94+
dotnet_naming_style.static_field_style.capitalization = camel_case
95+
dotnet_naming_style.static_field_style.required_prefix = s_
96+
97+
# Instance fields are camelCase and start with _
98+
dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
99+
dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
100+
dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
101+
102+
dotnet_naming_symbols.instance_fields.applicable_kinds = field
103+
104+
dotnet_naming_style.instance_field_style.capitalization = camel_case
105+
dotnet_naming_style.instance_field_style.required_prefix = _
106+
107+
# Locals and parameters are camelCase
108+
dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
109+
dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
110+
dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
111+
112+
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
113+
114+
dotnet_naming_style.camel_case_style.capitalization = camel_case
115+
116+
# Local functions are PascalCase
117+
dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
118+
dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
119+
dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
120+
121+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
122+
123+
dotnet_naming_style.local_function_style.capitalization = pascal_case
124+
125+
# By default, name items with PascalCase
126+
dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
127+
dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
128+
dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
129+
130+
dotnet_naming_symbols.all_members.applicable_kinds = *
131+
132+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
133+
134+
# CSharp code style settings:
135+
[*.cs]
136+
# Indentation preferences
137+
csharp_indent_block_contents = true
138+
csharp_indent_braces = false
139+
csharp_indent_case_contents = true
140+
csharp_indent_case_contents_when_block = true
141+
csharp_indent_switch_labels = true
142+
csharp_indent_labels = flush_left
143+
144+
# Prefer "var" everywhere
145+
csharp_style_var_for_built_in_types = true:suggestion
146+
csharp_style_var_when_type_is_apparent = true:suggestion
147+
csharp_style_var_elsewhere = true:suggestion
148+
149+
# Prefer method-like constructs to have a block body
150+
csharp_style_expression_bodied_methods = false:none
151+
csharp_style_expression_bodied_constructors = false:none
152+
csharp_style_expression_bodied_operators = false:none
153+
154+
# Prefer property-like constructs to have an expression-body
155+
csharp_style_expression_bodied_properties = true:none
156+
csharp_style_expression_bodied_indexers = true:none
157+
csharp_style_expression_bodied_accessors = true:none
158+
159+
# Suggest more modern language features when available
160+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
161+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
162+
csharp_style_inlined_variable_declaration = true:suggestion
163+
csharp_style_throw_expression = true:suggestion
164+
csharp_style_conditional_delegate_call = true:suggestion
165+
166+
# Newline settings
167+
csharp_new_line_before_open_brace = all
168+
csharp_new_line_before_else = true
169+
csharp_new_line_before_catch = true
170+
csharp_new_line_before_finally = true
171+
csharp_new_line_before_members_in_object_initializers = true
172+
csharp_new_line_before_members_in_anonymous_types = true
173+
csharp_new_line_between_query_expression_clauses = true
174+
175+
# Spacing
176+
csharp_space_after_cast = true
177+
csharp_space_after_colon_in_inheritance_clause = true
178+
csharp_space_after_keywords_in_control_flow_statements = true
179+
csharp_space_around_binary_operators = before_and_after
180+
csharp_space_before_colon_in_inheritance_clause = true
181+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
182+
csharp_space_between_method_call_name_and_opening_parenthesis = false
183+
csharp_space_between_method_call_parameter_list_parentheses = false
184+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
185+
csharp_space_between_method_declaration_parameter_list_parentheses = false
186+
csharp_space_between_parentheses = false
187+
188+
# Blocks are allowed
189+
csharp_prefer_braces = true:silent
190+
csharp_preserve_single_line_blocks = true
191+
csharp_preserve_single_line_statements = true
192+
193+
194+
#### 自动代码优化 ####
195+
196+
# 过时 Obsolete 忽略
197+
198+
dotnet_diagnostic.CS0618.severity = none
199+
dotnet_diagnostic.CS0612.severity = none
200+
201+
# 其他优化 忽略 NET45 不支持的新 API 功能
202+
203+
dotnet_diagnostic.CA1846.severity = none # CA1846: Prefer 'AsSpan' over 'Substring'
204+
dotnet_diagnostic.CA1825.severity = silent # Avoid zero-length array allocations

0 commit comments

Comments
 (0)