Search code examples
c#debuggingauto-generate

disable DebuggerStepThrough for partial class


I have set of classes that are auto generated by tool. but all classes are marked with DebuggerStepThrough attribute

the classes are partial, so I can write my code for that class in separate file, however DebuggerStepThrough in auto generated part of partial class will affect entire class.

How can I disable this behavior for DebuggerStepThrough, removing DebuggerStepThrough is obvious solution but that's not the answer I'm looking for. I don't want to touch auto generated code. also skipping from auto generated code is ok, but I want to be able to debug my own code.

[DebuggerStepThrough]
partial class Foo
{
   // auto generated
}

// how to exclude this part from DebuggerStepThrough?
partial class Foo
{
   // user code
}

Solution

  • What you are asking to do is impossible as far as I know. Partial class attributes are merged at compile time. So your two partial classes:

    [DebuggerStepThrough]
    partial class Foo
    {
        // auto generated
    }
    
    partial class Foo
    {
        // user code
    }
    

    Compile to this:

    [DebuggerStepThrough]
    class Foo
    {
        // auto generated
    
        // user code
    }