How to track changes in object

hi,

I have a function and a object created at runtime. The function takes object as an argument. I don't have control over structure of the object or script of the function.

At execution time the functions changes some fields of the object based on some conditions in script.

My question is,

Is there any way to find the fields of object accessed for modification by the function after it passed through it

Thanks in advance,

Regards,

ralbert.



Answer this question

How to track changes in object

  • RapidLord

    There's no general solution.

    You can't do this even under the debugger either (CLR Debugging doesn't yet support managed data breakpoints)

    Now one technique that you may be able to use is make a copy of the object before you pass it in; and then compare things once the function returns. Obviously, this does not work in the general case. But if you have a simple case (Eg, you want to see if a Point was changed), then it can work.



  • Michael Sims

    Hello Ralbert,

    Without some kind of event/notification interface or support on the object passed to you, there is no straightforward and guaranteed way to determine if an object is changed.

    If you grovel around inside the internal data structures, that may be incorrect due to inheritance, overridden properties/methods, etc..

    Hope that helps,
    Stephen [Microsoft CLR - Security: Developer]
    http://blogs.msdn.com/stfisher



  • How to track changes in object