Skip to content

Commit 20831b7

Browse files
Update ASP.NET Core with editorconfig
1 parent e211a7e commit 20831b7

File tree

6 files changed

+669
-413
lines changed

6 files changed

+669
-413
lines changed

ASP.NET Core/.editorconfig

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
1+
# Remove the line below if you want to inherit .editorconfig settings from higher directories
2+
root = true
3+
4+
# All files
5+
[*]
6+
indent_style = space
7+
indent_size = 4
8+
tab_width = 4
9+
charset = utf-8
10+
insert_final_newline = true
11+
end_of_line = lf
12+
trim_trailing_whitespace = true
13+
guidelines = 120
14+
15+
# C# files
16+
[*.cs]
17+
18+
#### .NET Coding Conventions ####
19+
20+
# Organize usings
21+
dotnet_separate_import_directive_groups = false
22+
dotnet_sort_system_directives_first = true
23+
file_header_template = unset
24+
25+
# this. and Me. preferences
26+
dotnet_style_qualification_for_event = false
27+
dotnet_style_qualification_for_field = false
28+
dotnet_style_qualification_for_method = false
29+
dotnet_style_qualification_for_property = false
30+
31+
# Language keywords vs BCL types preferences
32+
dotnet_style_predefined_type_for_locals_parameters_members = true
33+
dotnet_style_predefined_type_for_member_access = true
34+
35+
# Parentheses preferences
36+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity
37+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity
38+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary
39+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity
40+
41+
# Modifier preferences
42+
dotnet_style_require_accessibility_modifiers = for_non_interface_members
43+
44+
# Expression-level preferences
45+
dotnet_style_coalesce_expression = true
46+
dotnet_style_collection_initializer = true
47+
dotnet_style_explicit_tuple_names = true
48+
dotnet_style_namespace_match_folder = false
49+
dotnet_style_null_propagation = true
50+
dotnet_style_object_initializer = true
51+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
52+
dotnet_style_prefer_auto_properties = true
53+
dotnet_style_prefer_compound_assignment = true
54+
dotnet_style_prefer_conditional_expression_over_assignment = true
55+
dotnet_style_prefer_conditional_expression_over_return = true
56+
dotnet_style_prefer_inferred_anonymous_type_member_names = true
57+
dotnet_style_prefer_inferred_tuple_names = true
58+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true
59+
dotnet_style_prefer_simplified_boolean_expressions = true
60+
dotnet_style_prefer_simplified_interpolation = true
61+
62+
# Field preferences
63+
dotnet_style_readonly_field = true
64+
65+
# Parameter preferences
66+
dotnet_code_quality_unused_parameters = all
67+
68+
# Suppression preferences
69+
dotnet_remove_unnecessary_suppression_exclusions = none
70+
dotnet_diagnostic.S1186.severity = none
71+
dotnet_diagnostic.S6602.severity = none
72+
dotnet_diagnostic.S6605.severity = none
73+
dotnet_diagnostic.S6608.severity = none
74+
dotnet_diagnostic.S2971.severity = none
75+
dotnet_diagnostic.S4136.severity = none
76+
dotnet_diagnostic.S1066.severity = none
77+
dotnet_diagnostic.S3358.severity = none
78+
dotnet_diagnostic.S6562.severity = none
79+
dotnet_diagnostic.S3267.severity = none
80+
dotnet_diagnostic.S6967.severity = none
81+
dotnet_diagnostic.S1121.severity = suggestion
82+
dotnet_diagnostic.S1144.severity = suggestion
83+
dotnet_diagnostic.S2325.severity = suggestion
84+
dotnet_diagnostic.S3963.severity = suggestion
85+
dotnet_diagnostic.CA1826.severity = none
86+
87+
# New line preferences
88+
dotnet_style_allow_multiple_blank_lines_experimental = true
89+
dotnet_style_allow_statement_immediately_after_block_experimental = true
90+
91+
#### C# Coding Conventions ####
92+
93+
# var preferences
94+
csharp_style_var_elsewhere = false
95+
csharp_style_var_for_built_in_types = false
96+
csharp_style_var_when_type_is_apparent = false
97+
98+
# Expression-bodied members
99+
csharp_style_expression_bodied_accessors =true:suggestion
100+
csharp_style_expression_bodied_constructors =false:silent
101+
csharp_style_expression_bodied_indexers =true:suggestion
102+
csharp_style_expression_bodied_lambdas =true:warning
103+
csharp_style_expression_bodied_local_functions =true:suggestion
104+
csharp_style_expression_bodied_methods =false:silent
105+
csharp_style_expression_bodied_operators =false:silent
106+
csharp_style_expression_bodied_properties =true:suggestion
107+
108+
# Pattern matching preferences
109+
csharp_style_pattern_matching_over_as_with_null_check = true
110+
csharp_style_pattern_matching_over_is_with_cast_check = true
111+
csharp_style_prefer_not_pattern = true
112+
csharp_style_prefer_pattern_matching =true:suggestion
113+
csharp_style_prefer_switch_expression = true
114+
115+
# Null-checking preferences
116+
csharp_style_conditional_delegate_call =true:warning
117+
118+
# Modifier preferences
119+
csharp_prefer_static_local_function = true
120+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
121+
122+
# Code-block preferences
123+
csharp_prefer_braces = true
124+
csharp_prefer_simple_using_statement = true
125+
csharp_style_namespace_declarations = file_scoped:suggestion
126+
127+
# Expression-level preferences
128+
csharp_prefer_simple_default_expression = true
129+
csharp_style_deconstructed_variable_declaration = true
130+
csharp_style_implicit_object_creation_when_type_is_apparent = true
131+
csharp_style_inlined_variable_declaration = true
132+
csharp_style_pattern_local_over_anonymous_function =true:silent
133+
csharp_style_prefer_index_operator = true
134+
csharp_style_prefer_range_operator = true
135+
csharp_style_throw_expression = true
136+
csharp_style_unused_value_assignment_preference = discard_variable
137+
csharp_style_unused_value_expression_statement_preference = discard_variable
138+
139+
# 'using' directive preferences
140+
csharp_using_directive_placement =outside_namespace:warning
141+
142+
# New line preferences
143+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true
144+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true
145+
csharp_style_allow_embedded_statements_on_same_line_experimental = true
146+
147+
#### C# Formatting Rules ####
148+
149+
# New line preferences
150+
csharp_new_line_before_catch = false
151+
csharp_new_line_before_else = false
152+
csharp_new_line_before_finally = false
153+
csharp_new_line_before_members_in_anonymous_types = true
154+
csharp_new_line_before_members_in_object_initializers = true
155+
csharp_new_line_before_open_brace = none
156+
csharp_new_line_between_query_expression_clauses = true
157+
158+
# Indentation preferences
159+
csharp_indent_block_contents = true
160+
csharp_indent_braces = false
161+
csharp_indent_case_contents = true
162+
csharp_indent_case_contents_when_block = true
163+
csharp_indent_labels = no_change
164+
csharp_indent_switch_labels = true
165+
166+
# Space preferences
167+
csharp_space_after_cast = false
168+
csharp_space_after_colon_in_inheritance_clause = true
169+
csharp_space_after_comma = true
170+
csharp_space_after_dot = false
171+
csharp_space_after_keywords_in_control_flow_statements = false
172+
csharp_space_after_semicolon_in_for_statement = true
173+
csharp_space_around_binary_operators = before_and_after
174+
csharp_space_around_declaration_statements = false
175+
csharp_space_before_colon_in_inheritance_clause = false
176+
csharp_space_before_comma = false
177+
csharp_space_before_dot = false
178+
csharp_space_before_open_square_brackets = false
179+
csharp_space_before_semicolon_in_for_statement = false
180+
csharp_space_between_empty_square_brackets = false
181+
csharp_space_between_method_call_empty_parameter_list_parentheses = false
182+
csharp_space_between_method_call_name_and_opening_parenthesis = false
183+
csharp_space_between_method_call_parameter_list_parentheses = false
184+
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
185+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
186+
csharp_space_between_method_declaration_parameter_list_parentheses = false
187+
csharp_space_between_parentheses = false
188+
csharp_space_between_square_brackets = false
189+
190+
# Wrapping preferences
191+
csharp_preserve_single_line_blocks = true
192+
csharp_preserve_single_line_statements = true
193+
194+
#### Naming styles ####
195+
196+
# Naming rules
197+
198+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
199+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
200+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
201+
202+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
203+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
204+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
205+
206+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
207+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
208+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
209+
210+
# Symbol specifications
211+
212+
dotnet_naming_symbols.interface.applicable_kinds = interface
213+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
214+
dotnet_naming_symbols.interface.required_modifiers =
215+
216+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
217+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
218+
dotnet_naming_symbols.types.required_modifiers =
219+
220+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
221+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
222+
dotnet_naming_symbols.non_field_members.required_modifiers =
223+
224+
# Naming styles
225+
226+
dotnet_naming_style.pascal_case.required_prefix =
227+
dotnet_naming_style.pascal_case.required_suffix =
228+
dotnet_naming_style.pascal_case.word_separator =
229+
dotnet_naming_style.pascal_case.capitalization = pascal_case
230+
231+
dotnet_naming_style.begins_with_i.required_prefix = I
232+
dotnet_naming_style.begins_with_i.required_suffix =
233+
dotnet_naming_style.begins_with_i.word_separator =
234+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
235+
236+
# IDE0290 Use primary constructor
237+
dotnet_diagnostic.IDE0290.severity = none
238+
239+
[*.{cs,vb}]
240+
dotnet_style_prefer_conditional_expression_over_assignment=true:suggestion
241+
dotnet_style_prefer_conditional_expression_over_return=true:suggestion
242+
dotnet_style_readonly_field=true:warning
243+
dotnet_style_predefined_type_for_locals_parameters_members=true:warning
244+
dotnet_style_parentheses_in_arithmetic_binary_operators=always_for_clarity:warning
245+
dotnet_style_parentheses_in_other_binary_operators=always_for_clarity:warning
246+
dotnet_style_parentheses_in_relational_binary_operators=always_for_clarity:warning
247+
dotnet_style_qualification_for_field=false:suggestion
248+
dotnet_style_qualification_for_property=false:suggestion
249+
dotnet_style_qualification_for_method=false:suggestion
250+
dotnet_style_qualification_for_event=false:suggestion
251+
252+
[*.{json,eslintrc,xml,config}]
253+
indent_size = 2
254+
tab_width = 2
255+
256+
[*.sh]
257+
end_of_line = lf
258+
259+
[*.{bat,cmd,sln}]
260+
end_of_line = crlf
261+
262+
[*.{*proj}]
263+
indent_size = 2
264+
tab_width = 2

