Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to rename a c# namespace in an existing API without breaking users code?

Tags:

c#

assemblies

Is it possible to rename a namespace name in an existing API without breaking users code?

like image 564
Mher Avatar asked Jun 18 '10 14:06

Mher


3 Answers

no, it is not possible. The best you can is to rename namespace in single file: http://msdn.microsoft.com/en-us/library/sf0df423(VS.80).aspx

like image 118
Andrey Avatar answered Oct 13 '22 11:10

Andrey


Is it possible to rename a namespace name in an existing API without breaking users code?

If you change the namespace an object is in, it will break the code that references it.

like image 35
kemiller2002 Avatar answered Oct 13 '22 11:10

kemiller2002


You could generate a bunch of objects in the old namespace that just delegate their calls to the new ones (transparent proxies in effect) and then deprecate the proxy objects at some point in the future.

Maybe pretty horrible depending on the size/complexity of your codebase though.

Better may simply be a non-technical answer of warning your users that an API namespace change is occuring in advance of it being released. Assuming they are actively developing the clients a search/replace is not the end of the world for them.

If there are significant numbers NOT actively developing clients then you'll have to continue a maintenance/bug-fix branch for a while with the old namespace.

like image 40
Paolo Avatar answered Oct 13 '22 10:10

Paolo