Skip to content

Commit 61e9c9d

Browse files
authored
Merge pull request #46 from stricq/dev
Lots of code cleanup; Roslyn and Resharper fixes
2 parents 6f83ea0 + ce2e31e commit 61e9c9d

25 files changed

+684
-639
lines changed

.editorconfig

Lines changed: 54 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ csharp_prefer_simple_default_expression= false:suggestion
8484
#Style - implicit and explicit types
8585

8686
#prefer explicit type over var in all cases, unless overridden by another code style rule
87-
csharp_style_var_elsewhere=false:suggestion
87+
csharp_style_var_elsewhere= false:suggestion
8888
#prefer explicit type over var to declare variables with built-in system types such as int
89-
csharp_style_var_for_built_in_types=false:suggestion
89+
csharp_style_var_for_built_in_types= false:suggestion
9090
#prefer explicit type over var when the type is already mentioned on the right-hand side of a declaration
91-
csharp_style_var_when_type_is_apparent=false:suggestion
91+
csharp_style_var_when_type_is_apparent= false:suggestion
9292

9393
#Style - language keyword and framework type options
9494

@@ -113,7 +113,7 @@ csharp_preferred_modifier_order=public,private,protected,internal,static,overrid
113113
#Style - Pattern matching
114114

115115
#prefer pattern matching instead of is expression with type casts
116-
csharp_style_pattern_matching_over_as_with_null_check=true:suggestion
116+
csharp_style_pattern_matching_over_as_with_null_check= true:suggestion
117117

118118
#Style - qualification options
119119

@@ -126,7 +126,7 @@ dotnet_style_qualification_for_method=false:suggestion
126126
#prefer properties not to be prefaced with this. or Me. in Visual Basic
127127
dotnet_style_qualification_for_property=false:suggestion
128128

129-
dotnet_remove_unnecessary_suppression_exclusions=category: ReSharper
129+
dotnet_remove_unnecessary_suppression_exclusions=category: ReSharper,AsyncUsage
130130

131131
# ReSharper properties
132132
resharper_space_within_single_line_array_initializer_braces=true
@@ -152,18 +152,18 @@ dotnet_naming_symbols.async_method.required_modifiers = async
152152

153153
dotnet_naming_symbols.method.applicable_kinds = method
154154
dotnet_naming_symbols.method.applicable_accessibilities = public
155-
dotnet_naming_symbols.method.required_modifiers =
155+
dotnet_naming_symbols.method.required_modifiers =
156156

157157
# Naming styles
158158

159-
dotnet_naming_style.pascal_case_async.required_prefix =
159+
dotnet_naming_style.pascal_case_async.required_prefix =
160160
dotnet_naming_style.pascal_case_async.required_suffix = Async
161-
dotnet_naming_style.pascal_case_async.word_separator =
161+
dotnet_naming_style.pascal_case_async.word_separator =
162162
dotnet_naming_style.pascal_case_async.capitalization = pascal_case
163163

164-
dotnet_naming_style.pascal_case.required_prefix =
165-
dotnet_naming_style.pascal_case.required_suffix =
166-
dotnet_naming_style.pascal_case.word_separator =
164+
dotnet_naming_style.pascal_case.required_prefix =
165+
dotnet_naming_style.pascal_case.required_suffix =
166+
dotnet_naming_style.pascal_case.word_separator =
167167
dotnet_naming_style.pascal_case.capitalization = pascal_case
168168
csharp_using_directive_placement = outside_namespace:silent
169169
csharp_prefer_simple_using_statement = true:suggestion
@@ -188,6 +188,23 @@ csharp_style_unused_value_assignment_preference = discard_variable:suggestion
188188
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
189189
csharp_indent_labels = one_less_than_current
190190
csharp_space_around_binary_operators = before_and_after
191+
csharp_prefer_system_threading_lock = true:suggestion
192+
csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion
193+
csharp_prefer_static_local_function = true:suggestion
194+
csharp_prefer_static_anonymous_function = true:suggestion
195+
csharp_style_prefer_readonly_struct = true:suggestion
196+
csharp_style_prefer_readonly_struct_member = true:suggestion
197+
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
198+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
199+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
200+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
201+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
202+
csharp_style_conditional_delegate_call = true:suggestion
203+
csharp_style_prefer_switch_expression = true:suggestion
204+
csharp_style_prefer_pattern_matching = true:silent
205+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
206+
csharp_style_prefer_not_pattern = true:suggestion
207+
csharp_style_prefer_extended_property_pattern = true:suggestion
191208

192209
[*.{cs,vb}]
193210
#### Naming styles ####
@@ -210,31 +227,31 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
210227

