tags:

views:

55

answers:

1

The class browser of NDepend doesn't seem to have an option for revealing inherited methods.

We have a scenario where we have thousands of singly-rooted Model objects that descend from RootModel, for instance. Only RootModel defines Save(). How does one form a query for finding all instances where SampleModel (:RootModel) invokes Save()?

SELECT METHODS WHERE IsUsing "SampleModel.Save()" ORDER BY DepthOfIsUsing

...is rejected: Not a valid assembly, namespace, typ, method or field name.

This seems to be the best approximation but is not exact:

SELECT METHODS WHERE IsUsing "SampleModel" AND IsUsing "RootModel.Save()" ORDER BY DepthOfIsUsing

This seems like a pretty heavy limitation, no? What's the workaround?

+1  A: 

From the static point of view of NDepend the class SampleModel doesn't declare a Save() method. This is why the first query doesn't compile.
The second query is indeed the good thing to do in your case.

Btw, IsUsing return methods that directly and indirectly use Save(); You might prefer relying on the IsDirectlyUsing CQL clause.

Patrick Smacchia - NDepend dev
Hi Patrick; are you suggesting that static analysis alone can't analyze inherited methods or that it's simply not implemented by NDepend? Surely it's the latter: various tools like the reflector enumerate inherited members in class browsers through static analysis. The second query is an estimate at best; it's not the precise answer one would hope for. I see that you guys are quite open to community feedback on NDepend and I’m hopeful that this one makes the list; in my estimation it’s a very common scenario in OOP.
Nariman