Skip to content

Commit a827ec0

Browse files
authored
Add latest .editorconfig from OS.2020 (#3363)
* Add latest .editorconfig from OS.2020 * Add csproj+wapproj (same handling as vcxproj)
1 parent 78f6225 commit a827ec0

File tree

1 file changed

+186
-110
lines changed

1 file changed

+186
-110
lines changed

.editorconfig

+186-110
Original file line numberDiff line numberDiff line change
@@ -1,134 +1,210 @@
1+
# editorconfig: http://editorconfig.org/
2+
# Help developers standardize spaces, tabs, encoding, end-line characters across editors
3+
4+
# top-most .editorconfig file
15
root = true
26

3-
# Rules in this file were initially inferred by Visual Studio IntelliCode from the S:\Repos\dep.controls codebase based on best match to current usage at 11/15/2018
4-
# You can modify the rules from these initially generated values to suit your own policies
5-
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
6-
[*.cs]
7+
# defaults for all files
8+
[*]
9+
charset = utf-8
10+
end_of_line = crlf
11+
indent_size = 4
12+
indent_style = space
13+
insert_final_newline = true
14+
trim_trailing_whitespace = true
715

8-
#Core editorconfig formatting - indentation
16+
# markdown, diff overrides
17+
# two trailing spaces are required for <br/> and hard line-breaks in markdown files
18+
# see: (https://daringfireball.net/projects/markdown/syntax#p) and (http://spec.commonmark.org/0.27/#hard-line-break)
19+
[*.{md,diff}]
20+
trim_trailing_whitespace = false
921

10-
#use soft tabs (spaces) for indentation
11-
indent_style = space
12-
indent_size = 4
22+
[*.{md,xml,xsd,gprops,man,natvis}]
23+
indent_size = 2
24+
25+
# manifest validation tool requires BOM
26+
[*.man]
1327
charset = utf-8-bom
14-
end_of_line = crlf
1528

16-
#Formatting - indentation options
29+
# XML-based MSBuild and Visual Studio files
30+
[*.{props,targets,settings,*proj,vcxitems,filters,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
31+
indent_size = 2
1732

18-
#indent switch case contents.
19-
csharp_indent_case_contents = true
20-
#csharp_indent_case_contents_when_block
21-
csharp_indent_case_contents_when_block = true
22-
#indent switch labels
23-
csharp_indent_switch_labels = true
33+
# Exceptions to the above *proj wildcard
34+
[*.vdproj]
35+
indent_size = 4
2436

25-
#Formatting - new line options
37+
# Visual Studio uses hard tabs for SLN files, so don't fight it
38+
[*.sln]
39+
indent_style = tab
2640

27-
#place catch statements on a new line
28-
csharp_new_line_before_catch = true
29-
#place else statements on a new line
30-
csharp_new_line_before_else = true
31-
#require braces to be on a new line for accessors, methods, object_collection, control_blocks, types, properties, and lambdas (also known as "Allman" style)
32-
csharp_new_line_before_open_brace = accessors, methods, object_collection, control_blocks, types, properties, lambdas
41+
# Visual Studio removes the last empty line, so don't fight it
42+
[*.{vcxproj,csproj,wapproj}]
43+
insert_final_newline = false
3344

34-
#Formatting - organize using options
45+
# YAML overrides
46+
[*.{yml,yaml}]
47+
indent_size = 2
3548

36-
#do not place System.* using directives before other using directives
37-
dotnet_sort_system_directives_first = false
49+
# package.json overrides
50+
# Updating package.json with NPM will revert indentation to 2 spaces so to
51+
# reduce churn, let's align to NPM and specify indent size 2
52+
[package.json]
53+
indent_size = 2
3854

39-
#Formatting - spacing options
55+
# JSON formats
56+
[{*.{json,testlist,testpasses,testenv,pluginlist},testmd.definition}]
57+
indent_size = 2
4058

41-
#require NO space between a cast and the value
59+
[*.{rc,rc2}]
60+
trim_trailing_whitespace = true
61+
insert_final_newline = true
62+
63+
[*.{c,w}]
64+
trim_trailing_whitespace = true
65+
insert_final_newline = true
66+
67+
[*.{c++,cc,cpp,cppm,cxx,h,h++,hh,hpp,hxx,inl,ipp,ixx,tlh,tli,idl}]
68+
trim_trailing_whitespace = true
69+
insert_final_newline = true
70+
cpp_indent_braces = false
71+
cpp_indent_multi_line_relative_to = innermost_parenthesis
72+
cpp_indent_within_parentheses = indent
73+
cpp_indent_preserve_within_parentheses = true
74+
cpp_indent_case_contents = true
75+
cpp_indent_case_labels = false
76+
cpp_indent_case_contents_when_block = false
77+
cpp_indent_lambda_braces_when_parameter = false
78+
cpp_indent_goto_labels = one_left
79+
cpp_indent_preprocessor = leftmost_column
80+
cpp_indent_access_specifiers = false
81+
cpp_indent_namespace_contents = true
82+
cpp_indent_preserve_comments = false
83+
cpp_new_line_before_open_brace_namespace = ignore
84+
cpp_new_line_before_open_brace_type = ignore
85+
cpp_new_line_before_open_brace_function = new_line
86+
cpp_new_line_before_open_brace_block = new_line
87+
cpp_new_line_before_open_brace_lambda = new_line
88+
cpp_new_line_scope_braces_on_separate_lines = true
89+
cpp_new_line_close_brace_same_line_empty_type = false
90+
cpp_new_line_close_brace_same_line_empty_function = ignore
91+
cpp_new_line_before_catch = true
92+
cpp_new_line_before_else = true
93+
cpp_new_line_before_while_in_do_while = true
94+
cpp_space_before_function_open_parenthesis = remove
95+
cpp_space_within_parameter_list_parentheses = false
96+
cpp_space_between_empty_parameter_list_parentheses = false
97+
cpp_space_after_keywords_in_control_flow_statements = true
98+
cpp_space_within_control_flow_statement_parentheses = false
99+
cpp_space_before_lambda_open_parenthesis = false
100+
cpp_space_within_cast_parentheses = false
101+
cpp_space_after_cast_close_parenthesis = false
102+
cpp_space_within_expression_parentheses = false
103+
cpp_space_before_block_open_brace = true
104+
cpp_space_between_empty_braces = false
105+
cpp_space_before_initializer_list_open_brace = false
106+
cpp_space_within_initializer_list_braces = true
107+
cpp_space_preserve_in_initializer_list = true
108+
cpp_space_before_open_square_bracket = false
109+
cpp_space_within_square_brackets = false
110+
cpp_space_before_empty_square_brackets = false
111+
cpp_space_between_empty_square_brackets = false
112+
cpp_space_group_square_brackets = true
113+
cpp_space_within_lambda_brackets = false
114+
cpp_space_between_empty_lambda_brackets = false
115+
cpp_space_before_comma = false
116+
cpp_space_after_comma = true
117+
cpp_space_remove_around_member_operators = true
118+
cpp_space_before_inheritance_colon = true
119+
cpp_space_before_constructor_colon = true
120+
cpp_space_remove_before_semicolon = true
121+
cpp_space_after_semicolon = true
122+
cpp_space_remove_around_unary_operator = true
123+
cpp_space_around_binary_operator = insert
124+
cpp_space_around_assignment_operator = insert
125+
cpp_space_pointer_reference_alignment = left
126+
cpp_space_around_ternary_operator = insert
127+
cpp_wrap_preserve_blocks = one_liners
128+
129+
# C# overrides
130+
# Rules explanation: https://kent-boogaart.com/blog/editorconfig-reference-for-c-developers
131+
[*.cs]
132+
# Indent settings
133+
csharp_indent_block_contents = true
134+
csharp_indent_braces = false
135+
csharp_indent_case_contents = true
136+
csharp_indent_switch_labels = true
137+
138+
# Newline settings
139+
csharp_new_line_before_catch = true
140+
csharp_new_line_before_else = true
141+
csharp_new_line_before_finally = true
142+
csharp_new_line_before_members_in_anonymous_types = true
143+
csharp_new_line_before_members_in_object_initializers = true
144+
csharp_new_line_before_open_brace = all
145+
csharp_new_line_between_query_expression_clauses = true
146+
147+
# Braces settings
148+
csharp_prefer_braces = true:error
149+
csharp_prefer_simple_default_expression = false:error
150+
csharp_preserve_single_line_blocks = true
151+
csharp_preserve_single_line_statements = false
152+
153+
# Space settings
42154
csharp_space_after_cast = false
43-
#require a space before the colon for bases or interfaces in a type declaration
44155
csharp_space_after_colon_in_inheritance_clause = true
45-
#require a space after a keyword in a control flow statement such as a for loop
156+
csharp_space_after_comma = true
157+
csharp_space_after_dot = false
46158
csharp_space_after_keywords_in_control_flow_statements = true
47-
#require a space before the colon for bases or interfaces in a type declaration
159+
csharp_space_after_semicolon_in_for_statement = true
160+
csharp_space_around_binary_operators = before_and_after
161+
csharp_space_around_declaration_statements = do_not_ignore
48162
csharp_space_before_colon_in_inheritance_clause = true
49-
#remove space within empty argument list parentheses
163+
csharp_space_before_comma = false
164+
csharp_space_before_dot = false
165+
csharp_space_before_open_square_brackets = false
166+
csharp_space_before_semicolon_in_for_statement = false
167+
csharp_space_between_empty_square_brackets = false
50168
csharp_space_between_method_call_empty_parameter_list_parentheses = false
51-
#remove space between method call name and opening parenthesis
52169
csharp_space_between_method_call_name_and_opening_parenthesis = false
53-
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
54170
csharp_space_between_method_call_parameter_list_parentheses = false
55-
#remove space within empty parameter list parentheses for a method declaration
56171
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
57-
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
172+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
58173
csharp_space_between_method_declaration_parameter_list_parentheses = false
59-
60-
#Formatting - wrapping options
61-
62-
#leave code block on single line
63-
csharp_preserve_single_line_blocks = true
64-
#leave statements and member declarations on the same line
65-
csharp_preserve_single_line_statements = true
66-
67-
#Style - expression bodied member options
68-
69-
#prefer block bodies for accessors
70-
csharp_style_expression_bodied_accessors = false:suggestion
71-
#prefer block bodies for constructors
72-
csharp_style_expression_bodied_constructors = false:suggestion
73-
#prefer block bodies for methods
74-
csharp_style_expression_bodied_methods = false:suggestion
75-
#prefer block bodies for properties
76-
csharp_style_expression_bodied_properties = false:suggestion
77-
78-
#Style - expression level options
79-
80-
#prefer out variables to be declared before the method call
81-
csharp_style_inlined_variable_declaration = false:suggestion
82-
#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
83-
dotnet_style_predefined_type_for_member_access = true:suggestion
84-
85-
#Style - implicit and explicit types
86-
87-
#prefer explicit type over var to declare variables with built-in system types such as int
88-
csharp_style_var_for_built_in_types = false:none
89-
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
90-
csharp_style_var_when_type_is_apparent = false:none
91-
92-
#Style - language keyword and framework type options
93-
94-
#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
174+
csharp_space_between_parentheses = false
175+
csharp_space_between_square_brackets = false
176+
177+
# Suggest more modern language features when available
178+
csharp_style_conditional_delegate_call = false:suggestion
179+
csharp_style_inlined_variable_declaration = true:suggestion
180+
csharp_style_pattern_matching_over_as_with_null_check = false:suggestion
181+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
182+
csharp_style_throw_expression = true:suggestion
183+
184+
# Prefer property-like constructs to have an expression-body
185+
csharp_style_expression_bodied_accessors = true:suggestion
186+
csharp_style_expression_bodied_indexers = true:suggestion
187+
csharp_style_expression_bodied_properties = true:suggestion
188+
189+
# Suggest "var" when type is apparent
190+
csharp_style_var_when_type_is_apparent = true:suggestion
191+
192+
# Sort using directives with System.* appearing first
193+
dotnet_sort_system_directives_first = true
194+
195+
# Suggest more modern language features when available
196+
dotnet_style_coalesce_expression = true:suggestion
197+
dotnet_style_collection_initializer = true:suggestion
198+
dotnet_style_explicit_tuple_names = true:suggestion
199+
dotnet_style_null_propagation = true:suggestion
200+
dotnet_style_object_initializer = true:suggestion
201+
202+
# Use language keywords instead of framework type names for type references
95203
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
204+
dotnet_style_predefined_type_for_member_access = true:suggestion
96205

97-
#Style - qualification options
98-
99-
#prefer events not to be prefaced with this. or Me. in Visual Basic
100-
dotnet_style_qualification_for_event = false:suggestion
101-
#prefer fields not to be prefaced with this. or Me. in Visual Basic
102-
dotnet_style_qualification_for_field = false:suggestion
103-
#prefer methods not to be prefaced with this. or Me. in Visual Basic
104-
dotnet_style_qualification_for_method = false:suggestion
105-
#prefer properties not to be prefaced with this. or Me. in Visual Basic
106-
dotnet_style_qualification_for_property = false:suggestion
107-
108-
# IDE0008: Use explicit type
109-
csharp_style_var_elsewhere = false:none
110-
111-
[**.{cpp,h,idl}]
112-
indent_style = space
113-
indent_size = 4
114-
charset = utf-8-bom
115-
insert_final_newline = true
116-
trim_trailing_whitespace = true
117-
end_of_line = crlf
118-
119-
120-
[**.{xaml,xml}]
121-
indent_style = space
122-
indent_size = 4
123-
charset = utf-8-bom
124-
insert_final_newline = true
125-
trim_trailing_whitespace = true
126-
end_of_line = crlf
127-
128-
[**.md]
129-
indent_style = space
130-
indent_size = 4
131-
charset = utf-8
132-
insert_final_newline = true
133-
trim_trailing_whitespace = true
134-
end_of_line = crlf
206+
# Avoid "this."
207+
dotnet_style_qualification_for_event = false:error
208+
dotnet_style_qualification_for_field = false:error
209+
dotnet_style_qualification_for_method = false:error
210+
dotnet_style_qualification_for_property = false:error

0 commit comments

Comments
 (0)