Trying to implement NotifyAutoPropertyChanged in ccisharp

Topics: ccisharp
May 28, 2010 at 1:22 AM
So far I've managed to get it to generate the OnNotifyPropertyChanged method, and rewrite simple property setters (i.e. auto-properties). The few tests in the project for this mutator all appear to pass. However, I'm having a bit of trouble figuring out how to implement the notify on more complex setters. My plan was to search for a static method call on the setter, and replace it, but I haven't found a nice way to do that. I can find the function call easily enough if I scan the IL, but rewriting the code seems to require quite a bit of code just to patch up all the offsets (i.e the ILMutator.cs sample). On the other hand, patching the code would be easy as a SourceMethodBody, but I cannot figure out how to scan the method body in this mode without specifically handing nearly every single IStatement type (or using reflection). Am I missing something? Is there an easy way to do this that I'm just not seeing?
May 30, 2010 at 4:14 AM

I guess I was missing something.  There was a Visit(MethodCall) override that I missed.  Annoyingly, Visit(IPropertyDefinition) doesn't recurse into the getter and setter method bodies, but it isn't too hard to work around.