11root =true
22
3- [* .cs ]
4- trim_trailing_whitespace =true
5- insert_final_newline =true
6- end_of_line = lf
7-
83[* ]
94charset = utf-8
105indent_style = tab
116indent_size = 4
127
13- [* .cshtml ]
14- indent_style = tab
15- indent_size = 4
16- end_of_line = lf
8+ [* .{fs,fsx,cs,vb} ]
9+ file_header_template =Licensed to Elasticsearch B.V under one or more agreements.\nElasticsearch B.V licenses this file to you under the Apache 2 .0 License.\nSee the LICENSE file in the project root for more information
10+ max_line_length = 160
1711
18- [* .{fs,fsx,yml } ]
12+ [* .{fs,fsx} ]
1913indent_style = space
2014indent_size = 4
21- end_of_line = lf
2215
23- [* .{md,markdown,json,js,csproj,fsproj,targets,targets,props} ]
16+ [* .{md,markdown,json,js,yml,yaml, csproj,fsproj,targets,targets,props} ]
2417indent_style = space
2518indent_size = 2
26- end_of_line = lf
19+
20+ [* .{ts,tsx} ]
21+ indent_style = space
22+ indent_size = 4
23+ quote_type = single
2724
2825# Dotnet code style settings:
2926[* .{cs,vb} ]
27+ trim_trailing_whitespace =true
28+ insert_final_newline =true
29+ # Sort using and Import directives with System.* appearing first
30+ dotnet_sort_system_directives_first = true
3031
31- # ---
32- # naming conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
33- # currently not supported in Rider/Resharper so not using these for now
34- # ---
32+ # Style rules
33+ # https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules?view=vs-2017
3534
36- # ---
37- # langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
35+ # Constants always pascal case
36+ dotnet_naming_rule.constants_should_be_pascal_case.symbols = consts
37+ dotnet_naming_rule.constants_should_be_pascal_case.style = consts
38+ dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
3839
39- # Sort using and Import directives with System.* appearing first
40- dotnet_sort_system_directives_first = true
40+ dotnet_naming_symbols.consts.applicable_kinds = field
41+ dotnet_naming_symbols.consts.applicable_accessibilities = *
42+ dotnet_naming_symbols.consts.required_modifiers = const
43+
44+ dotnet_naming_style.consts.capitalization = pascal_case
45+
46+ # Non-public static fields always pascal case
47+ dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.symbols = non_public_static_fields
48+ dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.style = non_public_static_fields
49+ dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.severity = suggestion
50+
51+ dotnet_naming_symbols.non_public_static_fields.applicable_kinds = field
52+ dotnet_naming_symbols.non_public_static_fields.applicable_accessibilities = private,protected,internal,protected_internal,private_protected
53+ dotnet_naming_symbols.non_public_static_fields.required_modifiers = static
54+
55+ dotnet_naming_style.non_public_static_fields.capitalization = pascal_case
56+
57+ # Non-private readonly fields are pascal case
58+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
59+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
60+ dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_fields
61+
62+ dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
63+ dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public,protected,internal,protected_internal,private_protected
64+ dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
65+
66+ dotnet_naming_style.non_private_readonly_fields.capitalization = pascal_case
67+
68+ # Private instance fields are camel case prefixed underscore
69+ dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.symbols = private_fields
70+ dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.style = private_fields
71+ dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.severity = suggestion
72+
73+ dotnet_naming_symbols.private_fields.applicable_kinds = field
74+ dotnet_naming_symbols.private_fields.applicable_accessibilities = private
75+
76+ dotnet_naming_style.private_fields.capitalization = camel_case
77+ dotnet_naming_style.private_fields.required_prefix = _
78+
79+ # Locals and parameters are camel case
80+ dotnet_naming_rule.locals.severity = suggestion
81+ dotnet_naming_rule.locals.symbols = locals
82+ dotnet_naming_rule.locals.style = locals
83+
84+ dotnet_naming_symbols.locals.applicable_kinds = parameter, local
85+
86+ dotnet_naming_style.locals.capitalization = camel_case
87+
88+ # Local functions are pascal case
89+ dotnet_naming_rule.local_functions.severity = suggestion
90+ dotnet_naming_rule.local_functions.symbols = local_functions
91+ dotnet_naming_rule.local_functions.style = local_functions
92+
93+ dotnet_naming_symbols.local_functions.applicable_kinds = local_function
94+
95+ dotnet_naming_style.local_functions.capitalization = pascal_case
96+
97+ # Public members always pascal case
98+ dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_members
99+ dotnet_naming_rule.public_members_should_be_pascal_case.style = public_members
100+ dotnet_naming_rule.public_members_should_be_pascal_case.severity = suggestion
101+
102+ dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event,delegate
103+ dotnet_naming_symbols.public_members.applicable_accessibilities = public
104+
105+ dotnet_naming_style.public_members.capitalization = pascal_case
41106
42- # Prefer this.X except for _fields
43- # TODO can we force _ for private fields?
44- # TODO elevate severity after code cleanup to warning minimum
45- # TODO use language latest
46107dotnet_style_qualification_for_field = false :error
47108dotnet_style_qualification_for_property = false :error
48109dotnet_style_qualification_for_method = false :error
@@ -71,12 +132,15 @@ csharp_style_var_for_built_in_types = true:error
71132csharp_style_var_when_type_is_apparent = true :error
72133csharp_style_var_elsewhere = true :error
73134
74- csharp_style_expression_bodied_methods = true :error
75- csharp_style_expression_bodied_constructors = true :error
76- csharp_style_expression_bodied_operators = true :error
77- csharp_style_expression_bodied_properties = true :error
78- csharp_style_expression_bodied_indexers = true :error
79- csharp_style_expression_bodied_accessors = true :error
135+ csharp_style_expression_bodied_methods = true :suggestion
136+ csharp_style_expression_bodied_constructors = true :suggestion
137+ csharp_style_expression_bodied_operators = true :suggestion
138+ csharp_style_expression_bodied_properties = true :suggestion
139+ csharp_style_expression_bodied_indexers = true :suggestion
140+ csharp_style_expression_bodied_accessors = true :suggestion
141+ csharp_style_expression_bodied_local_functions = when_on_single_line:error
142+ dotnet_style_prefer_conditional_expression_over_return = false
143+
80144
81145# Suggest more modern language features when available
82146csharp_style_pattern_matching_over_is_with_cast_check = true :error
@@ -95,59 +159,90 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter
95159
96160# Newline settings (Allman yo!)
97161csharp_new_line_before_open_brace = all
98- csharp_new_line_before_else = true : error
99- csharp_new_line_before_catch = true : error
100- csharp_new_line_before_finally = true : error
162+ csharp_new_line_before_else = true
163+ csharp_new_line_before_catch = true
164+ csharp_new_line_before_finally = true
101165csharp_new_line_before_members_in_object_initializers = true
166+
102167# just a suggestion do to our JSON tests that use anonymous types to
103168# represent json quite a bit (makes copy paste easier).
104- csharp_new_line_before_members_in_anonymous_types = true : suggestion
105- csharp_new_line_between_query_expression_clauses = true : error
169+ csharp_new_line_before_members_in_anonymous_types = true
170+ csharp_new_line_between_query_expression_clauses = true
106171
107172# Indent
108- csharp_indent_case_contents = true : error
109- csharp_indent_switch_labels = true : error
110- csharp_space_after_cast = false : error
111- csharp_space_after_keywords_in_control_flow_statements = true : error
112- csharp_space_between_method_declaration_parameter_list_parentheses = false : error
113- csharp_space_between_method_call_parameter_list_parentheses = false : error
173+ csharp_indent_case_contents = true
174+ csharp_indent_switch_labels = true
175+ csharp_space_after_cast = false
176+ csharp_space_after_keywords_in_control_flow_statements = true
177+ csharp_space_between_method_declaration_parameter_list_parentheses = false
178+ csharp_space_between_method_call_parameter_list_parentheses = false
114179
115180# Wrap
116- csharp_preserve_single_line_statements = false :error
117- csharp_preserve_single_line_blocks = true :error
118-
119- csharp_style_namespace_declarations = file_scoped
181+ csharp_preserve_single_line_statements = false
182+ csharp_preserve_single_line_blocks = true
183+ resharper_wrap_object_and_collection_initializer_style = chop_always
120184
121185# Resharper
122- resharper_csharp_braces_for_lock =required_for_complex
123- resharper_csharp_braces_for_using =required_for_complex
124- resharper_csharp_braces_for_while =required_for_complex
125- resharper_csharp_braces_for_foreach =required_for_complex
126- resharper_csharp_braces_for_for =required_for_complex
127- resharper_csharp_braces_for_fixed =required_for_complex
128- resharper_csharp_braces_for_ifelse =required_for_complex
186+ resharper_csharp_braces_for_lock =required_for_multiline
187+ resharper_csharp_braces_for_using =required_for_multiline
188+ resharper_csharp_braces_for_while =required_for_multiline
189+ resharper_csharp_braces_for_foreach =required_for_multiline
190+ resharper_csharp_braces_for_for =required_for_multiline
191+ resharper_csharp_braces_for_fixed =required_for_multiline
192+ resharper_csharp_braces_for_ifelse =required_for_multiline
193+ resharper_csharp_keep_existing_attribute_arrangement =true
129194
130195resharper_csharp_accessor_owner_body =expression_body
131196
132197resharper_redundant_case_label_highlighting =do_not_show
133198resharper_redundant_argument_default_value_highlighting =do_not_show
134- # Do not penalize code that explicitly lists generic arguments
135- resharper_redundant_type_arguments_of_method_highlighting =do_not_show
199+ resharper_explicit_caller_info_argument_highlighting =hint
136200
137- # Spell checker VS2022
138- spelling_exclusion_path = .\exclusion.dic
201+ csharp_style_namespace_declarations = file_scoped
139202
140- # Microsoft.VisualStudio.Threading.Analyzers
141- dotnet_diagnostic.VSTHRD200 .severity = error
203+ dotnet_analyzer_diagnostic.severity = warning
204+ dotnet_analyzer_diagnostic.category-Style .severity = warning
142205
143- [Jenkinsfile ]
144- indent_style = space
145- indent_size = 2
146- end_of_line = lf
147- charset = utf-8
148- trim_trailing_whitespace = true
149- insert_final_newline = true
206+ # can be made static
207+ dotnet_diagnostic.CA1822.severity = suggestion
208+
209+ # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1848
210+ dotnet_diagnostic.CA1848.severity = suggestion
211+ # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2201
212+ dotnet_diagnostic.CA2201.severity = none
213+
214+ # disable for default arm on switches, IDE0072 still covers missing enum members
215+ # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/ide0010
216+ dotnet_diagnostic.IDE0010.severity = none
217+
218+ # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/IDE0200
219+ dotnet_diagnostic.IDE0200.severity = none
220+ dotnet_diagnostic.IDE0001.severity = none
221+ dotnet_diagnostic.IDE0057.severity = none
222+ dotnet_diagnostic.IDE0051.severity = suggestion
223+ dotnet_diagnostic.IDE0059.severity = suggestion
224+ dotnet_diagnostic.CA1859.severity = none
225+ dotnet_diagnostic.CA1816.severity = none
226+
227+ # https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca1727
228+ dotnet_diagnostic.CA1727.severity = none
229+
230+ dotnet_diagnostic.IDE0305.severity = none
231+
232+ # https://github.com/dotnet/roslyn/issues/60784
233+ # CS8509 already warns
234+ dotnet_diagnostic.IDE0072.severity = none
235+
236+ [tests/** /* .cs ]
237+ dotnet_diagnostic.IDE0058.severity = none
238+ dotnet_diagnostic.IDE0022.severity = none
150239
151240[* .{sh,bat,ps1} ]
152241trim_trailing_whitespace =true
153242insert_final_newline =true
243+
244+ [* .sh ]
245+ end_of_line = lf
246+
247+ [{LICENSE,NOTICE} ]
248+ end_of_line = lf
0 commit comments