views:

156

answers:

1

I realize that the query this question is looking for won't be enough to find every little problem with IDisposable implementations, but every early warning counts, so I'll take what I can get.

I'd like to know if anyone has come up with a CQL query for NDepend that will list all classes that doesn't implement IDisposable, but has one or more fields that does. A class could end up on the resultlist of this query either through a bug (ie. someone forgot to check the field types for IDisposable implementations), or through code evolution (ie. a class used in a field somewhere gets IDisposable tacked on at a later date without all usages being updated).

The simple query to find all classes that doesn't implement IDisposable is:

SELECT TYPES WHERE !Implement "System.IDisposable"

However, this will of course not check if the class should implement IDisposable for the above rule.

Does anyone have such a query? I'm still getting to grips with CQL so this part eludes me.

+3  A: 

Lasse, what you would need to do this is to use the result of one CQL query as the input for another CQL query, some kind of query composition.

This is not possible yet at the time of writing (CQL v1.8, Dec2008) but this is a feature we are willing to implement during 2009 (I am part of the NDepend development team).

Patrick Smacchia - NDepend dev