For each method in file

ForEachMethodInFile is a Visual Studio macro that lets you do custom actions for each method defined in the current file. I’ve used it in the past to generate logging code to log the start and end of each method, to generate default error handling code etc..  And today someone over at CodeProject wanted to generate a breakpoint at the start of each method. The common thread here is the performing of some custom action for each method in the current file. I figured it would be useful for a lot of people if the “for each method in file” logic … Continue reading For each method in file

Yowza! My computer is seeing patterns!

Ever since I happened to stumble upon this book on Data Mining, I’ve been hooked. So much so that I’ve been brushing up on statistics and probability distributions just to follow along the book. I’m currently reading the chapter on classification using decision trees, and what appeals to me is the how the technique reduces huge sets of data (records) into simple models that can both describe the data and can predict the class of previously unseen records. If all that goes right above your head, here’s a simple example. P1 P2 Class (Result) True True True False False False … Continue reading Yowza! My computer is seeing patterns!

Add logs to the start and end of methods

 MethodLogger is a macro I wrote that adds log statements at the beginning and ending of all methods in the current document in Visual Studio. Unzip the file, load it in Visual Studio using Tools->Macros->Load Macro Project, open the appropriate C# file and then run the LogMethodStartAndEnd macro. It transforms class SomeClass{ public void SomeMethod() { MessageBox.Show(“Doodly doodly Doo”); }} to class SomeClass{ public void SomeMethod() { Console.WriteLine(“Start of SomeClass.SomeMethod()”); try { MessageBox.Show(“Doodly doodly Doo”); } finally { Console.WriteLine(“End of SomeClass.SomeMethod()”); } }} The code, written in VB .NET (which seems to be the only supported language for writing macros?) … Continue reading Add logs to the start and end of methods

New version of deadlock detector

A new version of deadlock detector is up at Deadlock Detector^. This version is a partial rewrite, with a modified version of the algorithm to detect the object being locked. It now does a virtual execution of the IL, following through all control paths to find the locked object. There are a few issues with the execution logic, sometimes resulting in stack overflows and infinite loops. Any comments/suggestions/bug reports welcome.