1- # EditorConfig is awesome:
2- http://EditorConfig.org
1+ # EditorConfig is awesome: https://EditorConfig.org
32
43# top-most EditorConfig file
54root = true
65
6+ # Don't use tabs for indentation.
77[* ]
88indent_style = space
9- insert_final_newline = false
109
10+ # Code files
1111[* .{cs,csx,vb,vbx} ]
1212indent_size = 4
13+ insert_final_newline = true
14+ charset = utf-8-bom
1315
14- [* .* proj ]
16+ # XML project files
17+ [* .{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj} ]
1518indent_size = 2
1619
17- [* .{json,props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct,vcxproj.filters,projitems} ]
20+ # XML config files
21+ [* .{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct} ]
1822indent_size = 2
1923
20- [ * .{sh} ]
21- end_of_line = lf
24+ # JSON files
25+ [ * .json ]
2226indent_size = 2
2327
24- [* .{ps1,cmd} ]
28+ # Powershell files
29+ [* .ps1 ]
2530indent_size = 2
2631
27- # ### .NET Coding Conventions ####
32+ # Shell script files
33+ [* .sh ]
34+ end_of_line = lf
35+ indent_size = 2
2836
29- # this. and Me. preferences
30- dotnet_style_qualification_for_event = false :warning
31- dotnet_style_qualification_for_field = false :warning
32- dotnet_style_qualification_for_method = false :warning
33- dotnet_style_qualification_for_property = false :warning
37+ # Dotnet code style settings:
38+ [* .{cs,vb} ]
3439
35- # Language keywords vs BCL types preferences
36- dotnet_style_predefined_type_for_locals_parameters_members = true :warning
37- dotnet_style_predefined_type_for_member_access = true :warning
40+ # Sort using and Import directives with System.* appearing first
41+ dotnet_sort_system_directives_first = true
42+ dotnet_separate_import_directive_groups = false
43+ # Avoid "this." and "Me." if not necessary
44+ dotnet_style_qualification_for_field = false:refactoring
45+ dotnet_style_qualification_for_property = false:refactoring
46+ dotnet_style_qualification_for_method = false:refactoring
47+ dotnet_style_qualification_for_event = false:refactoring
3848
39- # Parentheses preferences
40- dotnet_style_parentheses_in_arithmetic_binary_operators = never_if_unnecessary:silent
41- dotnet_style_parentheses_in_other_binary_operators = never_if_unnecessary:silent
42- dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
43- dotnet_style_parentheses_in_relational_binary_operators = never_if_unnecessary:silent
49+ # Use language keywords instead of framework type names for type references
50+ dotnet_style_predefined_type_for_locals_parameters_members = true :suggestion
51+ dotnet_style_predefined_type_for_member_access = true :suggestion
4452
45- # Modifier preferences
46- dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
53+ # Suggest more modern language features when available
54+ dotnet_style_object_initializer = true :suggestion
55+ dotnet_style_collection_initializer = true :suggestion
56+ dotnet_style_coalesce_expression = true :suggestion
57+ dotnet_style_null_propagation = true :suggestion
58+ dotnet_style_explicit_tuple_names = true :suggestion
4759
48- # Expression-level preferences
49- csharp_style_deconstructed_variable_declaration = true :suggestion
50- csharp_style_inlined_variable_declaration = true :suggestion
51- csharp_style_throw_expression = true :suggestion
52- dotnet_style_coalesce_expression = true :warning
53- dotnet_style_collection_initializer = false :silent
54- dotnet_style_explicit_tuple_names = true :warning
55- dotnet_style_null_propagation = true :warning
56- dotnet_style_object_initializer = false :silent
57- dotnet_style_prefer_auto_properties = true :suggestion
58- dotnet_style_prefer_compound_assignment = true :suggestion
59- dotnet_style_prefer_conditional_expression_over_assignment = true :silent
60- dotnet_style_prefer_conditional_expression_over_return = true :silent
61- dotnet_style_prefer_inferred_anonymous_type_member_names = true :suggestion
62- dotnet_style_prefer_inferred_tuple_names = true :suggestion
63- dotnet_style_prefer_is_null_check_over_reference_equality_method = true :warning
64-
65- # Field preferences
66- dotnet_style_readonly_field = true :warning
67-
68- # Parameter preferences
69- dotnet_code_quality_unused_parameters = all:warning
70-
71- # ### C# Coding Conventions ####
72-
73- # var preferences
74- csharp_style_var_elsewhere = true :silent
75- csharp_style_var_for_built_in_types = false :silent
76- csharp_style_var_when_type_is_apparent = true :suggestion
60+ # Whitespace options
61+ dotnet_style_allow_multiple_blank_lines_experimental = false
7762
78- # Expression-bodied members
79- csharp_style_expression_bodied_accessors = true :suggestion
80- csharp_style_expression_bodied_constructors = true :silent
81- csharp_style_expression_bodied_indexers = true :suggestion
82- csharp_style_expression_bodied_lambdas = true :suggestion
83- csharp_style_expression_bodied_local_functions = true :suggestion
84- csharp_style_expression_bodied_methods = when_on_single_line:suggestion
85- csharp_style_expression_bodied_operators = when_on_single_line:suggestion
86- csharp_style_expression_bodied_properties = true :suggestion
87-
88- # Pattern matching preferences
89- csharp_style_pattern_matching_over_as_with_null_check = true :suggestion
90- csharp_style_pattern_matching_over_is_with_cast_check = true :suggestion
63+ # Non-private static fields are PascalCase
64+ dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.severity = suggestion
65+ dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.symbols = non_private_static_fields
66+ dotnet_naming_rule.non_private_static_fields_should_be_pascal_case.style = non_private_static_field_style
9167
92- # Null-checking preferences
93- csharp_style_conditional_delegate_call = true :warning
68+ dotnet_naming_symbols.non_private_static_fields.applicable_kinds = field
69+ dotnet_naming_symbols.non_private_static_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
70+ dotnet_naming_symbols.non_private_static_fields.required_modifiers = static
9471
95- # Modifier preferences
96- csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
72+ dotnet_naming_style.non_private_static_field_style.capitalization = pascal_case
9773
98- # Code-block preferences
99- csharp_prefer_braces = true :warning
74+ # Non-private readonly fields are PascalCase
75+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
76+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
77+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_field_style
10078
101- # Expression-level preferences
102- csharp_prefer_simple_default_expression = true :warning
103- csharp_style_pattern_local_over_anonymous_function = true :suggestion
104- csharp_style_prefer_index_operator = true :suggestion
105- csharp_style_prefer_range_operator = true :suggestion
106- csharp_style_unused_value_assignment_preference = discard_variable:warning
107- csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
79+ dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
80+ dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public, protected, internal, protected_internal, private_protected
81+ dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
10882
109- # ### C# Formatting Rules ####
83+ dotnet_naming_style.non_private_readonly_field_style.capitalization = pascal_case
11084
111- # New line preferences
112- csharp_new_line_before_catch = true
85+ # Constants are PascalCase
86+ dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
87+ dotnet_naming_rule.constants_should_be_pascal_case.symbols = constants
88+ dotnet_naming_rule.constants_should_be_pascal_case.style = constant_style
89+
90+ dotnet_naming_symbols.constants.applicable_kinds = field, local
91+ dotnet_naming_symbols.constants.required_modifiers = const
92+
93+ dotnet_naming_style.constant_style.capitalization = pascal_case
94+
95+ # Static fields are camelCase and start with s_
96+ dotnet_naming_rule.static_fields_should_be_camel_case.severity = suggestion
97+ dotnet_naming_rule.static_fields_should_be_camel_case.symbols = static_fields
98+ dotnet_naming_rule.static_fields_should_be_camel_case.style = static_field_style
99+
100+ dotnet_naming_symbols.static_fields.applicable_kinds = field
101+ dotnet_naming_symbols.static_fields.required_modifiers = static
102+
103+ dotnet_naming_style.static_field_style.capitalization = camel_case
104+ dotnet_naming_style.static_field_style.required_prefix = s_
105+
106+ # Instance fields are camelCase and start with _
107+ dotnet_naming_rule.instance_fields_should_be_camel_case.severity = suggestion
108+ dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields
109+ dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style
110+
111+ dotnet_naming_symbols.instance_fields.applicable_kinds = field
112+
113+ dotnet_naming_style.instance_field_style.capitalization = camel_case
114+ dotnet_naming_style.instance_field_style.required_prefix = _
115+
116+ # Locals and parameters are camelCase
117+ dotnet_naming_rule.locals_should_be_camel_case.severity = suggestion
118+ dotnet_naming_rule.locals_should_be_camel_case.symbols = locals_and_parameters
119+ dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
120+
121+ dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
122+
123+ dotnet_naming_style.camel_case_style.capitalization = camel_case
124+
125+ # Local functions are PascalCase
126+ dotnet_naming_rule.local_functions_should_be_pascal_case.severity = suggestion
127+ dotnet_naming_rule.local_functions_should_be_pascal_case.symbols = local_functions
128+ dotnet_naming_rule.local_functions_should_be_pascal_case.style = local_function_style
129+
130+ dotnet_naming_symbols.local_functions.applicable_kinds = local_function
131+
132+ dotnet_naming_style.local_function_style.capitalization = pascal_case
133+
134+ # By default, name items with PascalCase
135+ dotnet_naming_rule.members_should_be_pascal_case.severity = suggestion
136+ dotnet_naming_rule.members_should_be_pascal_case.symbols = all_members
137+ dotnet_naming_rule.members_should_be_pascal_case.style = pascal_case_style
138+
139+ dotnet_naming_symbols.all_members.applicable_kinds = *
140+
141+ dotnet_naming_style.pascal_case_style.capitalization = pascal_case
142+
143+ file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license.\nSee the LICENSE file in the project root for more information.
144+
145+ # RS0016: Only enable if API files are present
146+ dotnet_public_api_analyzer.require_api_files = true
147+
148+ # IDE0055: Fix formatting
149+ # Workaround for https://github.com/dotnet/roslyn/issues/70570
150+ dotnet_diagnostic.IDE0055.severity = warning
151+
152+
153+ # CSharp code style settings:
154+ [* .cs ]
155+ # Newline settings
156+ csharp_new_line_before_open_brace = all
113157csharp_new_line_before_else = true
158+ csharp_new_line_before_catch = true
114159csharp_new_line_before_finally = true
115- csharp_new_line_before_members_in_anonymous_types = true
116160csharp_new_line_before_members_in_object_initializers = true
117- csharp_new_line_before_open_brace = all
161+ csharp_new_line_before_members_in_anonymous_types = true
118162csharp_new_line_between_query_expression_clauses = true
119163
120164# Indentation preferences
121165csharp_indent_block_contents = true
122166csharp_indent_braces = false
123167csharp_indent_case_contents = true
124168csharp_indent_case_contents_when_block = true
125- csharp_indent_labels = one_less_than_current
126169csharp_indent_switch_labels = true
170+ csharp_indent_labels = flush_left
171+
172+ # Whitespace options
173+ csharp_style_allow_embedded_statements_on_same_line_experimental = false
174+ csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false
175+ csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false
176+ csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false
177+ csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false
178+
179+ # Prefer "var" everywhere
180+ csharp_style_var_for_built_in_types = true :suggestion
181+ csharp_style_var_when_type_is_apparent = true :suggestion
182+ csharp_style_var_elsewhere = true :suggestion
183+
184+ # Prefer method-like constructs to have a block body
185+ csharp_style_expression_bodied_methods = false :none
186+ csharp_style_expression_bodied_constructors = false :none
187+ csharp_style_expression_bodied_operators = false :none
188+
189+ # Prefer property-like constructs to have an expression-body
190+ csharp_style_expression_bodied_properties = true :none
191+ csharp_style_expression_bodied_indexers = true :none
192+ csharp_style_expression_bodied_accessors = true :none
193+
194+ # Suggest more modern language features when available
195+ csharp_style_pattern_matching_over_is_with_cast_check = true :suggestion
196+ csharp_style_pattern_matching_over_as_with_null_check = true :suggestion
197+ csharp_style_inlined_variable_declaration = true :suggestion
198+ csharp_style_throw_expression = true :suggestion
199+ csharp_style_conditional_delegate_call = true :suggestion
200+ csharp_style_prefer_extended_property_pattern = true :suggestion
127201
128202# Space preferences
129203csharp_space_after_cast = false
@@ -133,7 +207,7 @@ csharp_space_after_dot = false
133207csharp_space_after_keywords_in_control_flow_statements = true
134208csharp_space_after_semicolon_in_for_statement = true
135209csharp_space_around_binary_operators = before_and_after
136- csharp_space_around_declaration_statements = false
210+ csharp_space_around_declaration_statements = do_not_ignore
137211csharp_space_before_colon_in_inheritance_clause = true
138212csharp_space_before_comma = false
139213csharp_space_before_dot = false
@@ -149,10 +223,11 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false
149223csharp_space_between_parentheses = false
150224csharp_space_between_square_brackets = false
151225
152- # Wrapping preferences
226+ # Blocks are allowed
227+ csharp_prefer_braces = true :silent
153228csharp_preserve_single_line_blocks = true
154229csharp_preserve_single_line_statements = true
155230
231+ # IDE0060: Remove unused parameter
232+ dotnet_diagnostic.IDE0060.severity = warning
156233
157- [* .{cs} ]
158- file_header_template = Licensed to the.NET Foundation under one or more agreements.\nThe.NET Foundation licenses this file to you under the MIT license.\nSee the License.txt file in the project root for more information.
0 commit comments