捕捉VS局部变量,而在EnvDTE调试 [英] Capture VS local variables while debugging in EnvDTE

查看:323
本文介绍了捕捉VS局部变量,而在EnvDTE调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能捕获的使用由当地人和调试窗口调试数据,使用EnvDTE的.vsix的Visual Studio扩展?或者是有可能通过其他方法?



我想创建一个自定义本地窗口中,我们可以修改,以显示我们的一些更加沉重的内容,因为我们喜欢,在不牺牲原来当地人窗口的电力用户。理想的解决方案将是获取数据被发送到当地人的窗口,所以我可以建立自己的树。


解决方案

原来这其实是很简单的!



<预类=郎-CS prettyprint-覆盖> DTE DTE =(DTE).Package.GetGlobalService(typeof运算( DTE));
如果(!dte.Debugger.CurrentStackFrame = NULL)//确保调试器运行
{
EnvDTE.Expressions当地人= dte.Debugger.CurrentStackFrame.Locals;
的foreach(在当地人EnvDTE.Expression本地)
{
EnvDTE.Expressions成员= expression.DataMembers;
//完成本节递归,在寻找每个表达式为
//下一组数据的成员了。这将构建树。
//数据成员是从来没有空,而不是只迭代一个长度为0列表。
}
}

每个表达式包含:




  • 命名(串)

  • 显示在(字符串值当地人窗口)

  • 键入(字符串类型的名称)

  • (类型是父类)

  • 数据成员)(其子(永远不能为null的可重复的集合)

  • 的IsValid (布尔)



希望这可以帮助其他人希望做类似的东西!


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!

这篇关于捕捉VS局部变量,而在EnvDTE调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