Skip to content

Commit

Permalink
feat: enable collection analyzers for any collection including dictio…
Browse files Browse the repository at this point in the history
…naries (#208)

* enable collection analyzers for any collection including dictionaries

* #77 is no longer correct
  • Loading branch information
Meir017 authored Aug 14, 2023
1 parent ff0ae92 commit 5a81bb4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 28 deletions.
25 changes: 0 additions & 25 deletions src/FluentAssertions.Analyzers.Tests/Tips/SanityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,31 +239,6 @@ public static void Main()
DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}

[TestMethod]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/77")]
public void DictionaryShouldHaveCount1_ShouldNotReport()
{
const string source = @"
using System.Linq;
using System.Collections.Generic;
using FluentAssertions;
using FluentAssertions.Extensions;
namespace TestNamespace
{
public class Program
{
public static void Main()
{
var dict = new Dictionary<string, object>();
dict.Should().HaveCount(1);
}
}
}";

DiagnosticVerifier.VerifyCSharpDiagnosticUsingAllAnalyzers(source);
}

[TestMethod]
[Implemented(Reason = "https://github.com/fluentassertions/fluentassertions.analyzers/issues/172")]
public void AssertAreEqualDoesNotCompile()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ public abstract class CollectionAnalyzer : FluentAssertionsAnalyzer
{
protected override bool ShouldAnalyzeVariableType(INamedTypeSymbol type, SemanticModel semanticModel)
{
var iDictionaryType = semanticModel.GetGenericIDictionaryType();
return type.SpecialType != SpecialType.System_String
&& type.IsTypeOrConstructedFromTypeOrImplementsType(SpecialType.System_Collections_Generic_IEnumerable_T)
&& !type.IsTypeOrConstructedFromTypeOrImplementsType(iDictionaryType);
&& type.IsTypeOrConstructedFromTypeOrImplementsType(SpecialType.System_Collections_Generic_IEnumerable_T);
}
}
}

0 comments on commit 5a81bb4

Please sign in to comment.