211228
dotnet_naming_symbols.interface.applicable_kinds = interface
212229
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
213-
dotnet_naming_symbols.interface.required_modifiers =
230+
dotnet_naming_symbols.interface.required_modifiers =
214231

215232
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
216233
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
217-
dotnet_naming_symbols.types.required_modifiers =
234+
dotnet_naming_symbols.types.required_modifiers =
218235

219236
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
220237
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
221-
dotnet_naming_symbols.non_field_members.required_modifiers =
238+
dotnet_naming_symbols.non_field_members.required_modifiers =
222239

223240
# Naming styles
224241

225242
dotnet_naming_style.begins_with_i.required_prefix = I
226-
dotnet_naming_style.begins_with_i.required_suffix =
227-
dotnet_naming_style.begins_with_i.word_separator =
243+
dotnet_naming_style.begins_with_i.required_suffix =
244+
dotnet_naming_style.begins_with_i.word_separator =
228245
dotnet_naming_style.begins_with_i.capitalization = pascal_case
229246

230-
dotnet_naming_style.pascal_case.required_prefix =
231-
dotnet_naming_style.pascal_case.required_suffix =
232-
dotnet_naming_style.pascal_case.word_separator =
247+
dotnet_naming_style.pascal_case.required_prefix =
248+
dotnet_naming_style.pascal_case.required_suffix =
249+
dotnet_naming_style.pascal_case.word_separator =
233250
dotnet_naming_style.pascal_case.capitalization = pascal_case
234251

235-
dotnet_naming_style.pascal_case.required_prefix =
236-
dotnet_naming_style.pascal_case.required_suffix =
237-
dotnet_naming_style.pascal_case.word_separator =
252+
dotnet_naming_style.pascal_case.required_prefix =
253+
dotnet_naming_style.pascal_case.required_suffix =
254+
dotnet_naming_style.pascal_case.word_separator =
238255
dotnet_naming_style.pascal_case.capitalization = pascal_case
239256
dotnet_style_coalesce_expression = true:suggestion
240257
dotnet_style_null_propagation = true:suggestion
@@ -256,3 +273,18 @@ dotnet_style_operator_placement_when_wrapping = beginning_of_line
256273
tab_width = 4
257274
indent_size = 4
258275
end_of_line = crlf
276+
dotnet_style_readonly_field = true:suggestion
277+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
278+
dotnet_style_predefined_type_for_member_access = false:suggestion
279+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
280+
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
281+
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
282+
dotnet_code_quality_unused_parameters = all:suggestion
283+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
284+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
285+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
286+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
287+
dotnet_style_qualification_for_field = false:suggestion
288+
dotnet_style_qualification_for_property = false:suggestion
289+
dotnet_style_qualification_for_method = false:suggestion
290+
dotnet_style_qualification_for_event = false:suggestion

.github/workflows/build-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ jobs:
5555
5656
printf -v jdate '%(%y%j%H%M)T'
5757
58-
branch_name=${{github.ref_name}}
58+
branch_name=${{ github.ref_name }}
5959
6060
values=(${branch_name//_/ })
6161

Str.Common.Tests/LockingObservableCollectionTests.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,24 @@ public void OnCollectionChangedMoveEventSameIndexTest() {
134134
Assert.AreEqual(0, changedCount);
135135
}
136136

137-
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException)), TestCategory("Unit")]
137+
[TestMethod, TestCategory("Unit")]
138138
public void OnCollectionChangedMoveSourceOutOfRangeTest() {
139139
TestClass tester1 = new();
140140
TestClass tester2 = new();
141141

142142
LockingObservableCollection<TestClass> testCollection = [tester1, tester2];
143143

144-
145-
testCollection.Move(2, 1);
144+
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => testCollection.Move(2, 1));
146145
}
147146

148-
[TestMethod, ExpectedException(typeof(ArgumentOutOfRangeException)), TestCategory("Unit")]
147+
[TestMethod, TestCategory("Unit")]
149148
public void OnCollectionChangedMoveDestinationOutOfRangeTest() {
150149
TestClass tester1 = new();
151150
TestClass tester2 = new();
152151

153152
LockingObservableCollection<TestClass> testCollection = [tester1, tester2];
154153

155-
testCollection.Move(1, 2);
154+
Assert.ThrowsExactly<ArgumentOutOfRangeException>(() => testCollection.Move(1, 2));
156155
}
157156

158157
#endregion OnCollectionChanged Tests

Str.Common.Tests/LockingReadOnlyCollectionTests.cs

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -6,82 +6,83 @@
66

77
namespace Str.Common.Tests;
88

