Sunday, January 17, 2010

Justin Angel's Automatic INotifyPropertyChanged

Justin Angel has come up with another way to auto implement INPC. This time using low-level IL re-writing in the DLLs in after the project has been compiled. Advantages to this from my perspective are:
  • Minimal intrusion into the application's code;
  • Will work with Prism easily as it does not need to use proxy creators that must integrate with Prism/Unity;
  • No extra dependencies on the project... Sort of... Since there has to be adding of some DLLs that are exectued post-build to tweak the IL;

What I don't like (at this stage at least) is:

  • Bleeding edge example that is probably not ready for production use yet (at one point in the code the comments actually say "This is the worst hack in the history of the known universe"!;
  • I had numerous issues compiling the project, with it locking files, which is no doubt related to the hack mentioned above, as it has to create temporary copies of DLLs in order to tweak the IL;
  • I suspect it will only work for automatic properties, so if the property is made more complex with validation code etc. (as most of ours are, as we perform data validation in our ViewModel property setters - to support Silverlight 3 data validation). This may in fact not be the case, but I spent too much time working with the compilation issues and never got the solution building reliably enough to be able to start modifying the code to find out;

It's still very interesting, and hopefully something more solid will come of it, but at this stage it's not ready for me to start using in our systems.

No comments:

Post a Comment