gpt4 book ai didi

c# - 有没有办法在 Visual Studio 中的 "break all"之后保留在当前文档上?

转载 作者:可可西里 更新时间:2023-11-01 03:00:14 25 4
gpt4 key购买 nike

当我在调试时“全部中断”时,Visual Studio 在堆栈顶部打开源代码;我想将光标保持在我当前正在处理的文档上,而不打开任何其他文档或窗口(例如:未加载符号)。

最佳答案

有一种方法可以保留在当前文档上,但这需要在调试 工具栏中创建一个 Visual Studio 加载项和一个新的 UI 命令。这个答案的学分实际上也应该去 openshac ,谁发布了类似的 SO question并且还通过使用宏在他的 OP 中提供了解决方法。

实现相当简单(我花了几分钟就让它工作了)。首先,在加载项项目中,修改 Connect.cs 文件中的 Exec 方法,如下所示:

public void Exec(string commandName, vsCommandExecOption executeOption, ref object varIn, ref object varOut, ref bool handled)
{
handled = false;
if(executeOption == vsCommandExecOption.vsCommandExecOptionDoDefault)
{
if(commandName == "BreakInCurrentDocument.Connect.BreakInCurrentDocument")
{

// here's where the magic happens
// ******************************
var activeWindow = _applicationObject.ActiveWindow;
_applicationObject.Debugger.Break();
if (_applicationObject.ActiveWindow != activeWindow)
{
_applicationObject.ActiveWindow.Close(vsSaveChanges.vsSaveChangesNo);
}
// ******************************

handled = true;
return;
}
}
}

创建并注册加载项后,只需:

  1. 单击 Visual Studio 菜单上的TOOLS
  2. 自定义
  3. 命令
  4. 选择“工具栏”单选按钮
  5. 选择“调试”
  6. 添加命令...
  7. 从“插件”类别中,选择您的自定义插件。

就是这样。

关于c# - 有没有办法在 Visual Studio 中的 "break all"之后保留在当前文档上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14645791/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com