fluentassertions.analyzers
fluentassertions.analyzers copied to clipboard
DictionaryShouldContainsKey is triggered on custom ContainsKey
Description
When a class implements IDictionary
and a custom ContainsKey(TKey1, TKey2)
, the analyzer does not distinguish between IDictionary.ContainsKey(TKey)
and ContainsKey(TKey1, TKey2)
.
Related to #65
Complete minimal example reproducing the issue
public class MultiKeyDict<TKey1, TKey2, TValue>
: Dictionary<TKey1, Dictionary<TKey2, TValue>>
{
public bool ContainsKey(TKey1 key1, TKey2 key2) => false;
}
[TestMethod]
public void MyTestMethod()
{
var dict = new MultiKeyDict<int, int, string>();
dict.ContainsKey(0, 1).Should().BeTrue();
}
Expected behavior:
No analyzer should be triggered.
Actual behavior:
DictionaryShouldContainsKey
is suggested, but is not applicable as GenericDictionaryAssertions<TKey, TValue>
does not implement ContainKey(TKey1, TKey2)
.
Versions
- Which version of Fluent Assertions Analyzers are you using?
- 0.11.4
- Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.0.
- net472