Skip to content
This repository was archived by the owner on Apr 20, 2026. It is now read-only.

Commit e1e864e

Browse files
authored
Merge pull request #128 from bkoelman/csharpguidelines-55
Updates for CSharpGuidelines v5.5.0
2 parents a597425 + 6432e68 commit e1e864e

101 files changed

Lines changed: 1327 additions & 1003 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/Overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This analyzer reports when a member has the `new` modifier in its signature.
2020
This analyzer reports when a member has the word "And" in its name.
2121

2222
### [AV1130](https://github.com/dennisdoomen/CSharpGuidelines/blob/7a66f7468da6ce1477753a02e416e04bc9a44e45/_pages/1100_MemberDesignGuidelines.md#av1130): Return an `IEnumerable<T>` or `ICollection<T>` instead of a concrete collection class ![](/images/warn.png "severity: warning")
23-
This analyzer reports when a method return type is a `class` or `struct` that implements `IEnumerable` and is not an immutable collection.
23+
This analyzer reports when the return type of a public or internal method implements `IEnumerable` and is changeable (for example: `List<string>` or `ICollection<int>`). Instead, return `IEnumerable<T>`, `IReadOnlyCollection<T>`, `IReadOnlyList<T>`, `IReadOnlySet<T>`, `IReadOnlyDictionary<TKey, TValue>` or an immutable collection.
2424

2525
### [AV1135](https://github.com/dennisdoomen/CSharpGuidelines/blob/7a66f7468da6ce1477753a02e416e04bc9a44e45/_pages/1100_MemberDesignGuidelines.md#av1135): Properties, arguments and return values representing strings or collections should never be `null` ![](/images/warn.png "severity: warning")
2626
This analyzer reports when `null` is returned from a method, local function, lambda expression or property getter which has a return type of string, collection or task.

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/Specs/ClassDesign/AvoidStaticClassSpecs.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static class [|C|]
4040

4141
// Act and assert
4242
VerifyGuidelineDiagnostic(source,
43-
"Class 'C' should be non-static or its name should be suffixed with 'Extensions'.");
43+
"Class 'C' should be non-static or its name should be suffixed with 'Extensions'");
4444
}
4545

4646
[Fact]
@@ -61,7 +61,7 @@ static partial class C
6161

6262
// Act and assert
6363
VerifyGuidelineDiagnostic(source,
64-
"Class 'C' should be non-static or its name should be suffixed with 'Extensions'.");
64+
"Class 'C' should be non-static or its name should be suffixed with 'Extensions'");
6565
}
6666

6767
[Fact]
@@ -116,7 +116,7 @@ static class [|Nested|]
116116

117117
// Act and assert
118118
VerifyGuidelineDiagnostic(source,
119-
"Class 'Nested' should be non-static or its name should be suffixed with 'Extensions'.");
119+
"Class 'Nested' should be non-static or its name should be suffixed with 'Extensions'");
120120
}
121121

122122
[Fact]
@@ -182,7 +182,7 @@ static class SomeExtensions
182182

183183
// Act and assert
184184
VerifyGuidelineDiagnostic(source,
185-
"Extension method container class 'SomeExtensions' contains public member 'M', which is not an extension method.");
185+
"Extension method container class 'SomeExtensions' contains public member 'M', which is not an extension method");
186186
}
187187

188188
[Fact]
@@ -202,7 +202,7 @@ static class SomeExtensions
202202

203203
// Act and assert
204204
VerifyGuidelineDiagnostic(source,
205-
"Extension method container class 'SomeExtensions' contains internal member 'M', which is not an extension method.");
205+
"Extension method container class 'SomeExtensions' contains internal member 'M', which is not an extension method");
206206
}
207207

208208
[Fact]
@@ -220,7 +220,7 @@ static class SomeExtensions
220220

221221
// Act and assert
222222
VerifyGuidelineDiagnostic(source,
223-
"Extension method container class 'SomeExtensions' contains public member 'C', which is not an extension method.");
223+
"Extension method container class 'SomeExtensions' contains public member 'C', which is not an extension method");
224224
}
225225

226226
[Fact]
@@ -238,7 +238,7 @@ static class SomeExtensions
238238

239239
// Act and assert
240240
VerifyGuidelineDiagnostic(source,
241-
"Extension method container class 'SomeExtensions' contains public member 'F', which is not an extension method.");
241+
"Extension method container class 'SomeExtensions' contains public member 'F', which is not an extension method");
242242
}
243243

