Posts
58
Comments
103
Trackbacks
10
Tip: Impact Analysis Using the ObsoleteAttribute

Here's a quick trick I like to use when doing impact analysis on changing a type or member.  Instead of using the usual Find All for usages of the item, you can apply the ObsoleteAttribute instead.  By default, it will generate a compiler warning in each place where the obsolete member or type is used.  By setting the Error property to true, you can generate a compile error for each usage.

So, next time you have to make a fairly deep change to the system, and you want a quick way to gauge the impact, I suggest applying the ObsoleteAttribute to the member, setting the Error property to true, and doing a quick compile.  You will very quickly have a nice list of places in the application which will need to be updated.

One word of caution, there is one undocumented "feature" with this attribute.  If you leave it in your code during deployment (with Error property set to false obviously), the XmlSerializer will silently remove the obsolete member from your WSDL (like using the XmlIgnoreAttribute).  Watch out for that if you are working in a system with legacy WebServices.

posted on Friday, July 20, 2007 6:31 PM Print