views:

28

answers:

2

First the problem I am trying to solve: I'm debugging a C# application that has huge object graphs (think Building Information Models, a kind of object oriented CAD). When I hit a breakpoint, I generally have long lists of objects I'd first need to transform to be useful for debugging.

In code, I use LINQ and lambdas to do this. But you can't do that in the Watch window and the Immediate window.

How could I go about adding an IronPython shell extension to Visual Studio 2010 that lets me snoop the same information available to the Immediate window / Watch window?

EDIT: I can figure out how to make a debugger visualizer. But from the API it seems I would only have access to the object being visualized - while I'd actually prefer to have access to all local variables.

EDIT: From the documentation on msdn it seems a DE (Debug Engine) with an EE (Expression Evaluator?) can do the trick. This is for integrating your own language into Visual Studio. I'm trying to hook into the existing DE or at least provide my own EE.

+1  A: 

I don't know whether this will help, but there's a good series about writing debuggers and extensions in managed code at http://devhawk.net/2009/02/27/Writing+An+IronPython+Debugger+MDbg+101.aspx

Matthew Steeples
Thanks. I had seen MDbg, but failed to compile the python extension). This seems a bit of a round-about root, since it is a standalone debugger and I'd like to just hook into the Visual Studio Debugger. Alas, I think I'm gonna lose this one :(
Daren Thomas
A: 

It turns out its rather easy to write a Visual Studio 2010 Addin: Just download and install the Visual Studio 2010 SDK. Next, create an Addin project.

The OnConnection Method in the Connect class of your Addin will provide you with a DTE2 instance. This can be used to poke around in the Visual Studio Debuggers Expression Evaluator:

DTE2 application; // fill this in OnConnection
application.Debugger.GetExpression("some c# code goes here")

The results are Expression instances, COM objects. Check the Value property.

Homework: Figure out how to wrap that up in a nice pythonic framework to make it seem seamless.

Daren Thomas
Anyone interested on how this is coming along: Just comment here, I'll gladly post the code to a project host in exchange for some help!
Daren Thomas