⬆️ ⬇️

Debagger went right through: DebuggerStepThrough

Problem


Listen, how annoying it is when you are standing in a debugger on a line like this:

 ReportDefects (processor.Trash);


Do you want to go into ReportDefects, click "step into" and you first get into absolutely stupid

 public ICollection <Defect> Trash
 {
    get {return trash;  }
 }


The first approach to the projectile


There is such a thing called DebuggerStepThroughAttribute :

"... the Visual Studio 2005 debugger does not stop at the method marked with this attribute, but allows you to set breakpoints in this method."



It would seem that what is needed - an net! This attribute cannot be applied to properties.



Decision


As it turned out, attributes — like modifiers — can be applied separately to the getter and to the setter. In principle, it is logical, but not obvious. So, the pants turn into elegant shorts:

 public ICollection <Defect> Trash
 {
    [DebuggerStepThrough]
    get {return trash;  }
 }


Disclamation


No claim to originality, just in order to share experiences.

Got out of here .


')

Source: https://habr.com/ru/post/66365/



All Articles