I'm debugging a massive legacy code containing huge file size, bad encapsulation, mixing inheritance, etc.
For example, there is class with _age field:
public class User
{
private int _age;
//...
}
There are many execution paths that change _age: via Property, base class, protected methods, so on.
How I can suspend execution once this _age has been changed to examine stack trace? IDE does not allow putting breakpoint on this field declaration line. I'm wondering whether Rider IDE has an option for this goal? Or maybe there is some practice/workaround to achieve it.
CodePudding user response:
What you are looking for is called a data breakpoint. You can find instructions on how to use them here.
CodePudding user response:
Apparently, Rider supports data breakpoints (see the other answer), but if they're not available (e.g. VS, older versions of .NET), you can always temporarily change the field into a property like:
private int _age
{
get;
set;
};
then you can set breakpoints as usual (on set, get or both).
Your statement "... via base class, protected methods, so on." confuses me a bit. How can a private field be accessed via a derived class' base?
