|
1 | | -# editorconfig.org |
| 1 | +# EditorConfig is awesome:http://EditorConfig.org |
2 | 2 |
|
3 | 3 | # top-most EditorConfig file |
4 | 4 | root = true |
5 | 5 |
|
6 | | -# Default settings: |
7 | | -# A newline ending every file |
8 | | -# Use 4 spaces as indentation |
| 6 | +# Don't use tabs for indentation. |
9 | 7 | [*] |
10 | | -insert_final_newline = true |
11 | 8 | indent_style = space |
12 | 9 | # (Please don't specify an indent_size here; that has too many unintended consequences.) |
13 | 10 |
|
14 | | - |
15 | 11 | # Code files |
16 | 12 | [*.{cs,csx,vb,vbx}] |
17 | 13 | indent_size = 4 |
18 | 14 |
|
19 | | -# XML project files |
20 | | -[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}] |
21 | | -indent_size = 2 |
22 | | - |
23 | | -# XML config files |
24 | | -[*.{props,targets,ruleset,stylecop,xml,config,nuspec,resx,vsixmanifest,vsct}] |
25 | | -indent_size = 2 |
26 | | - |
27 | | -# JSON files |
28 | | -[*.json] |
| 15 | +# Xml project files |
| 16 | +[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj,msbuildproj,props,targets}] |
29 | 17 | indent_size = 2 |
30 | 18 |
|
31 | | -# Powershell files |
32 | | -[*.ps1] |
| 19 | +# Xml config files |
| 20 | +[*.{ruleset,config,nuspec,resx,vsixmanifest,vsct}] |
33 | 21 | indent_size = 2 |
34 | 22 |
|
35 | | -# Shell script files |
36 | | -[*.sh] |
37 | | -end_of_line = lf |
| 23 | +# YAML files |
| 24 | +[*.{yaml,yml}] |
38 | 25 | indent_size = 2 |
39 | 26 |
|
40 | | -# Yaml devops files |
41 | | -[*.{yml,yaml}] |
| 27 | +# JSON files |
| 28 | +[*.json] |
42 | 29 | indent_size = 2 |
43 | 30 |
|
44 | | -# Shell scripts |
45 | | -[*.sh] |
46 | | -end_of_line = lf |
47 | | -[*.{cmd, bat}] |
48 | | -end_of_line = crlf |
49 | | - |
50 | | - |
51 | | -# C# files |
52 | | -[*.cs] |
53 | | -# New line preferences |
54 | | -csharp_new_line_before_open_brace = all |
55 | | -csharp_new_line_before_else = true |
56 | | -csharp_new_line_before_catch = true |
57 | | -csharp_new_line_before_finally = true |
58 | | -csharp_new_line_before_members_in_object_initializers = true |
59 | | -csharp_new_line_before_members_in_anonymous_types = true |
60 | | -csharp_new_line_within_query_expression_clauses = true |
61 | | - |
62 | | -# Indentation preferences |
63 | | -csharp_indent_block_contents = true |
64 | | -csharp_indent_braces = false |
65 | | -csharp_indent_case_contents = true |
66 | | -csharp_indent_switch_labels = true |
67 | | -csharp_indent_labels = flush_left |
68 | | - |
69 | | -# avoid this. unless absolutely necessary |
| 31 | +# Dotnet code style settings: |
| 32 | +[*.{cs,vb}] |
| 33 | +# Sort using and Import directives with System.* appearing first |
| 34 | +dotnet_sort_system_directives_first = true |
| 35 | +# Avoid "this." and "Me." if not necessary |
70 | 36 | dotnet_style_qualification_for_field = false:suggestion |
71 | 37 | dotnet_style_qualification_for_property = false:suggestion |
72 | 38 | dotnet_style_qualification_for_method = false:suggestion |
73 | 39 | dotnet_style_qualification_for_event = false:suggestion |
74 | 40 |
|
75 | | -# Prefer "var" everywhere |
76 | | -csharp_style_var_for_built_in_types = true:suggestion |
77 | | -csharp_style_var_when_type_is_apparent = true:suggestion |
78 | | -csharp_style_var_elsewhere = true:suggestion |
79 | | - |
80 | | -# use language keywords instead of BCL types |
| 41 | +# Use language keywords instead of framework type names for type references |
81 | 42 | dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion |
82 | 43 | dotnet_style_predefined_type_for_member_access = true:suggestion |
83 | 44 |
|
84 | | -# name all constant fields using PascalCase |
85 | | -dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion |
86 | | -dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields |
87 | | -dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style |
| 45 | +# Suggest more modern language features when available |
| 46 | +dotnet_style_object_initializer = true:suggestion |
| 47 | +dotnet_style_collection_initializer = true:suggestion |
| 48 | +dotnet_style_coalesce_expression = true:suggestion |
| 49 | +dotnet_style_null_propagation = true:suggestion |
| 50 | +dotnet_style_explicit_tuple_names = true:suggestion |
88 | 51 |
|
89 | | -dotnet_naming_symbols.constant_fields.applicable_kinds = field |
90 | | -dotnet_naming_symbols.constant_fields.required_modifiers = const |
| 52 | +# CSharp code style settings: |
91 | 53 |
|
92 | | -dotnet_naming_style.pascal_case_style.capitalization = pascal_case |
| 54 | +# IDE0040: Add accessibility modifiers |
| 55 | +dotnet_style_require_accessibility_modifiers = omit_if_default:error |
93 | 56 |
|
94 | | -# internal and private fields should be _camelCase |
95 | | -dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion |
96 | | -dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields |
97 | | -dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case |
| 57 | +# IDE0040: Add accessibility modifiers |
| 58 | +dotnet_diagnostic.IDE0040.severity = error |
98 | 59 |
|
99 | | -dotnet_naming_symbols.private_internal_fields.applicable_kinds = field |
100 | | -dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal |
| 60 | +[*.cs] |
| 61 | +# Prefer "var" everywhere |
| 62 | +csharp_style_var_for_built_in_types = true:suggestion |
| 63 | +csharp_style_var_when_type_is_apparent = true:suggestion |
| 64 | +csharp_style_var_elsewhere = true:suggestion |
101 | 65 |
|
102 | | -# Code style defaults |
103 | | -dotnet_sort_system_directives_first = true |
104 | | -csharp_preserve_single_line_blocks = true |
105 | | -csharp_preserve_single_line_statements = false |
| 66 | +# Prefer method-like constructs to have an expression-body |
| 67 | +csharp_style_expression_bodied_methods = true:none |
| 68 | +csharp_style_expression_bodied_constructors = true:none |
| 69 | +csharp_style_expression_bodied_operators = true:none |
106 | 70 |
|
107 | | -# Expression-level preferences |
108 | | -dotnet_style_object_initializer = true:suggestion |
109 | | -dotnet_style_collection_initializer = true:suggestion |
110 | | -dotnet_style_explicit_tuple_names = true:suggestion |
111 | | -dotnet_style_coalesce_expression = true:suggestion |
112 | | -dotnet_style_null_propagation = true:suggestion |
| 71 | +# Prefer property-like constructs to have an expression-body |
| 72 | +csharp_style_expression_bodied_properties = true:none |
| 73 | +csharp_style_expression_bodied_indexers = true:none |
| 74 | +csharp_style_expression_bodied_accessors = true:none |
113 | 75 |
|
114 | | -# Expression-bodied members |
115 | | -csharp_style_expression_bodied_methods = when_on_single_line:suggestion |
116 | | -csharp_style_expression_bodied_constructors = when_on_single_line:suggestion |
117 | | -csharp_style_expression_bodied_operators = when_on_single_line:suggestion |
118 | | -csharp_style_expression_bodied_properties = when_on_single_line:suggestion |
119 | | -csharp_style_expression_bodied_indexers = when_on_single_line:suggestion |
120 | | -csharp_style_expression_bodied_accessors = when_on_single_line:suggestion |
121 | | - |
122 | | -# Pattern matching |
123 | | -csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion |
124 | | -csharp_style_pattern_matching_over_as_with_null_check = true:suggestion |
| 76 | +# Suggest more modern language features when available |
| 77 | +csharp_style_pattern_matching_over_is_with_cast_check = true:error |
| 78 | +csharp_style_pattern_matching_over_as_with_null_check = true:error |
125 | 79 | csharp_style_inlined_variable_declaration = true:suggestion |
126 | | - |
127 | | -# Null checking preferences |
128 | 80 | csharp_style_throw_expression = true:suggestion |
129 | 81 | csharp_style_conditional_delegate_call = true:suggestion |
130 | 82 |
|
131 | | -# Space preferences |
132 | | -csharp_space_after_cast = false |
133 | | -csharp_space_after_colon_in_inheritance_clause = true |
134 | | -csharp_space_after_comma = true |
135 | | -csharp_space_after_dot = false |
136 | | -csharp_space_after_keywords_in_control_flow_statements = true |
137 | | -csharp_space_after_semicolon_in_for_statement = true |
138 | | -csharp_space_around_binary_operators = before_and_after |
139 | | -csharp_space_around_declaration_statements = do_not_ignore |
140 | | -csharp_space_before_colon_in_inheritance_clause = true |
141 | | -csharp_space_before_comma = false |
142 | | -csharp_space_before_dot = false |
143 | | -csharp_space_before_open_square_brackets = false |
144 | | -csharp_space_before_semicolon_in_for_statement = false |
145 | | -csharp_space_between_empty_square_brackets = false |
146 | | -csharp_space_between_method_call_empty_parameter_list_parentheses = false |
147 | | -csharp_space_between_method_call_name_and_opening_parenthesis = false |
148 | | -csharp_space_between_method_call_parameter_list_parentheses = false |
149 | | -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false |
150 | | -csharp_space_between_method_declaration_name_and_open_parenthesis = false |
151 | | -csharp_space_between_method_declaration_parameter_list_parentheses = false |
152 | | -csharp_space_between_parentheses = false |
153 | | -csharp_space_between_square_brackets = false |
| 83 | +# Newline settings |
| 84 | +csharp_new_line_before_open_brace = all |
| 85 | +csharp_new_line_before_else = true |
| 86 | +csharp_new_line_before_catch = true |
| 87 | +csharp_new_line_before_finally = true |
| 88 | +csharp_new_line_before_members_in_object_initializers = true |
| 89 | +csharp_new_line_before_members_in_anonymous_types = true |
0 commit comments