Is it possible in Visual Studio 2010 to break on anything (a method for example) that changes an object’s property?
Or is it possible to find out if object properties changed in an ASP.NET Webforms application?
Update:
Correct answer can be found at: http://stackoverflow.com/questions/2682613/cant-set-breakpoints-on-an-auto-property-setter-why/6713920#6713920
If you have control over the code that declares the property, then certainly you can put a breakpoint inside the setter. Even if it is currently an auto-implemented property, e.g.:
you can easily change it like this:
If the value is actually a field instead of a property, you can still change it into a property to achieve the same thing.
If you don’t have access to the code that declares the property, then it’s quite a bit harder. Personally what I do is this, but it’s a bit laborious:
Declare a public static field in your
Programclass of the type that declares the property.Early in the program, find a reference to the object whose property value changes and put that reference in this static field. If necessary, use Reflection to retrieve private fields.
Add
global::MyNamespace.Program.MyField.ImportantPropertyto the Watch window while debugging.Step through the code until the value in the watch window changes.