Skip to content

Commit 19cb619

Browse files
committed
Update editor config naming rules
Relates: elastic/apm-agent-dotnet#1295
1 parent adb907c commit 19cb619

File tree

1 file changed

+96
-22
lines changed

1 file changed

+96
-22
lines changed

.editorconfig

Lines changed: 96 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,23 @@ root=true
33
[*.cs]
44
trim_trailing_whitespace=true
55
insert_final_newline=true
6-
end_of_line = lf
76

87
[*]
8+
charset = utf-8
99
indent_style = tab
1010
indent_size = 4
1111

1212
[*.cshtml]
1313
indent_style = tab
1414
indent_size = 4
15-
end_of_line = lf
1615

1716
[*.{fs,fsx,yml}]
1817
indent_style = space
1918
indent_size = 4
20-
end_of_line = lf
2119

2220
[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
2321
indent_style = space
2422
indent_size = 2
25-
end_of_line = lf
2623

2724
# Dotnet code style settings:
2825
[*.{cs,vb}]
@@ -33,15 +30,86 @@ end_of_line = lf
3330
# ---
3431

3532
# ---
36-
# langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
33+
# language conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
3734

3835
# Sort using and Import directives with System.* appearing first
3936
dotnet_sort_system_directives_first = true
4037

41-
# Prefer this.X except for _fields
42-
# TODO can we force _ for private fields?
43-
# TODO elevate severity after code cleanup to warning minimum
44-
# TODO use language latest
38+
# Style rules
39+
# https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules?view=vs-2017
40+
41+
# Constants always pascal case
42+
dotnet_naming_rule.constants_should_be_pascal_case.symbols = consts
43+
dotnet_naming_rule.constants_should_be_pascal_case.style = consts
44+
dotnet_naming_rule.constants_should_be_pascal_case.severity = suggestion
45+
46+
dotnet_naming_symbols.consts.applicable_kinds = field
47+
dotnet_naming_symbols.consts.applicable_accessibilities = *
48+
dotnet_naming_symbols.consts.required_modifiers = const
49+
50+
dotnet_naming_style.consts.capitalization = pascal_case
51+
52+
# Non-public static fields always pascal case
53+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.symbols = non_public_static_fields
54+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.style = non_public_static_fields
55+
dotnet_naming_rule.non_public_static_fields_should_be_pascal_case.severity = suggestion
56+
57+
dotnet_naming_symbols.non_public_static_fields.applicable_kinds = field
58+
dotnet_naming_symbols.non_public_static_fields.applicable_accessibilities = private,protected,internal,protected_internal,private_protected
59+
dotnet_naming_symbols.non_public_static_fields.required_modifiers = static
60+
61+
dotnet_naming_style.non_public_static_fields.capitalization = pascal_case
62+
63+
# Non-private readonly fields are pascal case
64+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.severity = suggestion
65+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.symbols = non_private_readonly_fields
66+
dotnet_naming_rule.non_private_readonly_fields_should_be_pascal_case.style = non_private_readonly_fields
67+
68+
dotnet_naming_symbols.non_private_readonly_fields.applicable_kinds = field
69+
dotnet_naming_symbols.non_private_readonly_fields.applicable_accessibilities = public,protected,internal,protected_internal,private_protected
70+
dotnet_naming_symbols.non_private_readonly_fields.required_modifiers = readonly
71+
72+
dotnet_naming_style.non_private_readonly_fields.capitalization = pascal_case
73+
74+
# Private instance fields are camel case prefixed underscore
75+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.symbols = private_fields
76+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.style = private_fields
77+
dotnet_naming_rule.private_fields_should_be_camelcase_prefix_underscore.severity = suggestion
78+
79+
dotnet_naming_symbols.private_fields.applicable_kinds = field
80+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private
81+
82+
dotnet_naming_style.private_fields.capitalization = camel_case
83+
dotnet_naming_style.private_fields.required_prefix = _
84+
85+
# Locals and parameters are camel case
86+
dotnet_naming_rule.locals.severity = suggestion
87+
dotnet_naming_rule.locals.symbols = locals
88+
dotnet_naming_rule.locals.style = locals
89+
90+
dotnet_naming_symbols.locals.applicable_kinds = parameter, local
91+
92+
dotnet_naming_style.locals.capitalization = camel_case
93+
94+
# Local functions are pascal case
95+
dotnet_naming_rule.local_functions.severity = suggestion
96+
dotnet_naming_rule.local_functions.symbols = local_functions
97+
dotnet_naming_rule.local_functions.style = local_functions
98+
99+
dotnet_naming_symbols.local_functions.applicable_kinds = local_function
100+
101+
dotnet_naming_style.local_functions.capitalization = pascal_case
102+
103+
# Public members always pascal case
104+
dotnet_naming_rule.public_members_should_be_pascal_case.symbols = public_members
105+
dotnet_naming_rule.public_members_should_be_pascal_case.style = public_members
106+
dotnet_naming_rule.public_members_should_be_pascal_case.severity = suggestion
107+
108+
dotnet_naming_symbols.public_members.applicable_kinds = property,method,field,event,delegate
109+
dotnet_naming_symbols.public_members.applicable_accessibilities = public
110+
111+
dotnet_naming_style.public_members.capitalization = pascal_case
112+
45113
dotnet_style_qualification_for_field = false:error
46114
dotnet_style_qualification_for_property = false:error
47115
dotnet_style_qualification_for_method = false:error
@@ -94,26 +162,26 @@ csharp_preferred_modifier_order = public,private,protected,internal,static,exter
94162

95163
# Newline settings (Allman yo!)
96164
csharp_new_line_before_open_brace = all
97-
csharp_new_line_before_else = true:error
98-
csharp_new_line_before_catch = true:error
99-
csharp_new_line_before_finally = true:error
165+
csharp_new_line_before_else = true
166+
csharp_new_line_before_catch = true
167+
csharp_new_line_before_finally = true
100168
csharp_new_line_before_members_in_object_initializers = true
101169
# just a suggestion do to our JSON tests that use anonymous types to
102170
# represent json quite a bit (makes copy paste easier).
103-
csharp_new_line_before_members_in_anonymous_types = true:suggestion
104-
csharp_new_line_between_query_expression_clauses = true:error
171+
csharp_new_line_before_members_in_anonymous_types = true
172+
csharp_new_line_between_query_expression_clauses = true
105173

106174
# Indent
107-
csharp_indent_case_contents = true:error
108-
csharp_indent_switch_labels = true:error
109-
csharp_space_after_cast = false:error
110-
csharp_space_after_keywords_in_control_flow_statements = true:error
111-
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
112-
csharp_space_between_method_call_parameter_list_parentheses = false:error
175+
csharp_indent_case_contents = true
176+
csharp_indent_switch_labels = true
177+
csharp_space_after_cast = false
178+
csharp_space_after_keywords_in_control_flow_statements = true
179+
csharp_space_between_method_declaration_parameter_list_parentheses = false
180+
csharp_space_between_method_call_parameter_list_parentheses = false
113181

114182
#Wrap
115-
csharp_preserve_single_line_statements = false:error
116-
csharp_preserve_single_line_blocks = true:error
183+
csharp_preserve_single_line_statements = false
184+
csharp_preserve_single_line_blocks = true
117185

118186
# Resharper
119187
resharper_csharp_braces_for_lock=required_for_multiline
@@ -126,6 +194,9 @@ resharper_csharp_braces_for_ifelse=required_for_multiline
126194

127195
resharper_csharp_accessor_owner_body=expression_body
128196

197+
resharper_redundant_case_label_highlighting=do_not_show
198+
resharper_redundant_argument_default_value_highlighting=do_not_show
199+
129200
[Jenkinsfile]
130201
indent_style = space
131202
indent_size = 2
@@ -137,3 +208,6 @@ insert_final_newline = true
137208
[*.{sh,bat,ps1}]
138209
trim_trailing_whitespace=true
139210
insert_final_newline=true
211+
212+
[*.sh]
213+
end_of_line = lf

0 commit comments

Comments
 (0)