Moling Collections

Moling Collections

Mole 2010, Mole 2012, and Mole 2013 are Visual Studio debugger visualizers that enable you to drill into and analyze any program which targets the .NET Framework 3.5 (Mole 2013 .NET Framework 4.0) or above (except Silverlight, Metro or Windows 8 Modern applications, and Windows Phone). It runs in Visual Studio while you are debugging. One of the ways that Mole can help make it easier to debug any application is by giving you immediate access to and control over data in collections.

Drilling into a Collection

The MoloScope allows you to drill into any .NET object, including collections of objects. The screenshot below shows how to drill into a collection of objects by clicking on the value of a property in the MoloScope.

After drilling into a collection the MoloScope displays the objects it contains.

Working with Collection Data

Once the MoloScope is displaying a collection of data, you can easily:

  • View individual objects in the collection
  • View all objects in the collection at once
  • Export the data to a CSV file that can be opened in Excel

Drilling into the first object in the collection, by clicking the link in the Value column, would allow you to see just that object.

You can also choose to view all objects in the collection by clicking the View button above the MoloScope list.

After clicking the View button another window opens that contains all of the data in the collection. If the collection happens to contain various types of objects, the Collection Viewer window will display separate lists for each type of object. This enables you to see all available properties on each type of object in an intuitive way.

TIP: To copy a property value from an object in the list, simply right-click on that value and select "Copy cell text to clipboard" from the context menu.

Notice in the image above that the “FullTimer” tab is selected, which means you are viewing only employees of type FullTimer. If you wanted to view the part-time employees, select the “PartTimer” tab. Note: each tab’s title is the type name of the objects in its list. In this scenario, the collection contains three types of objects; FullTimer, PartTimer, and TeamLeader.

This collection of data objects can also be exported to a comma-separated value file (CSV), which you can open in Excel or any other application that works with CSV files. If you click the Export button above the MoloScope, this collection of data could then be saved to disk and viewed in a spreadsheet.

Adjusting How Many Objects Mole Retrieves

By default Mole will display and export up to 1,000 items from a collection. This rule exists because Visual Studio 2010 will kill Mole if it takes too long to retrieve its data. If you often work with collections of data that have more than 1,000 objects, and you have a fast computer, you can adjust the maximum number of objects that Mole will retrieve from collections. This is available by going to the Tools | Options… menu and then adjust the “Max collection size” slider.

Mole makes working with collections easier.