I've got some inherited code that has a tendency to pass objects around as interfaces (IFoo, for example) then, at arbitrary places in the code, spontaneously cast them to concrete implementations of those interfaces (say, MyConcreteFoo).
Here's a silly example:
public bool IsThisFooScaredOfMonkeys(IFoo foo)
{
if (foo is MyConcreteFoo)
{
return ((MyConcreteFoo)foo).BelievesMonkeysAreEvil;
}
return false;
}
What I'd like to do is write an NDepend CQL query to pick up these sorts of casts and give me a count per method, or per type, or anything really. Just something so I know where I can start focusing my efforts on getting rid of this particular brand of silliness, rather than sending my team spelunking through the code on a random hunt for casts...
Does anyone know if there's a way to do that? I'm guessing not (there can't be too many people out there who need that particular functionality) but I figured I'd ask here first... :-)
Of course, any other ideas on ways to make the cast-hunting go faster would be equally appreciated.