Partial class debugging

爱⌒轻易说出口 提交于 2019-12-10 02:51:58

问题


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;
    }

}


回答1:


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


来源:https://stackoverflow.com/questions/3147938/partial-class-debugging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!