I have the following method in an external class
public static void DoStuffWithAnimals(IDictionary animals)
In my cal
IDictionary can't be covariant, because that would allow you to do something like:
IDictionary sheep = new Dictionary();
IDictionary animals = sheep;
animals.Add("another innocent sheep", new Wolf());
There is IReadOnlyDictionaryIEnumerable and KeyValuePair is not covariant.
To work around this, you could make your method generic with a constraint of the type parameter:
void DoStuffWithAnimals(IDictionary animals) where T : Animal