244244
[Fact]
@@ -259,7 +259,7 @@ public static int [|P|]
259259

260260
// Act and assert
261261
VerifyGuidelineDiagnostic(source,
262-
"Extension method container class 'SomeExtensions' contains public member 'P', which is not an extension method.");
262+
"Extension method container class 'SomeExtensions' contains public member 'P', which is not an extension method");
263263
}
264264

265265
[Fact]
@@ -277,7 +277,7 @@ static class SomeExtensions
277277

278278
// Act and assert
279279
VerifyGuidelineDiagnostic(source,
280-
"Extension method container class 'SomeExtensions' contains public member 'E', which is not an extension method.");
280+
"Extension method container class 'SomeExtensions' contains public member 'E', which is not an extension method");
281281
}
282282

283283
[Fact]

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/Specs/ClassDesign/DoNotHideInheritedMemberSpecs.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class C : B
2929

3030
// Act and assert
3131
VerifyGuidelineDiagnostic(source,
32-
"'C.F' hides inherited member.");
32+
"'C.F' hides inherited member");
3333
}
3434

3535
[Fact]
@@ -114,7 +114,7 @@ class C : B
114114

115115
// Act and assert
116116
VerifyGuidelineDiagnostic(source,
117-
"'C.P' hides inherited member.");
117+
"'C.P' hides inherited member");
118118
}
119119

120120
[Fact]
@@ -167,7 +167,7 @@ class C : B
167167

168168
// Act and assert
169169
VerifyGuidelineDiagnostic(source,
170-
"'C.M(int)' hides inherited member.");
170+
"'C.M(int)' hides inherited member");
171171
}
172172

173173
[Fact]
@@ -252,7 +252,7 @@ class C : B
252252

253253
// Act and assert
254254
VerifyGuidelineDiagnostic(source,
255-
"'C.Changed' hides inherited member.");
255+
"'C.Changed' hides inherited member");
256256
}
257257

258258
[Fact]
@@ -298,7 +298,7 @@ class C : B
298298

299299
// Act and assert
300300
VerifyGuidelineDiagnostic(source,
301-
"'C.Changed' hides inherited member.");
301+
"'C.Changed' hides inherited member");
302302
}
303303

304304
[Fact]
@@ -325,7 +325,7 @@ class C : B
325325

326326
// Act and assert
327327
VerifyGuidelineDiagnostic(source,
328-
"'C.S' hides inherited member.");
328+
"'C.S' hides inherited member");
329329
}
330330

331331
[Fact]
@@ -352,7 +352,7 @@ class C : B
352352

353353
// Act and assert
354354
VerifyGuidelineDiagnostic(source,
355-
"'C.S' hides inherited member.");
355+
"'C.S' hides inherited member");
356356
}
357357

358358
[Fact]
@@ -378,7 +378,7 @@ class C : B
378378

379379
// Act and assert
380380
VerifyGuidelineDiagnostic(source,
381-
"'C.P' hides inherited member.");
381+
"'C.P' hides inherited member");
382382
}
383383

384384
[Fact]
@@ -404,7 +404,7 @@ class C : B
404404

405405
// Act and assert
406406
VerifyGuidelineDiagnostic(source,
407-
"'C.P' hides inherited member.");
407+
"'C.P' hides inherited member");
408408
}
409409

410410
[Fact]
@@ -430,7 +430,7 @@ class C : B
430430

431431
// Act and assert
432432
VerifyGuidelineDiagnostic(source,
433-
"'C.F' hides inherited member.");
433+
"'C.F' hides inherited member");
434434
}
435435

436436
[Fact]
@@ -456,7 +456,7 @@ class C : B
456456

457457
// Act and assert
458458
VerifyGuidelineDiagnostic(source,
459-
"'C.F' hides inherited member.");
459+
"'C.F' hides inherited member");
460460
}
461461

462462
[Fact]
@@ -481,7 +481,7 @@ class C : B
481481

482482
// Act and assert
483483
VerifyGuidelineDiagnostic(source,
484-
"'C.Changed' hides inherited member.");
484+
"'C.Changed' hides inherited member");
485485
}
486486

487487
[Fact]
@@ -506,7 +506,7 @@ class C : B
506506

