I can't figure out how to catch the moment when Visual Studio debugger is evaluating my property value in C# code. Breakpoints only work if my code is accessing the property, not Visual Studio debugger (when this property is watched).
My question is: does Visual Studio have a setting or feature which changes the behavior of breakpoints so they become hit (if such breakpoint is located in getter of a property) when Visual Studio debugger shows the value of this property in Watch window (and somehow executing this getter for that)?
I need this for solving my issue (but the issue is NOT my question, it's just to provide some background why I ever needed the feature I'm asking for): for some reason, somehow reading some property of my object by the debugger makes unwanted side effects (causing another property to change). When I do the same in the code (read the properties of the object), nothing like that happens. To locate which property (as I have many dozens of them) causes this effect, I would like to be make breakpoints being hit when debugger evaluates expressions causing my code with these breakpoints to execute.
I couldn't find any feature to enable this in Visual Studio. Am I missing something? Or, maybe, it was added later? I'm on Visual Studio 2008 now.
EDIT: I got downvotes so I need to clarify it again. I'm not seeking assistance with finding the problem in my code (that's why no code here). I'm asking for a very concrete thing. Can I make Visual Studio stop on breakpoints when execution occurred due to evaluating some expression in the debugger. Just that.
public int MyProp1
{
get
{
DoSomething1(); // I want VS debugger stop here on evaluating expression in Watch window
return _value1;
}
}
...
public int MyProp99
{
get
{
DoSomething99(); // I want VS debugger stop here on evaluating expression in Watch window
return _value99;
}
}