views:

85

answers:

1

I have created a partial class for my xsd auto generated class. The problem is in debugging this partial class. Breakpoint are not recognized or the compiler doesn't break at the breakpoints set in the partial class.

// Autogenerated class by xsd.exe

public partial class Class1
{
    private Class1Brand[] brandField;

    private string Class1guidField;

    .....
}

// Debug Part - probably in a different file
public partial class Class1
{
    public static Validity setValidity(Validity validity)
    {
    // ********* BREAKPOINT IS SET ON THE NEXT LINE ***********
        validity.LastVerified = DateTime.Now;

        //certificates are only updated within 14 days before expiry date
        TimeSpan tsCheck = validity.NotAfter - validity.LastVerified;
        if (tsCheck.Days <= 14)
        {
            DateTime dtNotBefore = validity.NotAfter.AddDays(conf.validityPeriod());
            if (validity.NotAfter > DateTime.Now)
            {
                dtNotBefore = validity.NotAfter;
            }
            else
            {
                dtNotBefore = DateTime.Now;
            }
            validity.NotBefore = dtNotBefore;
            validity.NotAfter = dtNotBefore.AddDays(conf.validityPeriod());
        }
        return validity;
    }

}

+3  A: 

XSD decorates all generated classes with DebuggerStepThroughAttribute, which prevents the debugger from stopping in a method/class marked with this attribute.

To solve this:

  • Either search and replace all occurences of DebuggerStepThrough attribute
  • Or, In Visual Studio, go to Tools - Options..., scroll to Debugging/General and uncheck the box next to Enable Just My Code
Anton Gogolev
+1 I was just about to answer that but couldn't remember the attribute name lol
Adam
Note that if you make any changes to code-genned files, they will be lost if the file is ever regenerated.
Adam
Anton, you've made my daymany thanks
Bart