The Rock Star Hack of 2008

January 20, 2008

Hacks are usually the result of working around a bug or artificial limitation in some library against which you are coding, but have no ability to modify. I typically try to brush my hacks and workarounds under the rug, hoping no one will ever see them. But today I am proud to announce a hack I came up with. This is, in my opinion, one of the few hacks worth its weight in digital gold.

Karl Shifflett and I were talking on the phone yesterday. He mentioned that he has received a lot of support e-mails on moleproject@yahoo.com where people are confused about how to open Mole. Several people have tried to view an object in Mole that wasn’t “moleable,” meaning that the Mole.Visualizer.dll assembly is not decorated with an instance of the DebuggerVisualizer attribute where the target type is the type of object (or ancestor type) they want to molenate. In other words, people have been trying to open Mole on a business object they created, but Visual Studio does not list Mole as an available visualizer for that object.

Team Mole has known about this issue for a long time. The crux of the matter is that Visual Studio will not allow us to apply the DebuggerVisualizer attribute to Mole and specify that it works for any object that descends from System.Object. Visual Studio does not want to show Mole as an available visualizer for any type of object, but that is exactly what we want it to do. Yesterday I figured out a simple way to work around this artificial limitation imposed by Visual Studio. Karl has since dubbed it “The Rock Star Hack of 2008″ since my nickname is Rock Star (more on that here).

Visual Studio has no qualms with allowing us to specify that Mole can be used to visualize a System.WeakReference object. Since WeakReference is basically just a thin wrapper around any object, we use WeakReference as a Trojan horse to smuggle any object past the Visual Studio sentries and into Mole. Once Mole gets a hold of the WeakReference we wrapped around the object that we actually want to visualize, it unwraps the object and displays it in the UI, throwing away the WeakReference in the process. Keep in mind that we are only using WeakReference as a container to smuggle any object into Mole, we are not using that class for its intended and documented purpose.

So that’s all well and good, but it would be a real nuisance if you had to stop your debugging session just to edit your code and create these WeakReferences for Mole, wouldn’t it? That’s where the Watch window enters the picture. You can create a WeakReference in the Watch window, and pass the object to visualize into its constructor. Here’s an example of how I used this feature to open Mole on Podder‘s main data model class instance:

The Rock Star Hack of 2008 in action

Once the WeakReference has been created in the Watch window, I can simply click on the magnifying glass icon to open Mole. Bear in mind that this code is executing in the application’s data model assembly, which has no UI controls or anything else that you typically use to open Mole. Before this hack was invented, using Mole in this situation was impossible. How cool is that?!

Karl posted this video on YouTube showing how to use The Rock Star Hack of 2008:

You will need to get the new drop of Mole to perform the hack. The new drop also supports molenating Windows Workflow Foundation apps! Here is the link: http://karlshifflett.wordpress.com/mole-for-visual-studio/


Listen to the Polymorphic Podcast about Mole

January 15, 2008

I am extremely happy to announce that the Polymorphic Podcast has recently published an episode where Craig Shoemaker and I discuss the Mole debugger visualizer!  In the interview I explained a lot of background information about Mole’s development and how it works.  If you are interested, feel free to check it out here: http://polymorphicpodcast.com/shows/mole/

I highly recommend you listen to the Mole podcast episode using the Podder podcast player;)


Mole v4.1 released

January 15, 2008

Mole has been updated with some cool new features and minor bug fixes:

  • Added the ability to export an object’s properties and fields to an XML file. That file can later be imported to allow for element comparisons.
  • Fixed the image processing code so that it handles exceptions raised only after editing certain properties/fields of a control.
  • Added tooltips that display fully qualified type names to the TreeViews, breadcrumb items,  and the property grid’s Type column.
  • Added a “Show Namespaces” option to have the TreeViews, breadcrumb items, and the property grid’s Type column show the fully qualified type names.
  • The “Show Attached Properties” CheckBox is now hidden when not viewing WPF applications.

