Closed
Description
Description
I have a custom dictionary that has a method with the signature: public bool ContainsKey(TKey1 key1, TKey2 key2)
.
This incorrectly triggers DictionaryShouldContainsKey
.
Complete minimal example reproducing the issue
class MyDict<TKey, TValue>
{
public bool ContainsKey(TKey key) => false;
}
var dict = new MyDict<int, string>();
dict.ContainsKey(0).Should().BeTrue();
is transformed into
dict.Should().ContainKey(0);
As dict
is not a Dictionary
, Should()
returns an ObjectAssertions
which does not have the ContainKey()
assertion.
class MyDict2<TKey1, TKey2, TValue> : Dictionary<TKey1, TValue>
{
public bool ContainsKey(TKey1 key1, TKey2 key2) => false;
}
var dict2 = new MyDict2<int, int, string>();
dict2.ContainsKey(0, 0).Should().BeTrue();
is
var dict2 = new MyDict2<int, int, string>();
dict2.Should().ContainKey(0, 0);
but there is no such ContainKey(0, 0)
on GenericDictionaryAssertions
Expected behavior:
The analyzer should not be triggered.
Actual behavior:
The analyzer was triggered
Versions
Fluent Assertions Analyzers 0.11.2
.NET framework 4.6.1