Skip to content

Commit 5a81bb4

Browse files
authored
feat: enable collection analyzers for any collection including dictionaries (#208)
* enable collection analyzers for any collection including dictionaries * #77 is no longer correct
1 parent ff0ae92 commit 5a81bb4

File tree

2 files changed

+1
-28
lines changed

2 files changed

+1
-28
lines changed

src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -239,31 +239,6 @@ public static void Main()
239239
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
240240
}
241241

242-
[TestMethod]
243-
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/77")]
244-
public void DictionaryShouldHaveCount1_ShouldNotReport()
245-
{
246-
const string source = @"
247-
using System.Linq;
248-
using System.Collections.Generic;
249-
using FluentAssertions;
250-
using FluentAssertions.Extensions;
251-
252-
namespace TestNamespace
253-
{
254-
public class Program
255-
{
256-
public static void Main()
257-
{
258-
var dict = new Dictionary<string, object>();
259-
dict.Should().HaveCount(1);
260-
}
261-
}
262-
}";
263-
264-
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
265-
}
266-
267242
[TestMethod]
268243
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/172")]
269244
public void AssertAreEqualDoesNotCompile()

src/FluentAssertions.Analyzers/Tips/Collections/CollectionAnalyzer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ public abstract class CollectionAnalyzer : FluentAssertionsAnalyzer
77
{
88
protected override bool ShouldAnalyzeVariableType(INamedTypeSymbol type, SemanticModel semanticModel)
99
{
10-
var iDictionaryType = semanticModel.GetGenericIDictionaryType();
1110
return type.SpecialType != SpecialType.System_String
12-
&& type.IsTypeOrConstructedFromTypeOrImplementsType(SpecialType.System_Collections_Generic_IEnumerable_T)
13-
&& !type.IsTypeOrConstructedFromTypeOrImplementsType(iDictionaryType);
11+
&& type.IsTypeOrConstructedFromTypeOrImplementsType(SpecialType.System_Collections_Generic_IEnumerable_T);
1412
}
1513
}
1614
}

0 commit comments

Comments
 (0)