我可以动态跳过一行代码而无需使用断点在Visual Studio中重新编译吗?

时间:2023-01-14 23:54:09

I can manually skip lines of code by setting a breakpoint, moving the execution cursor and hitting continue.

我可以通过设置断点,移动执行光标并按下继续来手动跳过代码行。

Is there a way to configure Visual Studio, perhaps with a macro, such that a specific line will be skipped every time it is hit? I could do it manually, but this is highly impractical in instances where the line is hit every frame, or in a loop with a large number of elements.

有没有办法配置Visual Studio,可能使用宏,这样每次命中时都会跳过特定的行?我可以手动完成,但是在每一帧都有线的情况下,或者在有大量元素的循环中,这是非常不切实际的。

An alternative is commenting out the line, rebuilding and running the code up to the point I'm testing out. Sure I could add a static boolean to control whether or not the line is executed, but it is still impractical, especially with large codebases where the rebuilding time is not trivial.

另一种方法是评论该行,重建和运行代码直到我正在测试的那一点。当然我可以添加一个静态布尔来控制是否执行该行,但它仍然是不切实际的,特别是对于重建时间不重要的大型代码库。

Another idea is removing the line straight in memory/disassembly, but it is still impractical, and one has to be extremely careful as the slightest error can be catastrophic.

另一个想法是在内存/反汇编中直接删除线,但它仍然是不切实际的,必须非常小心,因为最轻微的错误可能是灾难性的。

1 个解决方案

#1


1  

Code Melee - FlexPoints would be an extension which could skip multiple lines of code while debugging without editing code or manually stepping over the line.

Code Melee - FlexPoints是一个扩展,可以在调试时跳过多行代码,无需编辑代码或手动跨越行。

https://marketplace.visualstudio.com/items?itemName=CodeMelee.CodeMelee-FlexPoints

https://marketplace.visualstudio.com/items?itemName=CodeMelee.CodeMelee-FlexPoints

Actually this feature request has been submitted before for old VS version:

实际上此功能请求之前已提交旧版VS:

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2221315-implement-a-new-skip-over-breakpoint-type

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2221315-implement-a-new-skip-over-breakpoint-type

But product team didn't think about adding this feature in current VS version. So my suggestion is that you could use above extension tool as a workaround, or you could submit a new feature for next VS version.

但产品团队没有考虑在当前的VS版本中添加此功能。所以我的建议是你可以使用上面的扩展工具作为解决方法,或者你可以为下一个VS版本提交一个新功能。

#1


1  

Code Melee - FlexPoints would be an extension which could skip multiple lines of code while debugging without editing code or manually stepping over the line.

Code Melee - FlexPoints是一个扩展,可以在调试时跳过多行代码,无需编辑代码或手动跨越行。

https://marketplace.visualstudio.com/items?itemName=CodeMelee.CodeMelee-FlexPoints

https://marketplace.visualstudio.com/items?itemName=CodeMelee.CodeMelee-FlexPoints

Actually this feature request has been submitted before for old VS version:

实际上此功能请求之前已提交旧版VS:

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2221315-implement-a-new-skip-over-breakpoint-type

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/2221315-implement-a-new-skip-over-breakpoint-type

But product team didn't think about adding this feature in current VS version. So my suggestion is that you could use above extension tool as a workaround, or you could submit a new feature for next VS version.

但产品团队没有考虑在当前的VS版本中添加此功能。所以我的建议是你可以使用上面的扩展工具作为解决方法,或者你可以为下一个VS版本提交一个新功能。