views:

98

answers:

2

Hi all,

I was wondering if someone would be able to help me write a CQL query for NDepend that will show me all the methods in my form class that handle the form events. So I would like to be able to find all the methods that look like this:

Private Sub AddFolderButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddFolderButton.Click

I have had a look through some of the options but I can't really find anything that does what I need.

I have only just started using NDepend, so I haven't really got used to it yet, but I do know one thing how the hell did I live without it all this time.

A: 

I have sort of got something that works but its not really 100% correct, because all the form generated event handlers have an underscores in there name, I used the underscore as a filter, I also filter where the name has "EventArgs" in it. The query looks like this:

SELECT METHODS WHERE NameLike "_" OR NameLike "EventArgs" AND !IsSpecialName AND IsPrivate

That query pretty much returns all the methods that handle events but I would still like to find a more correct way.

Nathan W
+4  A: 

Hi Nathan,

I am Patrick from the NDepend team and I confirm, so far using a condition 'Namelike + regular expression' on the 'method name + signature' is the best way to achieve what you want with CQL.

Patrick Smacchia - NDepend dev
Cheers! Great tool by the way, I don't know what I would do without it.
Nathan W