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
How to force debugger to skip a piece of code?
提问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 ;)
因此,将此代码提取到一个方法中并将该属性应用于它;)

