The DebuggerStepThrough attribute allows you to skip breaking into certain methods/classes/properties.
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();
}
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
Result after pressing F5
Visual Studio Version:
Our missing attribute:
I don't think there is a way to achieve the effect you're looking for.
DebuggerStepThrough
to the class containing the iterator method. The debugger only looks at the immediate parent type not the types containing a nested type.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With