views:

74

answers:

1

I'm in the middle of performing a large refactoring which will involve renaming a lot of events. This will leave our code with a lot of code like this:

thing.NewEventName += thing_OldEventName;

How do I get a list of event handlers with nonstandard names in my code? Should I be thinking about a regex search, or should I be looking at writing something using CodeDom?

+4  A: 

You could take a look at Cecil ( http://www.mono-project.com/Cecil ), a library enabling you to look in your IL code, or fire up NDepend ( http://www.ndepend.com ) (which itself uses Cecil) that offers amazing query capabilities over your code base.

Yann Schwartz
+1 NDepend will tell you this in approximately 5 seconds.
Tim Robinson
Well, I just checked out, it's a bit more complicated like that. You first have to get all the methods that are event adders, then find the methods that call these, then check for the parameter names. It's feasible but it might involve a little bit of automatic CQL (the NDepend query language) queries generation. I wish Patrick Smacchia would finish his linq provider...
Yann Schwartz