Finding All Form Event Handling Methods Using NDepend

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

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

      

I've looked at some options, but I can't find anything that does what I need.

I've just started using NDepend, so I'm not used to it yet, but I know what the hell I've been living without it all this time.

0


source to share


2 answers


I'm Patrick from the NDepend team, and I confirm that using the "Namelike + regular expression" clause on the "method name + signature" is the best way to achieve what you want with CQL.



+4


source


I have something that works, but in fact it is not 100% correct because all the form-processed handlers have underscores in it, I used the underscore as a filter, I also filter where the name has "EventArgs" in that. The request looks like this:

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

      



This query pretty much returns all the event handling methods, but I would still like to find a better way.

0


source







All Articles