Is it possible to capture the debug data that's used by the locals and debug window, using EnvDTE for a .vsix visual studio extension? Or is it possible through another method?
I would like to create a custom Locals window that we can modify to display some of our more heavy content as we like, without sacrificing the original Locals window for power users. The ideal solution would be to grab the data being sent to the locals window so I could build my own tree.
Turns out this is actually quite simple!
DTE dte = (DTE).Package.GetGlobalService(typeof(DTE));
if(dte.Debugger.CurrentStackFrame != null) // Ensure that debugger is running
{
EnvDTE.Expressions locals = dte.Debugger.CurrentStackFrame.Locals;
foreach(EnvDTE.Expression local in locals)
{
EnvDTE.Expressions members = expression.DataMembers;
// Do this section recursively, looking down in each expression for
// the next set of data members. This will build the tree.
// DataMembers is never null, instead just iterating over a 0-length list.
}
}
Each expression contains:
- Name (string)
- Value (string value displayed in the locals window)
- Type (string name of type)
- Parent (type is of parent type)
- DataMembers (iteratable collection of its children (never null))
- IsValid (bool)
Hope this helps anyone else looking to do something similar!