.NET Framework support for compliance with guidelines

One of the biggest issues facing developers of reusable libraries is backward compatibility. When you get to work on version 2.0 or later, you will inevitably regret some of the choices you made in the previous version. Typical issues include:

  • We should have named this method XXX instead.
  • This should have been a method, not a property.
  • We should have put these types in their own namespace.
  • We should have used an enum instead of a bool for that parameter.

Unfortunately, fixing any of these issues could break existing code. Even though you may have very good reasons to change the API, your customers won’t be happy.

I read a suggestion recently to use the Obsolete attribute to aid in the conversion. This class has a Message property that can be used to inform the user of the recommended alternative.

Now, wouldn’t it be nice if, in addition to this message, you could specify the required changes in a formal manner using attributes. With Visual Studio 2005’s refactoring support, it should then be relatively easy to write an add-in that interprets this information and performs the necessary changes for you. This would work only for relatively simple modifications. But it would still be a big help, and make the transition to compliant code a lot easier.