Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to have a namespace with an alternative name?

Using VB.net, I have a namespace which I'd like to rename for the future. However, I'd also like to keep the old obsolete namespace for a time to ensure backward-compatibility for our consumers for awhile. Is there a way in .NET to have two namespaces, one ordinary and one that merely is an alternative name for the other?

In other words, I would have two namespaces with duplicate classes and modules. Obviously, I could copy all the code, but I really want to do something like

<Obsolete("Use types in namespace MyCompany.Area.ProjectName instead.")>
Namespace MyCompany.WrongArea.WrongProjectName
    Inherits Namespace MyCompany.Area.ProjectName
End Namespace

(A C# answer would be nice too, if you have it.)

like image 756
Patrick Szalapski Avatar asked Dec 06 '25 13:12

Patrick Szalapski


1 Answers

Perhaps you could look at something like namespace aliasing.

See: http://www.devx.com/tips/Tip/34419 for example

like image 177
AshtonKJ Avatar answered Dec 09 '25 01:12

AshtonKJ



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!