我可以将一个类标记为不是我的代码,以便调试器跨过它吗?

时间:2021-09-16 08:00:19

I have a utility class that has been thoroughly tested, and I do not want the VS debugger to step into any of its methods. I think I have heard of a way to mark something as not my code so that the Just My Code debugger setting causes the debugger to step over these method calls, but for the life of me I cannot recall what the class attribute is (nor can I successfully Google for it).

我有一个经过全面测试的实用工具类,我不希望VS调试器进入任何方法。我想我已经听说过一种方法来标记某些东西而不是我的代码,以便Just My Code调试器设置导致调试器跳过这些方法调用,但对于我的生活,我不记得类属性是什么(也不能我成功谷歌吧)。

I know that I could separate this class into its own assembly and build it in release mode to alleviate the issue, but I would like to step into some of the assembly (and I would like to keep this class where it is).

我知道我可以将这个类分成它自己的程序集并在发布模式下构建它来缓解这个问题,但是我想进入一些程序集(我希望将这个类保持在原来的位置)。

Is this possible, or was I dreaming up this option?

这是可能的,还是我梦想着这个选择?

Update

I did some testing with the two options (DebuggerStepThrough and DebuggerNonUserCode), and I found that DebuggerNonUserCode behaves exactly the same as the framework when having Just My Code enabled / disabled. The DebuggerStepThrough attribute always causes the debugger to skip the section marked with the attribute. For consistency's sake, I went with DebuggerNonUserCode.

我使用两个选项(DebuggerStepThrough和DebuggerNonUserCode)进行了一些测试,我发现DebuggerNonUserCode在启用/禁用Just My Code时的行为与框架完全相同。 DebuggerStepThrough属性始终使调试器跳过标有该属性的部分。为了保持一致性,我选择了DebuggerNonUserCode。

2 个解决方案

#1


12  

You are looking for the DebuggerNonUserCode attribute.

您正在寻找DebuggerNonUserCode属性。

#2


20  

You can use the DebuggerStepThrough attribute to skip over it.

您可以使用DebuggerStepThrough属性跳过它。

#1


12  

You are looking for the DebuggerNonUserCode attribute.

您正在寻找DebuggerNonUserCode属性。

#2


20  

You can use the DebuggerStepThrough attribute to skip over it.

您可以使用DebuggerStepThrough属性跳过它。