Is there a way to have breakpoints hit when the action is caused by the Visual Studio debugger? For example, let's say I have the following (I know you shouldn't do this, just using it for argument's sake):
public class Test
{
int _X = -1;
public int X {
get { return ++_X; } //Breakpoint here
set { _X = value; }
}
}
And:
static void Main(string[] args)
{
Test t = new Test();
t.X = 1; //Breakpoint here
return;
}
If you pause at the breakpoint in Main, every time you "hover" the mouse pointer over "t.X" (assuming you have the following Debugging option enabled - "Enable property evaluation and other implicit function calls") or you evaluate the property in the "watch" window - it will increment the property but the breakpoint in the property's "get" accessor will not be hit. Re-asking the question in a more specific context - is there a way to hit the breakpoint in the property's "get" accessor when the evaluation is done by the debugger?