ASP.NET Core/Controllers/HomeController.cs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,14 @@
44
using System.Threading.Tasks;
55
using Microsoft.AspNetCore.Mvc;
66

7-
namespace ASP_NET_Core.Controllers
8-
{
9-
public class HomeController : Controller
10-
{
11-
public IActionResult Index()
12-
{
13-
return View();
14-
}
7+
namespace ASP_NET_Core.Controllers;
8+
public class HomeController: Controller {
9+
public IActionResult Index() {
10+
return View();
11+
}
1512

16-
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
17-
public IActionResult Error() {
18-
return View();
19-
}
13+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
14+
public IActionResult Error() {
15+
return View();
2016
}
2117
}

ASP.NET Core/Controllers/SampleDataController.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
using DevExtreme.AspNet.Mvc;
99
using Microsoft.AspNetCore.Mvc;
1010

11-
namespace ASP_NET_Core.Controllers {
11+
namespace ASP_NET_Core.Controllers;
1212

13-
[Route("api/[controller]")]
14-
public class SampleDataController : Controller {
15-
16-
[HttpGet]
17-
public object Get(DataSourceLoadOptions loadOptions) {
18-
return DataSourceLoader.Load(SampleData.Orders, loadOptions);
19-
}
13+
[Route("api/[controller]")]
14+
public class SampleDataController: Controller {
2015

16+
[HttpGet]
17+
public object Get(DataSourceLoadOptions loadOptions) {
18+
return DataSourceLoader.Load(SampleData.Orders, loadOptions);
2119
}
22-
}
20+
21+
}

0 commit comments

Comments
 (0)