Skip to content

Commit c97b163

Browse files
committed
chore: Add editorconfig
(This will be applied in subsequent commits.) One potentially-controversial aspect of this editorconfig is the use of a space after casting. The code is currently very inconsistent, but has a space after the cast more often than not (the diff is smaller with it set to true than false)... it's also consistent with the style I personally use in multiple other repositories. While I'm the main contributor, it probably makes sense to stick to that. Signed-off-by: Jon Skeet <[email protected]>
1 parent 6f48433 commit c97b163

File tree

1 file changed

+208
-0
lines changed

1 file changed

+208
-0
lines changed

.editorconfig

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
2+
# top-most EditorConfig file
3+
root = true
4+
###############################
5+
# Core EditorConfig Options #
6+
###############################
7+
# All files
8+
[*]
9+
insert_final_newline = true
10+
indent_style = space
11+
indent_size = 4
12+
trim_trailing_whitespace = true
13+
14+
# Generated code
15+
[*{_AssemblyInfo.cs,.g.cs}]
16+
generated_code = true
17+
18+
# XML project files
19+
[*.{csproj}]
20+
indent_size = 2
21+
22+
# Code files
23+
24+
###############################
25+
# .NET Coding Conventions #
26+
###############################
27+
[*.{cs}]
28+
29+
# Organize usings
30+
dotnet_sort_system_directives_first = false
31+
32+
# this. preferences
33+
dotnet_style_qualification_for_field = false:suggestion
34+
dotnet_style_qualification_for_property = false:suggestion
35+
dotnet_style_qualification_for_method = false:suggestion
36+
dotnet_style_qualification_for_event = false:suggestion
37+
38+
# Language keywords vs BCL types preferences
39+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
40+
dotnet_style_predefined_type_for_member_access = true:suggestion
41+
42+
# Parentheses preferences
43+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
44+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
45+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
46+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
47+
48+
# Modifier preferences
49+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning
50+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:warning
51+
dotnet_style_readonly_field = true:warning
52+
53+
# Expression-level preferences
54+
dotnet_style_object_initializer = true:suggestion
55+
dotnet_style_collection_initializer = true:suggestion
56+
dotnet_style_explicit_tuple_names = true:suggestion
57+
dotnet_style_null_propagation = true:suggestion
58+
dotnet_style_coalesce_expression = true:suggestion
59+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
60+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
61+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
62+
dotnet_style_prefer_auto_properties = true:suggestion
63+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
64+
dotnet_style_prefer_conditional_expression_over_return = true:silent
65+
csharp_prefer_simple_default_expression = true:suggestion
66+
67+
###############################
68+
# Naming Conventions #
69+
###############################
70+
# Style Definitions
71+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
72+
73+
# Use PascalCase for constant fields
74+
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
75+
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
76+
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
77+
dotnet_naming_symbols.constant_fields.applicable_kinds = field
78+
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
79+
dotnet_naming_symbols.constant_fields.required_modifiers = const
80+
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
81+
82+
# static fields should have s_ prefix
83+
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
84+
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
85+
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
86+
dotnet_naming_symbols.static_fields.applicable_kinds = field
87+
dotnet_naming_symbols.static_fields.required_modifiers = static
88+
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
89+
dotnet_naming_style.static_prefix_style.required_prefix = s_
90+
dotnet_naming_style.static_prefix_style.capitalization = camel_case
91+
92+
# internal and private fields should be _camelCase
93+
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
94+
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
95+
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
96+
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
97+
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
98+
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
99+
dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case
100+
101+
###############################
102+
# C# Coding Conventions #
103+
###############################
104+
[*.cs]
105+
# var preferences
106+
csharp_style_var_for_built_in_types = true:silent
107+
csharp_style_var_when_type_is_apparent = true:silent
108+
csharp_style_var_elsewhere = true:silent
109+
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
110+
dotnet_style_predefined_type_for_member_access = true:silent
111+
112+
csharp_using_directive_placement = outside_namespace:warning
113+
csharp_prefer_braces = true:suggestion
114+
csharp_preserve_single_line_blocks = true:none
115+
csharp_preserve_single_line_statements = false:none
116+
csharp_prefer_static_local_function = true:suggestion
117+
csharp_prefer_simple_using_statement = true:suggestion
118+
csharp_style_prefer_switch_expression = true:suggestion
119+
120+
# Expression-bodied members
121+
csharp_style_expression_bodied_methods = true:suggestion
122+
csharp_style_expression_bodied_constructors = true:suggestion
123+
csharp_style_expression_bodied_operators = true:suggestion
124+
csharp_style_expression_bodied_properties = true:suggestion
125+
csharp_style_expression_bodied_indexers = true:suggestion
126+
csharp_style_expression_bodied_accessors = true:suggestion
127+
csharp_style_expression_bodied_lambdas = true:suggestion
128+
csharp_style_expression_bodied_local_functions = true:suggestion
129+
130+
# Pattern matching preferences
131+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
132+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
133+
csharp_style_inlined_variable_declaration = true:suggestion
134+
135+
# Null-checking preferences
136+
csharp_style_throw_expression = true:suggestion
137+
csharp_style_conditional_delegate_call = true:suggestion
138+
139+
# Other features
140+
csharp_style_prefer_index_operator = true:suggestion
141+
csharp_style_prefer_range_operator = true:suggestion
142+
csharp_style_pattern_local_over_anonymous_function = false:none
143+
144+
###############################
145+
# C# Formatting Rules #
146+
###############################
147+
indent_size = 4
148+
insert_final_newline = true
149+
charset = utf-8
150+
151+
# New line preferences
152+
csharp_new_line_before_open_brace = all
153+
csharp_new_line_before_else = true
154+
csharp_new_line_before_catch = true
155+
csharp_new_line_before_finally = true
156+
csharp_new_line_before_members_in_object_initializers = true
157+
csharp_new_line_before_members_in_anonymous_types = true
158+
csharp_new_line_between_query_expression_clauses = true
159+
160+
# Indentation preferences
161+
csharp_indent_block_contents = true
162+
csharp_indent_braces = false
163+
csharp_indent_case_contents = true
164+
csharp_indent_case_contents_when_block = true
165+
csharp_indent_switch_labels = true
166+
csharp_indent_labels = one_less_than_current
167+
168+
# Space preferences
169+
csharp_space_after_cast = true
170+
csharp_space_after_colon_in_inheritance_clause = true
171+
csharp_space_after_comma = true
172+
csharp_space_after_dot = false
173+
csharp_space_after_keywords_in_control_flow_statements = true
174+
csharp_space_after_semicolon_in_for_statement = true
175+
csharp_space_between_method_call_parameter_list_parentheses = false
176+
csharp_space_between_method_declaration_parameter_list_parentheses = false
177+
csharp_space_between_parentheses = false
178+
csharp_space_before_comma = false
179+
csharp_space_before_dot = false
180+
csharp_space_before_open_square_brackets = false
181+
csharp_space_before_semicolon_in_for_statement = false
182+
csharp_space_between_empty_square_brackets = false
183+
csharp_space_around_declaration_statements = do_not_ignore
184+
csharp_space_before_colon_in_inheritance_clause = true
185+
csharp_space_after_colon_in_inheritance_clause = true
186+
csharp_space_around_binary_operators = before_and_after
187+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
188+
csharp_space_between_method_call_name_and_opening_parenthesis = false
189+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
190+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
191+
csharp_space_between_square_brackets = false
192+
193+
# Wrapping preferences
194+
csharp_preserve_single_line_statements = true
195+
csharp_preserve_single_line_blocks = true
196+
197+
csharp_style_namespace_declarations = file_scoped:suggestion
198+
csharp_style_prefer_null_check_over_type_check = true:suggestion
199+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
200+
csharp_style_prefer_tuple_swap = true:suggestion
201+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
202+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
203+
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
204+
csharp_style_prefer_pattern_matching = true:suggestion
205+
csharp_style_prefer_not_pattern = true:suggestion
206+
csharp_style_prefer_extended_property_pattern = true:suggestion
207+
csharp_style_prefer_parameter_null_checking = true:suggestion
208+
csharp_style_prefer_method_group_conversion = true:suggestion

0 commit comments

Comments
 (0)