Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Partial class debugging

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

}

like image 357
Bart Avatar asked Jun 30 '10 09:06

Bart


People also ask

What is partial class example?

A partial class is a special feature of C#. It provides a special ability to implement the functionality of a single class into multiple files and all these files are combined into a single class file when the application is compiled. A partial class is created by using a partial keyword.

What is the use of partial class?

Partial Class is a unique feature of C#. It can break the functionality of a single class into many files. When the application is compiled, these files are then reassembled into a single class file. The partial keyword is used to build a partial class.

What is partial class in Java?

A partial class, or partial type, is a class that can be split into two or more source code files and/or two or more locations within the same source file. Each partial class is known as a class part or just a part. Logically, partial classes do not make any difference to the compiler.

What is partial class in MVC?

A partial class is one that can be split among multiple physical files. This feature came in C# 2.0. The partial class break the definition of class two or more than two class files, but it will be together at compile time as one class. Now here we will be using partial concept in MVC using entity framework.


1 Answers

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
like image 156
Anton Gogolev Avatar answered Sep 21 '22 23:09

Anton Gogolev