507507
// Act and assert
508508
VerifyGuidelineDiagnostic(source,
509-
"'C.Changed' hides inherited member.");
509+
"'C.Changed' hides inherited member");
510510
}
511511

512512
protected override DiagnosticAnalyzer CreateAnalyzer()

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/Specs/ClassDesign/TypeShouldHaveASinglePurposeSpecs.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class [|CustomerAndOrder|]
2323

2424
// Act and assert
2525
VerifyGuidelineDiagnostic(source,
26-
"Type 'CustomerAndOrder' contains the word 'and', which suggests it has multiple purposes.");
26+
"Type 'CustomerAndOrder' contains the word 'and', which suggests it has multiple purposes");
2727
}
2828

2929
[Fact]
@@ -40,7 +40,7 @@ struct [|customer_and_order|]
4040

4141
// Act and assert
4242
VerifyGuidelineDiagnostic(source,
43-
"Type 'customer_and_order' contains the word 'and', which suggests it has multiple purposes.");
43+
"Type 'customer_and_order' contains the word 'and', which suggests it has multiple purposes");
4444
}
4545

4646
[Fact]
@@ -57,7 +57,7 @@ interface [|CUSTOMER_AND_ORDER|]
5757

5858
// Act and assert
5959
VerifyGuidelineDiagnostic(source,
60-
"Type 'CUSTOMER_AND_ORDER' contains the word 'and', which suggests it has multiple purposes.");
60+
"Type 'CUSTOMER_AND_ORDER' contains the word 'and', which suggests it has multiple purposes");
6161
}
6262

6363
[Fact]
@@ -74,7 +74,7 @@ enum [|Match1And2Again3|]
7474

7575
// Act and assert
7676
VerifyGuidelineDiagnostic(source,
77-
"Type 'Match1And2Again3' contains the word 'and', which suggests it has multiple purposes.");
77+
"Type 'Match1And2Again3' contains the word 'and', which suggests it has multiple purposes");
7878
}
7979

8080
[Fact]
@@ -91,7 +91,7 @@ enum [|MATCH1AND2AGAIN3|]
9191

9292
// Act and assert
9393
VerifyGuidelineDiagnostic(source,
94-
"Type 'MATCH1AND2AGAIN3' contains the word 'and', which suggests it has multiple purposes.");
94+
"Type 'MATCH1AND2AGAIN3' contains the word 'and', which suggests it has multiple purposes");
9595
}
9696

9797
[Fact]
@@ -106,7 +106,7 @@ internal void When_delegate_name_contains_the_word_And_it_must_be_reported()
106106

107107
// Act and assert
108108
VerifyGuidelineDiagnostic(source,
109-
"Type 'CustomerAndOrder' contains the word 'and', which suggests it has multiple purposes.");
109+
"Type 'CustomerAndOrder' contains the word 'and', which suggests it has multiple purposes");
110110
}
111111

112112
[Fact]

src/CSharpGuidelinesAnalyzer/CSharpGuidelinesAnalyzer.Test/Specs/Documentation/AvoidInlineCommentSpecs.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void M()
2525

2626
// Act and assert
2727
VerifyGuidelineDiagnostic(source,
28-
"Code block should not contain inline comment.");
28+
"Code block should not contain inline comment");
2929
}
3030

3131
[Fact]
@@ -45,7 +45,7 @@ of text*/|]
4545

4646
// Act and assert
4747
VerifyGuidelineDiagnostic(source,
48-
"Code block should not contain inline comment.");
48+
"Code block should not contain inline comment");
4949
}
5050

5151
[Fact]
@@ -138,7 +138,7 @@ internal void When_field_initializer_contains_single_line_comment_it_must_be_rep
138138

139139
// Act and assert
140140
VerifyGuidelineDiagnostic(source,
141-
"Code block should not contain inline comment.");
141+
"Code block should not contain inline comment");
142142
}
143143

144144
[Fact]
@@ -163,8 +163,8 @@ public string P
163163

164164
// Act and assert
165165
VerifyGuidelineDiagnostic(source,
166-
"Code block should not contain inline comment.",
167-
"Code block should not contain inline comment.");
166+
"Code block should not contain inline comment",
167+
"Code block should not contain inline comment");
168168
}
169169

170170
[Fact]

0 commit comments

Comments
 (0)