BugAid–C# Visual Studio Debugging made easier

On September 8th 2012 I gave a presentation on BugAid, an exciting extension/tool for Visual Studio.  BugAid is a C# debugging helper for Visual Studio.  I personally have been using it for about a year on Visual Studio 2010 and 2012 and when I am not working in C# it is the one add-on that is miss. 

In the demo the scenario was this.  We had thirty customers that won a gift.  All of them but one (a customer named Michael) reported that they received their gifts.  Here is an example of the code that calculates the gift.

private static void BoostCustomerRelation(IEnumerable<Customer> customers)
    IEnumerable<Customer> validatedCustomers = WebService.ValidateCustomers(customers);

    foreach (var customer in validatedCustomers)
        if (((IsLotteryWinner(customer) || IsVIP(customer)) && IsBudgetAvailable(CalculateGiftCost(customer))))


Below is a screenshot of the customer collection.  Normally we would need to look though each item in the collection individually (either by manually viewing or breakpoint conditions) to find what we are looking for.


With BugAid enabled we can expand the first item in the collection, and star any number of items.  In this example I placed a star on FirstName and Surname.  Now the same collection listed above looks like this.


Now you can easily scroll through your collection till you find the name of the user you need.  What if your collection was a million users?  Visually viewing might take time.  If you look closer to the image above at the bottom there is now a search feature.  In our scenario the custom that is reporting the problem is named Michael. 

If we search for him our collection will display this.


If you notice search comes back with a few things of value.  We now know that Michael is the 20th uses in this collection.  The search feature is also not limited to just the fields that are stared, it is returning that Michael was found in FirstName, EmailAddress, and in a FullName field. 

With search we now know that Michael is number twenty in our collection.  Do we cycle though the foreach loop twenty times.  This might be fine, but think about the possibility of a million users.  BugAid has a foreach enhancement (Note:requires BugAid to be running in full mode).  First thing you will see if you break inside the foreach loop is an iteration counter that looks like this.


From this we can see where we are in the collection.  If you click on it, the foreach visualization will be displayed.  The follow highlight tells us which item is currently being viewed.


If you scroll down to Michael (item 20) and right click on it, you will get the option ‘Run to item’.  If you select that, the foreach loop will advance to Michael.  You will notice the iteration count and the yellow highlight both update.


Now upon clicking step over for Michael the If statement returns false and never sends a gift.   Next to the if statement a BugAid symbol appears.


Clicking on the bug, we get a verification that indeed the if statement returned false.


Clicking on the down arrow we get more detail on which side of the and condition returned false.  One note, if you look closer to the left side. You will notice that IsVIP(customer) is striked out.  This is because for this side, IsLotteryWinner(customer) returned true for the or condition so IsVIP did not need to be evaluated.

We also learn that the false statement happened on the right side of the condition. 


Clicking the down arrow one more time we can see that IsLotteryWinner was a Boolean check that returned true and that CalculateGiftCost returned an insanely high number.  I don’t know about most companies but I know a gift of 2+billion dollars is probably not in the budget.


So in this demo we have verified there is definitely a problem after we validate which customers should be eligible to receive a gift. 

In our code we can mouse over the validatedCustomers collection, and right click we can  compare this collection with the the customers collection that was passed in.


This gives us the ability to see a side by side compare of the collections. 


However it take us hours to look through each of these items to do a visual compare to find the differences, OR if you look at the bottom of this image, there is a check box to have BugAid show you only the line items that are different between these two collections. 

Clicking it we can see that in the collection passed in Michaels occupation is set to Mental health counselor; however after validation this field is corrupted.  This is why calculating the gift returns a large number, because that calculation is based off the customers occupation. 


For more information, visit the BugAid site and try the 60 day trial.

This entry was posted in Debug, Visual Studio and tagged , . Bookmark the permalink.

3 Responses to BugAid–C# Visual Studio Debugging made easier

  1. Pingback: BugAid is now OzCode and improved | Research ~ A ~ holic

  2. What’s up, I log on to your new stuff like every week.
    Your humoristic style is witty, keep doing what you’re doing!

  3. A preliminary deposit is often required for the sake of the unformulated contract that is in between the brokers and the

Comments are closed.