-
Notifications
You must be signed in to change notification settings - Fork 0
/
.editorconfig
174 lines (136 loc) · 7.11 KB
/
.editorconfig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
root=true
# Use UNIX line endings for .sh fils so we play nice cross platform
[*.sh]
end_of_line = lf
[*.cs]
indent_style = space
indent_size = 4
#
# NOTE:
#
# https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
#
# Good resource for most values
# https://github.com/dotnet/roslyn/blob/master/.editorconfig
#
# Avoid "this." for methods, fields, events and properties
dotnet_style_qualification_for_field = false:error
dotnet_style_qualification_for_method = false:error
dotnet_style_qualification_for_property = false:error
dotnet_style_qualification_for_event = false:error
# Use language keywords instead of framework type names for type references (such as int not Int32)
dotnet_style_predefined_type_for_locals_parameters_members = true:error
dotnet_style_predefined_type_for_member_access = true:error
# Require access modifiers all the time (i.e. private void Function(), not just void Function())
dotnet_style_require_accessibility_modifiers = always:error
# Force order of modifiers
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error
# Prefer "var" everywhere
csharp_style_var_for_built_in_types = true:error
csharp_style_var_when_type_is_apparent = true:error
csharp_style_var_elsewhere = true:error
# Prefer method-like constructs to have a block body (using {})
# csharp_style_expression_bodied_methods = false:error
# csharp_style_expression_bodied_constructors = false:error
# csharp_style_expression_bodied_operators = false:error
# Prefer property-like constructs to have an expression-body (properties using => instead of {})
csharp_style_expression_bodied_properties = true:error
csharp_style_expression_bodied_indexers = true:error
csharp_style_expression_bodied_accessors = true:error
# Force objects to initialize their members inside {} on construction
dotnet_style_object_initializer = true:error
dotnet_style_collection_initializer = true:error
# Use tuple explicit names not the Item1, Item2 properties
dotnet_style_explicit_tuple_names = true:error
# Force expression coalescing
# var a = x ?? y;
# instead of: var a = x == null ? y : x;
dotnet_style_coalesce_expression = true:error
# Force null propagation
# var s = o?.ToString()
# instead of: var s = o == null ? null : o.ToString()
dotnet_style_null_propagation = true:error
# Force pattern matching over cast checking
# if (o is int i)
# instead of: if (o is int) { var i = (int)o; }
csharp_style_pattern_matching_over_is_with_cast_check = true:error
# Force pattern matching over null checking
# if (o is string s)
# instead of: var s = (string)o; if (s != null) {}
csharp_style_pattern_matching_over_as_with_null_check = true:error
# Force using tuple names never the Item1, Item2 etc...
dotnet_style_explicit_tuple_names = true:error
# Force inline variable declaration
# SomeCall(out onError e)
# instead of: int e; SomeCall(out e);
csharp_style_inlined_variable_declaration = true:error
# Force use of ?? for throwing on null checks
# var b = a ?? throw();
# instead of: if (a == null) { throw(); } b = a;
csharp_style_throw_expression = true:error
# Force calling delegates with null check
# func?.Invoke()
# instead of: if (func != null) func();
csharp_style_conditional_delegate_call = true:error
# Prefer no braces for one liner if's
# NOTE: Just show as warning as some one-liners just look better with braces
# if it has a lot of parameters
csharp_prefer_braces = false:warning
#
# EXPRESSION LEVEL PREFERENCES
#
#
# Prefer int a = default; instead of int a = default(int)
csharp_prefer_simple_default_expression = true:error
# Prefer using var for a tuple instead of deconstructed tuple
# false = var person = GetPersonTuple()
# false = var (name, age) = GetPersonTuple()
csharp_style_deconstructed_variable_declaration = false:error
# Prefer local functions over anonymous functions
# NOTE: Right now I have no preference so ingnore this
# true = int fibonacci(int n) { return n <= 1 ? 1 : fibonacci(n-1) + fibonacci(n-2); }
# false = Func<int, int> fibonacci = null;
# fibonacci = (int n) => {} return n <= 1 ? 1 : fibonacci(n - 1) + fibonacci(n - 2); };
# csharp_style_pattern_local_over_anonymous_function = false:error
#
# NAMING CONVENTIONS
# https://github.com/dotnet/roslyn/pull/15065
#
# NOTE: Order of priority works here, so to exclude private static members
# from the m-prefix style place it before the prefix rule
#
# Any static field and Properties should be just PascalCase
dotnet_naming_rule.static_fields_pascal.severity = error
dotnet_naming_rule.static_fields_pascal.symbols = static_fields_pascal_symbols
dotnet_naming_rule.static_fields_pascal.style = static_fields_pascal_style
dotnet_naming_style.static_fields_pascal_style.capitalization = pascal_case
dotnet_naming_symbols.static_fields_pascal_symbols.applicable_kinds = field
dotnet_naming_symbols.static_fields_pascal_symbols.required_modifiers = static
# Member fields must start with 'm' then PascalCase
dotnet_naming_rule.members_start_with_m.severity = warning
dotnet_naming_rule.members_start_with_m.symbols = members_start_with_m_symbols
dotnet_naming_rule.members_start_with_m.style = members_start_with_m_style
dotnet_naming_style.members_start_with_m_style.capitalization = pascal_case
dotnet_naming_style.members_start_with_m_style.required_prefix = m
dotnet_naming_symbols.members_start_with_m_symbols.applicable_kinds = field
dotnet_naming_symbols.members_start_with_m_symbols.required_modifiers = private,internal,private,protected,protected_internal
# Async methods end with Async
dotnet_naming_rule.async_methods_must_end_with_async.severity = error
dotnet_naming_rule.async_methods_must_end_with_async.symbols = async_methods_must_end_with_async_symbols
dotnet_naming_rule.async_methods_must_end_with_async.style = async_methods_must_end_with_async_style
dotnet_naming_symbols.async_methods_must_end_with_async_symbols.applicable_kinds = method
dotnet_naming_symbols.async_methods_must_end_with_async_symbols.required_modifiers = async
dotnet_naming_style.async_methods_must_end_with_async_style.capitalization = pascal_case
dotnet_naming_style.async_methods_must_end_with_async_style.required_suffix = Async
# Properties and Enums are PascalCase
dotnet_naming_rule.properties_pascal.severity = error
dotnet_naming_rule.properties_pascal.symbols = properties_pascal_symbols
dotnet_naming_rule.properties_pascal.style = properties_pascal_style
dotnet_naming_style.properties_pascal_style.capitalization = pascal_case
dotnet_naming_symbols.properties_pascal_symbols.applicable_kinds = property,enum
# Classes, Structs, Events, Delegates, Methods and Interfaces are PascalCase
dotnet_naming_rule.class_pascal.severity = error
dotnet_naming_rule.class_pascal.symbols = class_pascal_symbols
dotnet_naming_rule.class_pascal.style = class_pascal_style
dotnet_naming_style.class_pascal_style.capitalization = pascal_case
dotnet_naming_symbols.class_pascal_symbols.applicable_kinds = class,interface,struct,method,event,delegate