9+
910
[TestClass]
1011
public class LockingReadOnlyCollectionTests {
1112

12-
[TestMethod, TestCategory("Unit")]
13-
public void LockingReadOnlyCollectionCount() {
14-
List<int> source = [1, 2, 3];
13+
[TestMethod, TestCategory("Unit")]
14+
public void LockingReadOnlyCollectionCount() {
15+
List<int> source = [1, 2, 3];
1516

16-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
17+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
1718

18-
Assert.AreEqual(source.Count, tester.Count);
19-
}
19+
Assert.AreEqual(source.Count, tester.Count);
20+
}
2021

21-
[TestMethod, TestCategory("Unit")]
22-
public void LockingReadOnlyCollectionContains() {
23-
List<int> source = [1, 2, 3];
22+
[TestMethod, TestCategory("Unit")]
23+
public void LockingReadOnlyCollectionContains() {
24+
List<int> source = [1, 2, 3];
2425

25-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
26+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
2627

27-
Assert.IsTrue(tester.Contains(2));
28-
}
28+
Assert.IsTrue(tester.Contains(2));
29+
}
2930

30-
[TestMethod, TestCategory("Unit")]
31-
public void LockingReadOnlyCollectionCopyTo() {
32-
List<int> source = [1, 2, 3];
31+
[TestMethod, TestCategory("Unit")]
32+
public void LockingReadOnlyCollectionCopyTo() {
33+
List<int> source = [1, 2, 3];
3334

34-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
35+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
3536

36-
int[] array = new int[3];
37+
int[] array = new int[3];
3738

38-
tester.CopyTo(array, 0);
39+
tester.CopyTo(array, 0);
3940

40-
Assert.AreEqual(source[0], array[0]);
41-
Assert.AreEqual(source[1], array[1]);
42-
Assert.AreEqual(source[2], array[2]);
43-
}
41+
Assert.AreEqual(source[0], array[0]);
42+
Assert.AreEqual(source[1], array[1]);
43+
Assert.AreEqual(source[2], array[2]);
44+
}
4445

45-
[TestMethod, TestCategory("Unit")]
46-
public void LockingReadOnlyCollectionIsReadOnly() {
47-
List<int> source = [1, 2, 3];
46+
[TestMethod, TestCategory("Unit")]
47+
public void LockingReadOnlyCollectionIsReadOnly() {
48+
List<int> source = [1, 2, 3];
4849

49-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
50+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
5051

51-
Assert.IsTrue(tester.IsReadOnly);
52-
}
52+
Assert.IsTrue(tester.IsReadOnly);
53+
}
5354

54-
[TestMethod, TestCategory("Unit")]
55-
public void LockingReadOnlyCollectionIsEnumerable() {
56-
List<int> source = [1, 2, 3];
55+
[TestMethod, TestCategory("Unit")]
56+
public void LockingReadOnlyCollectionIsEnumerable() {
57+
List<int> source = [1, 2, 3];
5758

58-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
59+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
5960

60-
int total = tester.Sum();
61+
int total = tester.Sum();
6162

62-
Assert.AreEqual(6, total);
63-
}
63+
Assert.AreEqual(6, total);
64+
}
6465

65-
[TestMethod, TestCategory("Unit")]
66-
public void LockingReadOnlyCollectionIndexOf() {
67-
List<int> source = [1, 2, 3];
66+
[TestMethod, TestCategory("Unit")]
67+
public void LockingReadOnlyCollectionIndexOf() {
68+
List<int> source = [1, 2, 3];
6869

69-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
70+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
7071

71-
int index = tester.IndexOf(3);
72+
int index = tester.IndexOf(3);
7273

73-
Assert.AreEqual(2, index);
74-
}
74+
Assert.AreEqual(2, index);
75+
}
7576

76-
[TestMethod, TestCategory("Unit")]
77-
public void LockingReadOnlyCollectionIndexer() {
78-
List<int> source = [1, 2, 3];
77+
[TestMethod, TestCategory("Unit")]
78+
public void LockingReadOnlyCollectionIndexer() {
79+
List<int> source = [1, 2, 3];
7980

80-
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
81+
LockingReadOnlyCollection<int> tester = source.ToLockingReadOnlyCollection();
8182

82-
Assert.AreEqual(source[0], tester[0]);
83-
Assert.AreEqual(source[1], tester[1]);
84-
Assert.AreEqual(source[2], tester[2]);
85-
}
83+
Assert.AreEqual(source[0], tester[0]);
84+
Assert.AreEqual(source[1], tester[1]);
85+
Assert.AreEqual(source[2], tester[2]);
86+
}
8687

87-
}
88+
}

Str.Common.Tests/TaskExtensionTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Str.Common.Tests;
77

8+
89
[TestClass]
910
public class TaskExtensionTests {
1011

0 commit comments

Comments
 (0)