Little API gem for legacy methods

Daniel Cazzulino posted a little gem about evolving an API without breaking client code.

This is a simple, yet very elegant idea - moving "old" methods out into a legacy dll and use extension methods to attach them to the original class. That way new users of the API are not automatically exposed to legacy implementations and existing client code can simply reference the new legacy dll to obtain the legacy functionality.

To make this available simply by referencing you would need to ensure the namespace within the legacy dll matches the original namespace (e.g. Something.MyProduct and not Something.MyProduct.Legacy).

But, I hear you R#ers cry, Resharper would continually complain that namespace does not match the location!

Never fear, if you look at the properties window of a folder in visual studio with resharper installed, you will see a "Namespace Provider" property. When you set this to false, an entry is placed in the Something.MyProduct.csproj.resharper file that will stop those namespace/location warnings: e.g.

<Configuration>
  <NamespaceFolders>
    <SkipFolder>E73F41D0-727C-4243-8BAA-21321E922934/d:something/d:folder</SkipFolder>
  </NamespaceFolders>
</Configuration>

This file can also be checked into source control as it is a project specific config and not a user one. Happy coding!



1 comments:

  1. Vivian January 16, 2009 at 9:31 AM

    Nice Blog J!