The source code and binaries associated with the article have been updated as well.

If you would like to quickly get up to speed on using Mole, be sure to watch the tutorial videos on YouTube.

Have a great day!


The Mole tutorial video

January 7, 2008

Karl made a nice and short introductory video to using our Mole for Visual Studio debugger visualizer. If you want to quickly learn the ropes of using our free tool, check it out here:


Mole now has editing capabilities

December 31, 2007

Karl and Andrew have taken Mole to the next level.  Now you can edit properties and fields of an object, and those modifications are persisted!  I was only marginally involved with this new feature, mostly testing and giving feedback, but I’m really glad that those two guys took the time to see it through to completion.  This is really amazing stuff, and I highly recommend you check out the new article and download the latest bits.  Here is the new article:

http://www.codeproject.com/KB/macros/MoleForVisualStudioEdit.aspx

Visit www.moleproject.com to learn more about Mole.

Happy New Year!  :-D


Mole is now legit!

December 21, 2007

After clobbering the web with mountains of articles, blog posts, and comments about Mole, we decided that Mole needs a home.  We bought it a domain name, so that from now on whenever you need to find your latest Mole fix, just go here:  http://moleproject.com

Right now that URL just gets forwarded over to the main Mole page on my blog.  Over time we hope to build a little Web site for Mole, and will eventually have the URL point there instead.

For some reason, Mole seems to be a “legitimate” project now that it has its very own URL.  Kind of silly… 

If you want to contact Team Mole with any questions/problems/suggestions about Mole, please send them to moleproject@yahoo.com

Have a great holiday!


Mole for Visual Studio

December 15, 2007

There have been many iterations of the Mole visualizer.  The latest and greatest release is not confined to WPF applications, it works with any application!!  Karl Shifflett and Andrew Smith (of Infragistics) have really hit the ball out of the park.  I helped out with testing, editing the article, and providing feedback.  I’ve been too busy learning Silverlight 1.1 to keep up with their amazing pace.  Great work guys!

Read the article and get the latest Mole for Visual Studio here: http://www.codeproject.com/KB/macros/MoleForVisualStudio.aspx

Enjoy!

(Note: I cross-posted this  blog entry between this blog and my new blog.  Normally I would not do this, but I really want to help spread the word about Mole for Visual Studio.  It’s such an awesome tool!)


Mole II has been enhanced

December 11, 2007

Karl Shifflett decided that Mole II was not good enough, so he added in a feature which allows you to see non-public fields of the object you are inspecting.  Now you can see properties and fields, which makes the debugging process even more rapid because the true state of your objects can be seen with ease.  After we reviewed the new feature, Karl blogged about it and wrote an article on CodeProject.  Check out his updates here: http://karlshifflett.wordpress.com/2007/12/11/mole-v22-black-ops-version-released/

As of this writing, this new feature does not display the private fields of an object’s ancestor types.  It only displays the fields found in the object’s most derived partial.  I think that needs to be addressed before it is truly “done,” but so far it’s a great start.  Nice work, Karl!


Forget about Woodstock, get Mole!

November 26, 2007

Woodstock was a prototype; a “proof of concept” which really caught on and matured.  After I published the Woodstock article a good friend and cohort in WPF crime, Karl Shifflett, began working on a better WPF visualizer.  After a couple weeks of us discussing, prototyping, emailing code snippets, sharing/critiquing ideas, and him working around the clock, he finally published an article about it.  His WPF visualizer, called Mole, is now publicly available, just waiting for WPF developers to download it and put it to use.

I highly recommend that you check out Mole.  It is the WPF visualizer.  Forget about Woodstock, use Mole!


Woodstock snapshot image bug fix

November 21, 2007

I finally figured out how to fix a bug in Woodstock’s snapshot image processing logic.  The bug prevented images from showing up in certain situations, but now all is well.  Get the latest drop here:

http://www.codeproject.com/useritems/WoodstockForWPF.asp


Follow

Get every new post delivered to your Inbox.

Join 275 other followers