Say I have this auto-implemented property in class ClassName: public int Counter{ get; set; }
I have not successfully been able to have a conditional breakpoint on a C# auto-implemented property setter in Visual Studio 2013. Specifically, on the new value being set. (I would like to breakpoint it when it is set to a negative number, for example.)
I know there are other solutions, like breaking out the property so that it isn't an auto-implemented property, or breakpointing all places that set that property. But I would love to just be able to do it without tedious workarounds.
I have successfully breakpointed on an auto-implemented property setter using the following tip from https://stackoverflow.com/a/6713867/119418
Using Visual Studio 2008, 2010, 2012, 2013:
- Go to the Breakpoint window
- New->Break at Function…
For the get, type:
ClassName.get_Counter()
For the set, type:
ClassName.set_Counter(int)
You'll get a "No Source Available" when the breakpoint is hit, but you'll get the calling location in the call stack.