Blog Home  Home Feed your aggregator (RSS 2.0)  
Linq Expressions DebuggerVisualizer - Manuel Abadia's ASP.NET stuff
# Tuesday, April 24, 2007

I have been playing a bit with Visual Studio "Orcas" Beta 1 and I really wanted to see the Expression Trees generated by Linq, so it was a good chance to play with my StructsViz component. In a couple of hours I got this DebuggerVisualizer working.

For the following expressions:

Expression<Func<Person, bool>> expr1;

Expression<Func<int, string, bool>> expr2;


expr1 = p => p.Name == "Manu";

expr2 = (idx, str) => !((idx <= 0) || (str.Length > 2));


The visualizer renders the following:

The nodes in red are terminal expressions (constants or parameters), the nodes in green are objects used by the expression subtree, and the other expression nodes are blue. The properties and fields for each node are loaded on demand and can be inspected when the node is expanded.

As expression trees are used to do really cool things I have made a free special version of StructsViz with only the functionaly needed to display expression trees. Due to the crappy NVidia drivers for Vista I haven't been able to test it extensively (as my hard disk stops from time to time, specially with Virtual PC) so let me know if there is any problem. As always, feedback is welcome.

To read more about Linq take a look at this article or at ScottGu's excellent posts about Linq.

To use the DebuggerVisualizer, create a Visualizers folder inside C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008, and copy the LinqExpressionVisualizer.dll there.

Another option is to copy the visualizer to C:\Program FIles\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers

Please do not distribute the visualizer from your web page. Link to this page instead.

Update 13/01/2008:

Modified it to run on VS 2008 RTM. (33.4 KB)

Update 21/11/2010:

Modified it to run on VS 2010 RTM. (40,22 KB)

Tuesday, April 24, 2007 2:05:10 PM (Romance Daylight Time, UTC+02:00)  #    Comments [7]   Linq | Microsoft .NET Framework  | 
Copyright © 2020 Manuel Abadia. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.