部分类调试

发布于 2024-09-07 06:07:58 字数 1169 浏览 1 评论 0原文

我已经为我的 xsd 自动生成的类创建了一个部分类。问题在于调试这个部分类。无法识别断点或者编译器不会在分部类中设置的断点处中断。

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

}

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

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生殊途 2024-09-14 06:07:58

XSD 使用 DebuggerStepThroughAttribute< 装饰所有生成的类/a>,这可以防止调试器在标有此属性的方法/类中停止。

要解决此问题:

  • 搜索并替换所有出现的 DebuggerStepThrough 属性
  • 或者,在 Visual Studio 中,转到“工具”-“选项...”,滚动到调试/常规并取消选中仅启用我的代码旁边的框

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文