vb.net 如何强制调试器跳过一段代码?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15023996/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 12:28:14  来源:igfitidea点击:

How to force debugger to skip a piece of code?

c#.netvb.netvisual-studiodebugging

提问by Mohsen Sarkar

There is huge amount of code in my project which already debugged 50% of it.
Every time I try to debug it I have to manually set breakpoints after unwanted piece of code to skip it.
Is there a way to tell debugger not to debug that part of code ? Any extension for this ?

我的项目中有大量代码已经调试了其中的 50%。
每次我尝试调试它时,我都必须在不需要的代码段之后手动设置断点以跳过它。
有没有办法告诉调试器不要调试那部分代码?任何扩展?

Let's face debugger is on line 1500.

让我们面对调试器在 1500 行。

Method1(){
   Line 1500 CODE
   Line 1501 CODE
   ...
   Line 1726 CODE
   Line 1727 CODE
   ...
   Line 2200 CODE
}

I won't need to debug lines between 1727 and 2200.

我不需要调试 1727 和 2200 之间的线路。

NOTE : It's not just one piece. Otherwise I would be fine with manual breakpoints

注意:它不仅仅是一件。否则我可以使用手动断点

回答by Oded

If the code in question is encapsulated in a method, you can skip the method by applying the DebuggerStepThroughAttributeon it.

如果有问题的代码封装在一个方法中,则可以通过DebuggerStepThroughAttribute在其上应用 来跳过该方法。

Other than that, setting breakpoints is how to do it.

除此之外,设置断点是如何做到的。

So, extract this code into a method and apply the attribute to it ;)

因此,将此代码提取到一个方法中并将该属性应用于它;)

回答by Pawcio

Don't know why it's not in the answer but you can set next statement by CTRL+SHIFT+F10or dragging the yellow arrow to wanted line and code before next statement will not be executed.

不知道为什么它不在答案中,但您可以通过CTRL+SHIFT+F10设置下一条语句或将黄色箭头拖动到所需的行,并且不会执行下一条语句之前的代码。

Found it here

在这里找到