I'm not joking. The Visual Studio debugger's side effect I'm about to discuss caused my dismissal during my probation period.
Some of you (including my ex-manager) may not be aware of this controversial behavior in Visual Studio's IDE debugger: during debugging sessions, hovering over a property in the code triggers the property's getter.
Consider this example:
public class SomeObject(){
public string AProperty{
get{
Console.Beep();
}
}
}
var so = new SomeObject();
var x0 = so.AProperty;
When you hover over AProperty
, the getter executes and makes a beep sound.
Hard to believe, but that's it.
(In my code, the getter was responsible for filling a list. I had set a breakpoint on the line
var x0 = so.AProperty;
My manager expected AProperty
to be empty at the breakpoint, but hovering over it the debugger showed the full list.
This led my manager to believe there was a mistake in my code. It was not possible to let him believe that was a known behavior of the debugger, not a coding error.
The worst part of all this was that my effort to explain what was going on was interpreted as a kind of insubordination and ultimately fired me.)
The lesson? Be cautious when using the debugger. What you see in the debugger might not always reflect the true state of your application, especially when dealing with properties with complex getters (and some kind of managers).
Top comments (0)