I’m developing a quite complicated (it is always complicated when you have to manage big trees) project.
As in the project there are a lot of trees that are moving around (never seen a tree walking down the streets?) and transforming themselves I’ve thought that it could be nice to use a Debug Visualizer to have a clearer view of the structure of these expression trees.
I know, the visual studio 2010 have the new DebugView property that makes it inspect the tree.. but it is still complicated to read when you have kilometric long namespace names that ends in generic object that in turn uses generic parameters with (again) long names.
it is a mess
so I’ve decided to use the old but still good Expression tree visualizer available from the Visual studio 2008 C# code samples.
Downloaded, changed the reference to the Microsoft.VisualStudio.DebuggerVisualizers.dll library so to reference the newest one (C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\ReferenceAssemblies\v2.0\Microsoft.VisualStudio.DebuggerVisualizers.dll) and then compiled.
But here starts the problem:
My configuration is Windows 7 64 bit Ultimate and Visual studio 2010 Ultimate (with latest service packs and everything)
My projects are all in .Net 4.0 at the moment I'm writing.
I’ve compiled the visualizer, put it in the right folder
C:\Users\Duke\Documents\Visual Studio 2010\Visualizers
and BAM! …. nothing
nothing appear, no magnifier when I hover an expression reference.
I’ve tried to moving the visualizer in all the possible valid location (also considering the 64 bit architecture) but noting!
Binged and Googled… I’ve found that many people have had the same issue.
So I’ve started looking inside the actual code, and here it is!
[assembly: DebuggerVisualizer(typeof(ExpressionTreeVisualizer), typeof(ExpressionTreeVisualizerObjectSource), Target = typeof(Expression), Description = "Expression Tree Visualizer")]
Sooooo wrong! I’ve fixed it this way
[assembly: DebuggerVisualizer(typeof(ExpressionTreeVisualizer), typeof(ExpressionTreeVisualizerObjectSource), Target = typeof(Expression<>), Description = "Expression Tree Visualizer")]
Note typeof(Expression) transformed in typeof(Expression<>)
The type to visualize should be the generic one to work with the last version of the framework.
Recompiled, dropped in the right folder and this time IT WORKS!
Ok! now it works like a charm I hope this could help also other people with the same issue
Tags: