可以DebuggerStepThrough被继承到自动生成的IEnumerable实现? [英] Can DebuggerStepThrough be inherited into the automatically generated IEnumerable implementation?

查看:135
本文介绍了可以DebuggerStepThrough被继承到自动生成的IEnumerable实现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

借助 DebuggerStepThrough 属性你可以跳过闯入某些方法/班/属性。

The DebuggerStepThrough attribute allows you to skip breaking into certain methods/classes/properties.

DebuggerStepThrough被忽略它阐明了C#编译器不会继承该属性为生成的的IEnumerable<编译器; T> 的实施。

In DebuggerStepThrough being ignored it is clarified that the c# compiler does not inherit this attribute into the compiler generated IEnumerable<T> implementation.

这种故障的简单的例子是:

A trivial example of such a failure is:

static void Main(string[] args)
{
    var a = SkipMe().ToList();
}

[System.Diagnostics.DebuggerStepThrough]
static IEnumerable<int> SkipMe()
{
    // comment out line below and the throw will be stepped over.
    yield return 1;
    throw new Exception();
}



有没有办法让C#编译器添加 DebuggerStepThrough 属性自动生成的类型?

Is there a way to get the C# compiler to add the DebuggerStepThrough attribute to the auto generated type?

有没有办法让视觉工作室跳过调试到任何类型的 [编译器生成] 属性?

Is there a way to get visual studio to skip debugging into any types with the [CompilerGenerated] attribute?

-

附录:一些说明性的截图

Addendum: some illustrative screenshots

按<大骨节病> F5

Visual Studio的版本:

Visual Studio Version:

我们的遗漏属性:

推荐答案

我不认为有一种方法可以实现你要找的效果。

I don't think there is a way to achieve the effect you're looking for.


  • 有没有办法让C#编译器复制这个属性到生成状态机的方法。

  • 您不能解决此加入 DebuggerStepThrough 含有迭代器方法的类获得。调试器仅着眼于眼前的父类型不包含嵌套类型的类型。

  • There is no way to make the C# compiler copy this attribute into the generate state machine method.
  • You can't get around this by adding DebuggerStepThrough to the class containing the iterator method. The debugger only looks at the immediate parent type not the types containing a nested type.

我能想到的,实现的唯一途径这是把所有你不想调试代码到一个单独的DLL。那就不要加载PDB为特定的DLL。

The only real way I can think of to achieve this is to put all of the code you don't want to debug into in a separate DLL. Then don't load the PDB for that particular DLL.

这篇关于可以DebuggerStepThrough被继承到自动生成的IEnumerable实现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