|
|||||||||||||||||||||
|
|||||||||||||||||||||
|
Announcements
Services
Chapters
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
Visual Studio 2005
The video links require Microsoft Silverlight 1.0. If you do not have it, you will be prompted to install it when you click one of the links. After the short installation is completed, close the browser window that you did the install in and re-click the video you want to watch. You can also download it here. Windows XP or Vista required. FYI: Each link has a ToolTip containing information about the video. Silverlight Video Player
When you click on one of the above links your browser will open a new window and display the video player. You can resize your browser window and the video player will resize with the browser. You can also click on the Full Screen button on the video player controller. Additionally, single clicking the video will pause it. Double clicking the video is another way to switch to Full Screen mode.
Create Your Own Screen Capture VideosWant to learn how to create you own screen capture videos? Then read my Code Project article, Creating, Encoding and Delivering Silverlight Streaming Screen Capture Videos. Very detailed and download includes the above Silverlight video player and necessary encoding preset profile. The article also has two videos that cover the process. Mole v4.2 - Visualizer With Property Editing
Table Of Contents
Mole v4.2 Update New Features!
IntroductionMole was authored by Karl Shifflett, Josh Smith and Andrew Smith who make up Team Mole. The core development process took the team several weeks. Most of the additional enhancements were implemented by Andrew and Karl, with a lot of testing and feedback provided by Josh. You can visit Team Mole's Home Page here. This article was written by Karl. Mole has been tested on WPF, WCF, WF, WinForms and ASP.NET projects on Vista, XP Pro, x32, x64, VS2005 and VS2008, C# and VB.NET. We sincerely hope all .NET developers like and use Mole. Currently Mole does not support Silverlight but we will consider writing a visualizer, or similar tool, shortly after Silverlight 2.0 is released to the public. This article makes no assumptions about your prior exposure to the Mole project, or visualizers in general. What is Mole?Mole is a Visual Studio visualizer. Visualizers have been part of Visual Studio since version 2005. During debugging sessions, visualizers allow developers to view objects and data using a customized interface. Visual Studio ships with several simple but useful visualizers. Many developers have posted visualizers for .NET classes. Mole was designed to not only allow the developer to view objects or data, but to also allow the developer to drill into properties of those objects and then edit them. Mole allows unlimited drilling into objects and sub-objects. When Mole finds an Depending on the type of object you are visualizing you can view properties, fields, Mole v4 allows editing of properties. Please see the Editing section below for full details. Quick HistoryWhen a great friend and co-author Josh Smith wrote Woodstock for WPF on 13 Nov 2007, I got pretty excited about how Visual Studio visualizers that target WPF can really assist developers. I started making a list of features I wanted and began working on Mole. Mole was my first visualizer and first real WinForms program I've created with .NET 2.0. I spend most of my time with WPF, WCF, ASP.NET, SQL Server and Windows Services. So starting from scratch would prove to be challenging at times. Mole grew alongside Woodstock as it was being developed and refined. Josh and I worked hard to develop fast performing visualizers. We both tried some crazy things during this process of refinement, some of these I wouldn't post on a billboard or even admit to a priest during confession. To give you a comparison of what we were up against from a data loading perspective, consider the Text Visualizer which ships with Visual Studio. It allows you to view long strings in a multiline Mole displays a tree of the UI's elements and over a hundred associated properties in a What you'll see in this article is a highly refined visualizer which runs lightning fast. When running Mole in stress tests with absurdly large WPF visual trees (over 10,000 elements) it was able to open in less than a second. Bearing in mind that most sane developers would never create visual trees, WinForms or ASP.NET pages with element counts of that size, it is safe to say that Mole is fast enough to be usable by the most impatient developers out there. The largest visual tree loaded in Mole that I know about is 125,000 items! Josh was just stress testing Mole. On 26 November 2007 Mole v1, a Visualizer for WPF, was released. After Mole v1 was published, Josh, Andrew and I teamed up and have continued making significant upgrades to Mole v1. Due to the tremendous response from the WPF community, we radically expanded Mole's capabilities. On 6 Dec 2007, we released Mole v2. On 11 Dec 2007, we made further enhancements and released Mole v2.2 Black Ops. However, these tools only targeted WPF developers. Karl just couldn't put Mole down until extending Mole to all Visual Studio developers. So on 14 Dec 2007, we released Mole v3 that allowed all Visual Studio project types to be inspected by Mole. After Mole v3, Andrew really wanted to add editing capabilities to Mole. So Andrew and I jumped off that cliff to bring property Editing to Mole. This was not as easy task. Mole v4 adds editing of properties to Mole's already awesome feature set. Please see the Editing section for a full explanation of this new and powerful feature. This project has been a wild adventure to say the least. In just over a month, we have gone from never using a visualizer to authoring this product. For those that are interested, our development team employs a very specialized formal development methodology that is described towards the end of this article. When Josh and I started on our beginner visualizers a month ago, we never envisioned where Mole would take us. We have been working almost non-stop since we started. All three of us work regular jobs and work on Mole when we can. One of the side effects of just coding our brains out like this, almost without a rudder, is that Mole has a few areas that could use some refactoring. We are aware of this. We are considering a new product next year that can use this one as a prototype and one that will be designed before we start coding. This was a ready-fire-aim operation. We had a lot of fun with Mole! We are three regular guys, two C#, one VB.NET. Yes we are all bilingual, but have our preference of expression. We live in three different states and two of us have never met or spoken on the phone! Additionally, right in the middle of this Josh had to move and got a new job! Meanwhile, Karl would fire off new features like the Fourth of July. Andrew has been like a sniper, who assassinates the really nasty bugs and then disappears into the thickets until needed again. Installation RequirementsYou must install the .NET 3.0 Framework on your computer before installing Mole. Standalone InstallationIf you are developing on Vista and are running with Elevated Security enabled, you must install Mole in the following directory:
All others download and unzip the above package. Copy the file in the Release package to either:
ASP.NET Developers Please Read ThisWhen using Mole with ASP.NET If you do not do this, you will get an exception when attempting to load the visualizer in a debugging session. You would get this exception for any visualizer and not just Mole. This is because the ASPNET account has very few permissions on your computer. Adding these permissions prevents this exception. Source Code InstallationWe have provided source and test bench programs for both VS2005 and VS2008. The only difference between the two versions of the visualizer is the reference to Microsoft.VisualStudio.DebuggerVisualizers.DLL. For VS2005 the file version is 8.0.0.0 and for VS2008 the file version is 9.0.0.0. Copy the projects to your Projects directory for either VS 2005 or VS 2008. Don't forget, after compiling, you must copy the binary to the appropriate directory. The source code has two solutions. One solution has the visualizer project and also WPF, WinForm and ASP.NET test-bench programs that Josh and I wrote. The other solution has the WCF test bench program. I used a Chapter One sample from Michele Leroux Bustamante's book I've read, "Learning WCF". I strongly recommend "Learning WCF" to anyone interested in checking out WCF. ASP.NET Developers Please Read ThisWhen using Mole with ASP.NET If you do not do this, you will get an exception when attempting to load the visualizer in a debugging session. You would get this exception for any visualizer and not just Mole. This is because the ASPNET account has very few permissions on your computer. Adding these permissions prevents this exception. Mole's Feature Set
Mole has VS2005 and VS2008 builds and Mole has been tested on x32 and x64, Vista and XP systems. Lightning Fast PerformanceWe were fanatically obsessed with improving the speed of Mole; from how long it takes to initially load the Window, to how long it takes for an element’s properties to appear in the grid. This was a very high priority because most developers simply will not use a debugging tool which slows them down. So it had to be lightning fast. Period. To speed things up we did many things, such as:
Mole Visual Studio Visualizer and XBAPsOne big advantage Mole has over some other tools, is that you can use it to debug XBAP applications. Here is what you need to do to enable that:
Thanks to CodeProject member "ivolved" for this tip! Using VisualizersVisualizers are very easy to start. When debugging and at a breakpoint, hover your mouse over the object you want to visualize. If a visualizer is installed on your system which can visualize that type of object, the little magnifying glass will appear in the datatip. You can also start a visualizer from the Watch Window. You can click the magnifying glass to open the default visualizer for that object type. Or you can click the down arrow and select a visualizer to use. The check mark indicates the last visualizer used for the selected object type.
Using the data tip.
Using the Autos Watch Window. Notice the same magnifying glass in the Value column.
Mole's UI
When Mole opens it looks like the above image. On load, Mole configures and positions itself the same way you closed it during the previous session. Just about everything in a Mole session is persisted and restored without using the registry. Mole's UI can change depending on which object you have selected in the Visual Studio debugger. For example, a WinForms application does not have a visual tree, logical tree, or XAML. So these features are turned off. The same logic applies to ASP.NET, DataSets, DataTables, and class objects visualized in Mole. Additionally, the "Show Attached Properties" CheckBox, "Value Source" column, and "Is DP" column will only be available in applications that support them. Mole's Gardens
The The Element Type - Element Name (Count Of Descendants) Some objects were not assigned names in the program so they do not display here and some nodes do not have any child nodes associated with them. Elements are displayed in one of four colors. White is an unselected element. Light Gray is the selected element when the The dark gray 4 pixel line separating the two Select Initial button will select the object that you initially selected in Visual Studio. Expand All button will expand all Collapse All button will collapse all Expand Down button will expand all Collapse Down button will collapse all Element Properties - The Moloscope
Mole's Moloscope employs Max-O-Drilling technology, allowing the visualizer to drill back into the managed heap of another process to extract properties and data structures associated with the element being browsed from either the UI elements tree or logical tree. It is interesting to note that visualizers execute in a separate process from the data they are visualizing. All data must be piped through remoting, which is mostly handled by Visual Studio. The Max-O-Drilling technology we came up with is responsible for locating and maintaining references to objects on the managed heap that are being drilled into by the user. The label below the Element Properties TabPage heading is formatted as follows: [Drilling into] [Object Type] [Object Name] If you are drilling, the "Drilling into" text will be displayed. Some nodes were not assigned names in the program being debugged, so it won't display here. Properties GridThe Element Properties grid displays each of the selected item's properties. Columns with underlined header text can be sorted by clicking on the column header. Like many features in Mole, the selected column sort is persisted between Mole debugging sessions. The Favorites column (Fav) indicates if this property is one of your favorites for the selected type. You may select or deselect favorites by clicking the leftmost The property names are hyperlinks. When clicked, they open Google.com using your default browser and set the query string to search for the property name and selected item type. The property values are hyperlinks if the value can be drilled into. If the property can be edited, the pencil icon will be displayed. Please see the Editing section below for full details. Value Source identifies the source for the property value. Only WPF dependency properties have a value source. If you are not familiar with the concept of value sources, please read up on the topic at MSDN BaseValueSource Enumeration. The Category Name column is the name of the category assigned to it on the property declaration with the The rightmost column, Is DP, identifies whether this property is a dependency property or not. This column is removed when debugging applications that do not have dependency properties, like WinForms and ASP.NET. The below images will walk you through the drilling process:
I have used the Options tab to hide several columns. The developer has selected the node in the Notice that the Value column for some of the items is a hyperlink. This is how you can tell when you can drill into an object. Just click on these hyperlinks and you will conduct a drilling operation. When drilling into a property that is To truly appreciate what is going on here is a mind expanding experience. The visualizer UI does not have any references to any data in the managed heap in the other process. Also after drilling down, the UI element tree or logical tree we are viewing has no knowledge of what is being drilled into. The data I'm referring to is also located in another processes memory space and not Mole's! Max-O-Drilling technology enables this to happen. It took the better part of a day for me to architect and code this feature. Most of this feature resides in two places. The After my first pass, the feature was operating at 98%. Not good. Josh banged on the Moloscope with a 50lbs hammer and found a few cracks. We were not happy with some false readings that when the user drilled into them, the data was not there. You have to remember that drilling into objects is a two phase process. The first phase is when a list of properties are being returned back to Mole’s UI from the data source. It’s during this pass, that we must determine if a property can be drilled into, without actually drilling into it. That would simply take too long and slow Mole down. We all spent a good bit of time trying to find a solution. Bottom line, Andrew figured out the best method and that is the method Mole uses. You can view Andrew’s solution by searching for the There is a really funny story of how this drilling business all got started and is representative of how Mole was developed. One day Josh and I will have to post it somewhere.
This image is from the WPF Test Bench program Josh wrote for Mole. This is an application and not Mole. Displayed is a collection of the
This image shows how Mole drilled into the I really wish the Visual Studio debugger could display data inside collections with just one click without having to type so much in the debugger to view collection data. Maybe Visual Studio 2010, please?
This image shows the collection data in multiple data tables. Since the collection contains data that is of different
This image shows what the screen will look like after collapsing the Collection Data region. The standard WinForms Mole Can Help You Learn Or Teach .NETMole really shines in the next two images! .NET instructors can use this tool in the classroom to show your students how everything fits together in .NET.
Here the developer has drilled 4 layers deep to a control that exposes
In the image above, the developer has drilled three layers deep. You can see a I've played around with this a lot and it's so cool to be able to drill around the .NET Framework classes, and your own classes, too! Mole Black Ops
In the above image, an ASP.NET A BIG tip for all the ASP.NET developers. You can use Mole to discover the funky names of your child controls that ASP.NET assigns them. Just debug your ASP.NET page in Mole and look at the Fields (Black Ops) Section
Below the Search TextBox, there is a new "Show Fields" Black Ops Data
Some would ask, why show private or protected members? Allow me to list several reasons. (be aware that you can easily turn this feature off by un-checking the above Show Fields In the above image, I have selected a The real reason I wanted this feature was to be able to view private and protected members that I have defined in my own classes. Now when I'm using Mole, I can view and drill into the module level private and protected members of classes I have written. This provides a more in-depth view of my own data. Property EditingBackgroundWith the release of Mole v4 comes the most requested feature, Property Editing. Andrew really wanted to incorporate editing into Mole, so he and Karl dove off the cliff and into the property editing abyss. This change impacted many areas of Mole and required much testing by the entire team. When used correctly, this feature can be a great asset to WPF and WinForm developers. We will give some usage examples below. Visualizers allow the replacement of the object being visualized. Code Project MVP, Rama Krishna Vavilala brings this feature out in his XAML Debugger Visualizer for WPF article. He also explains the issues with replacing objects being visualized. Since the default object replacement capabilities of visualizers are limited to the original object being visualized, we were not able to use this technique. Instead Mole edits the values in the heap directly. As you may have already noticed in the above screen shots, not every property can be edited. Andrew wrote this explanation up for us to understand how editing in Mole works. The editing functionality makes use of .NET's TypeConverter infrastructure. The type converter is used to convert the entered text into the appropriate type for the property/field. Therefore, only properties and fields whose associated In addition, the properties/fields of certain objects are not allowed to be edited:
We have provided a good number of type editors (see below) that assist developers in editing properties. In order to provide the most flexibility and actually deliver this version of Mole, we allow the editing of objects that probably should not be edited. In order to exclude every class that "should not" be edited would take a lot more programming time, cause Mole to run slower and in the end we would see very little payback for the effort. You must also consider that Mole allows editing with every Visual Studio project type, so that "list" of non-editable types would be HUGE. So, please note that a certain amount of common sense is required when editing. The original purpose of the editing feature was to allow developers to adjust their UI at run-time and see the impact of those changes. But like everything in Mole, this feature took on a life of its own and even allows the editing of private members if they meet the above requirements. Editing Features
How To Edit There are two ways to initiate property editing. First you can click the pencil icon and the appropriate Mole Editor dialog will open. Second you can right click the pencil and select "Edit..." or "Reset/Clear." Note the "Reset/Clear" is not always available. This feature is controlled by the
Color Editor
When I first opened the editor, the font text color was black. You can see how the color was changed and then applied to the project being visualized and the color updated without having to close the editor. This is accomplished by selecting a color and pressing the "Save" button. Colors can be selected and/or set in many different ways using this editor. Also, note the color sorting below the Date Time Editor
Here the property being edited is a Font Editor (WinForm)
You can see how editing a font value is applied to the project without having to close the editor. After closing the font dialog, the "Preview Font" label is updated. Clicking the Save button actually applies the change to the project object. Font Name Editor (WPF)
Again, you can see how a font family is selected and set with the changes being applied without having to close the editor. The Font Size track bar is used to adjust the size of the preview only and not the actual font size. WPF breaks all the pieces of a font into separate properties which is different from WinForms. Also notice how font inheritance changes the entire WPF application. Selectable Value Editor (Enum's, lists, etc.)
Here we can see the mouse cursor property being edited in the Selectable Value Editor. All enums are edited in this fashion except enums that have the flags attribute. If the enum has a flags attribute and the property value has more than one value assigned to it, Mole won't edit it. We excluded enums with multiple values because the effort would not be worth the payback. Text Number Editor
In the above, the For some WPF properties that are of type Thickness Editor (Margins, padding, rectangles, etc.)
This editor handles the rectangles, margins, thickness, etc. properties. TimeSpan Editor
Mole is editing the EndOfTheWorld Logging '-----------------------------------------------------
'Tree View Object Name :
'Tree View Type Full Name: Mole.TestBench.MoleTestBench
'New Value : WidthAndHeight
'Editor Type : Int32Value
'Write Operation Type : WriteValue
'Write Error Message :
'-----------------------------------------------------
'Tree View Object Name :
'Tree View Type Full Name: Mole.TestBench.MoleTestBench
'New Value : Hi! Mole For Visual Studio - WPF Test Bench
'Editor Type : Text
'Write Operation Type : WriteValue
'Write Error Message :
Above is what the editing log looks like. After closing Mole, just paste the contents of the clipboard into your code editor to view them. In order to support developers using C# and VB.NET a new option, "Language" has been added to the Options tab. Please select your language so that the comments will be formatted correctly for you. ASP.NET I had to think long and hard about allowing ASP.NET properties to be edited. Most ASP.NET developers will probably agree that this can be problematic. We have enabled this feature, but please keep in mind that not all edits will be persisted to the page. ASP.NET has a complex page life-cycle, stores values in ViewState, cache, etc. I have been able to edit and persist many edits and see them when the page loads, but others are not persisted. SearchingMole allows you to search and filter the properties displayed. When searching, the Black Ops Field data and the normal property items are targeted by the search. The "Select Search Location" The "Show Attached Properties" Property ComparisonPurpose of Comparision Feature: This feature is handy when you need to know why something is working for one element and not for another and sometimes the best way to do that is to see what property values are different between the objects. The The When an XML file has been loaded, the The above image shows the properties grid with only non-matching value rows being displayed. When the developer changes the selected element or drills up or down, the properties grid unloads the saved values and the properties grid returns to normal. View the Logical Tree in a TreeView ControlThis section's in-depth research and coding of the WPF logical tree was all done by Josh Smith. This is fantastic information! Thanks Josh for enhancing our understanding of the WPF logical tree! In Mole v1 you could view the visual tree of the UI you were debugging, but not the logical tree(s). In Mole v2 we added support for viewing logical trees, as well as the properties, image snapshots, and XAML view of elements in the logical tree. The impetus behind this feature was to allow developers to inspect the logical tree so that they could understand how inherited dependency properties (such as Implementing this feature turned out to be rather challenging, because a significant amount of research and experimentation were necessary to fully grasp what needed to be done. After Josh completed his research into the differences between the visual tree and logical tree, he published the Understanding the Visual Tree and Logical Tree in WPF article on Code Project. If you intend on using the Logical Tree feature, you should be sure to read that article because it will explain the subtleties and quirks involved with the logical tree. Here is a screenshot of the Logical Tree tab:
Notice how beneath the TreeView there is a text area which lists three pieces of information. The “Original Element” refers to whatever element you had selected in the Visual Tree tab before opening the Logical Tree tab. The Logical Tree tab shows the logical tree of that visual element, or, if that element is not in a logical tree, the logical tree of the element’s closest ancestor which is in a logical tree. Clear as mud, right? The “Closest Logical Ancestor” refers to the first ancestor element of the original element which is in a logical tree. If the original element (i.e. the one selected in the Visual Tree tab) is in a logical tree, then this value will read “(self)”. Lastly, the “Templated Parent of CLA” refers to the templated parent of the closest logical ancestor element. This is useful information when elements are generated by templates and are disconnected from the logical tree of the templated element/control in which they exist. If you have no idea what any of this means, we recommend that you read the article Josh wrote about this topic and hopefully it won't seem so bizarre afterwards. Element Visual
The "Element Visual" The displayed image can easily be copied to the Windows Clipboard by clicking on the "Copy Image" Button. This Button makes it super easy to get snapshot images and copy them to other documents, emails, etc. Element XAML
The "Element XAML" The 'Font +' and 'Font -' Buttons allow you to change the font size of the displayed text. This setting is also persisted between Mole sessions. The two You may right-click the This This PLEASE READ THIS: If you want to conduct your own crazy list or combobox tests, remember, if your items are in a virtualizing Favorites
This Options
Mole automatically remembers many settings for you, such as the window size, window location, screen number, which column is sorted in the grid, the width of the TreeViews, and more. It also provides you with additional useful settings in the “Options” tab. Here is what that tab has to offer: Tooltip Initial DelayThis feature was requested by Josh, 2 minutes after using Mole v1. The tooltips became a hindrance so I added the ability for the user to change the amount of time the mouse must hover over an element before the tooltip pops up. Online ResourcePlease notice the Version number. You can easily compare your version with the version number on Mole's Home Page. I thought about adding in automatic checking but ditched that idea. You can also visit Team Mole's blogs by clicking the links. Moloscope Grid OptionsYou can hide some columns based on your usage preference. Please note, when inspecting a non-WPF object, the Value Source and Is DP columns will be hidden, since these are WPF-only columns. Max Rows In Collection DataAfter all the stress testing and crazy things we were doing, I added the ability to limit the number of rows in collections that gets displayed. You can adjust this to suit your needs. LanguagePlease select the language you use. This setting effects the formatting of the Mole Editing Log. Saved Settings File LocationThought someone might want to back their settings up so I provided a link to the directory. Just click the hyperlink and the directory where your settings are stored will be displayed in Windows Explorer. All Visual Studio ProjectsCollectionsViewing collection data in Mole is much easier than in Visual Studio. Basically with one or two mouse clicks you can view data inside your collection objects and collection objects that are part of the .NET Framework. Example: Also Mole displays collections with multiple data types in them. Example Mole provides two views for the same data. Individual members of a collection are displayed in the properties grid and can also be viewed in data tables using the “View Data” button. The collection members in the properties grid can be drilled into exposing rich data about that member. The data table view provides the typical data row view of collection members. There are two images of viewing collection data in this article. FavoritesThis was my first feature in Mole v1. I really wanted this. Mole allows establishing Favorites to make getting to data you normally view much faster. Let’s use the SearchingMole allows you to search the properties grid to find what you're looking for. You can search the property Name column and property Value column. With one or two keystrokes you can zero in on exactly what you're looking for. WinForm Project ExampleMole allows you to easily drill around your application, Visual Studio does not. For example open a WinForms application, place a breakpoint and perform a “Quick Watch” on the form object. For C# target, Now visualize the same object in Mole. Much more data that is easy to find and drill around is displayed. In fact the entire application is easily navigated. You can even view an image of each WinForm control. This is one reason the Visualizer feature was put into Visual Studio. Visualizers allow the display of rich data in a customized format. The DataSet Visualizer is a good example of this. Mole just treats your entire application as rich data, displays it and allows you to drill around it. The editing feature can help with making changes to forms that are dynamically generated. For WinForm applications, Visual Studio is a rock solid WYSIWYG editor and designer. For those applications where the UI is generated dynamically, Mole can help you edit your project at run-time, make the changes, view them and then returns a log of what you changed so that you can edit your source code. WPF Project ExampleThe same features and examples from the WinForm project apply here as well. If you are still using VS2005 and do not use Blend, Mole can really help out with your UI adjustments. ASP.NET Project ExampleThe same features described in the above WinForm section also apply to ASP.NET projects. Depending on when you open Mole up in relation to the Open the provided Test Bench program for ASP.NET. When you view the default.aspx When using Mole with ASP.NET applications, developers can really "see" the difference in the "state" of their applications between "before a PostBack" and "after a PostBack". When debugging a page before a PostBack has occurred objects are being constructed, databases queried, In all honesty, I may only be scratching the surface here. Maybe in the future, we'll see blog postings and articles on getting the most from Mole or tools like Mole. WF Project ExampleAs of Mole v4.2 can be used on WorkFlow (WF) applications. We have also posted a video on using Mole with WF on YouTube. You can learn a good bit by watching the vidoes we have posted. Two attributes were added to the A new WF project Test Bench was added to the source and test benches download. There are two places in the source code that we have left instructions for where to place break points to view WF data. These are marked with the 'TODO comment. Mole really shines with respect to the Check out the Launch Mole Using WeakReference Hack"The Rock Star Hack of 2008!" - We at Team Mole have been trying for a long time to figure out a generic way for developers to launch Mole. On 1/19/2008, Josh "Rock Star" Smith has finally breached this stone wall with his awesome hack!! Once you get a hold on how powerful this hack is, your debugging days will never be the same again! Josh Smith wrote an outstanding blog entry, The Rock Star Hack of 2008 that explains this feature in great detail. Check it out! Karl also posted a video on this awesome feature, Mole v4.2 New Generic Way To Start Mole, The Rock Star Hack!. This feature enables you to start Mole on any object any time you want to. You do NOT need to modify the attributes on the Mole.Visualizer.dll file. For example, in the above image, I'm using this new way of starting Mole, to visualize an exception. Mole has been modified so that Visual Studio can reconginze All that is required for a developer to use this hack, is to place a breakpoint anywhere in your code. Then use the Visual Studio Watch Window, and add a new watch, wrapping the object you want to visualizer in the constructor of the
If you wanted to view an object class like
After you add the new watch, press <ENTER> If you are using Visual Studio 2005, you must use the full type name, When used this way, Mole tries to figure out what project type your are using and will attempt to build the familar application tree. If Mole can't figure this out, it will load your object in the application tree, and then expose the object in the properties grid. You can then drill around like normal. Please read: You can not use Team Mole hopes you all like this new and exciting debugging feature! LimitationsSo far, the only limitation I've run into is the Element XAML. Under certain circumstances the You would get these same exceptions in your own code if you called Developers Please ReadWe have left 'TODO and 'HACK' Visual Studio comments in the source code. Please take a look at these. Visual Studio 2008 Warning MessageOpening up a release build of Mole can cause Visual Studio to display a message box stating: "This module was built either without optimizations enabled or without debug information." To make that stop, go to Tools | Options | Debugging | General and then uncheck the “Warn if no user code on launch” option. Mole & Visualizers 101The first article I read was Creating Debugger Visualizers with Visual Studio 2005 by Julia Lerman. She does an outstanding job of getting you started. Another good starting point is the MSDN Visualizer Architecture article. Also there many articles here on CodeProject and the Internet covering visualizers. Basically there are four partners, running in two processes, that work together in the visualizer world. Debugger Side
Debuggee Side
Visual Studio plays the middle man handling communications between the two processes. The bottom line is, your visualizer UI has no data, until it makes a request to the Both sides of the conversation are active throughout the visualizer's life. This allows your UI to make repeated requests to the data object whenever it needs more data to display. The communications plumbing Microsoft provided is incredibly fast, even with all the serialization and deserialization going on. Visualizer ProjectIf you are used to writing executables, this is going to blow your mind. Your visualizer complies into one class library DLL, part of which runs in one process and the other part is running in the other process. The classes from the Debugger process communicate through Visual Studio to classes in the Debuggee process. How Does Mole's Project Fit Into This?Visual Studio is only concerned about two classes in your visualizer. First, your Debugger Side class which derives from Visual Studio identifies these classes by looking at the following attributes placed on the assembly in which your visualizer lives. Since all visualizers must be in certain directories, it is very easy for Visual Studio to locate all visualizers on your system and determine which types have visualizers. You cannot have Visual Studio honor an attribute with a 'TODO developers feel free to add more Types that Mole can visualize
' You only have to add additional attributes here.
' Mole can handle just about ANYTHING you throw at it.
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow),_
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Windows.DependencyObject), _
Description:="Mole (Exploring WPF)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Web.UI.Control), _
Description:="Mole (Exploring ASP.NET)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Windows.Forms.Control), _
Description:="Mole (Exploring WinForms)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Data.DataSet), _
Description:="Mole (Exploring DataSet)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Data.DataTable), _
Description:="Mole (Exploring DataTable)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Windows.RoutedEventArgs), _
Description:="Mole (Exploring RoutedEventArgs)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.EventArgs), _
Description:="Mole (Exploring EventArgs)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.ServiceModel.ServiceHost), _
Description:="Mole (Exploring WCF)")>
<Assembly: System.Diagnostics.DebuggerVisualizer(GetType(Mole.Burrow), _
GetType(Mole.MoleVisualizerObjectSource), _
Target:=GetType(System.Data.SqlClient.SqlException), _
Description:="Mole (Exploring Exception)")>
First attribute parameter is the type of our visualizer ( Second is the type of our data source ( Third tells Visual Studio what type our visualizer wants to visualize. (In Mole speak that is, "what type Mole wants to Burrow into and molenate".) In our first attribute, Mole can visualize The fourth attribute parameter is the description Visual Studio displays in the listing of available visualizers when you are debugging. Glance back to the second image in this article and you'll see the above description. The remaining attributes simply register their object types with Visual Studio so that this Mole visualizer will be listed in the data tip during debugging. Using Mole To View ExceptionsI've added a section of code to the WinForm Test Bench program that throws an I did try to get the visualizer to recognize all exceptions by setting the Viewing the exception was for instructional purposes and to spread Mole's wings to see what the application is capable of. Where Are WeAt this point, all Visual Studio developers have enough information to begin using Mole for their advanced debugging needs. Additionally you can target more .NET Framework types for Molanization. If there is some interest, Team Mole could write a paper on the internals of Mole and possibly give a presentation also. I know this article is long, but for all the new users of Mole, necessary. Mole Fun StuffThe following provides information for becoming a Mole Geek. Mole Speak
Sample Questions You Can Ask Fellow Developers
Insect Programming MethodologyInsect Programming was heavily utilized during Mole’s coding cycle. This is where most of Mole’s features came from. The basic tenet of Insect Programming, as opposed to eXtreme Programming, is whatever features fly into our heads, we program. The Insect methodology increases developer creativity because it completely bypasses the boring specification process and all those meetings and long drawn out discussions, UML diagrams, etc. What is really funny is that at work, I’m the exact opposite; no spec, no keyboard activity. Mole Quotes From Users Of Mole
ResourcesCheck here Team Mole & Mole Project Home and Mole's Home Page for additional information. If you subscribe to Karl's Blog RSS feed you will be notified of all enhancements to Mole. You can leave comments at the bottom of this article, on our blogs or send Mole an email at: moleproject@yahoo.com. ReferencesWoodstock – It all started here http://www.codeproject.com/KB/WPF/WoodstockForWPF.aspx Mole v1 article http://www.codeproject.com/KB/WPF/MoleForWPF.aspx Mole v2 article http://www.codeproject.com/KB/WPF/moleIIforWPF.aspx Mole v2.2 Black Ops article http://www.codeproject.com/KB/WPF/MoleBlackOpsVersion.aspx Mole v3 Visual Studio Visualizer article Understanding the Visual and Logical Tree In WPF article http://www.codeproject.com/KB/WPF/WpfElementTrees.aspx Josh Smith’s Blog http://joshsmithonwpf.wordpress.com/ Karl Shifflett’s Blog http://karlshifflett.wordpress.com/ Andrew Smith's Blog MSDN Visualizers (has links to many MSDN visualizer topics) http://msdn2.microsoft.com/en-us/library/zayyhzts.aspx CloseTeam Mole hopes you find Mole For Visual Studio a productive developer tool and that this article helps learn a little more about Visual Studio Visualizers. From Team Mole, have a wonderful day and enjoy Mole! History
| ||||||||||||||||||||