Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to reverse alias a c# namespace?

Not sure how to phrase this question, but here is the problem.

I have a namespace designed: my.foo.bar

In one of my classes, I accidentally named the namespace my.foo.Bar

I want to fix the namespace capitalization so that everyone is on the same page, but this is a shared library, and I can't afford to recompile all programs using this.

So, is there something I can create that, in essence, redirects my.foo.Bar to my.foo.bar?

like image 646
IronicMuffin Avatar asked Mar 05 '12 18:03

IronicMuffin


People also ask

How do you undo an alias in Mac?

On your Mac, do one of the following: Remove an item from the Finder sidebar: Drag the item out of the Finder sidebar until you see the remove sign . Remove an alias from the Dock: Drag the item out of the Dock until you see Remove. If you remove an item from the sidebar or Dock, only the alias is removed.

Does deleting an alias delete the original?

The Mac counterpart to a Windows "shortcut," an alias can be placed on the desktop or stored in other folders, and clicking the alias is the same as clicking the original file's icon. However, deleting an alias does not remove the original file.

How do I delete an alias loop?

You need to use unalias command on Linux or Unix to remove bash shell aliases. The alias command used to create aliases. It works on bash, ksh, csh and other Unix shells.


2 Answers

Not globally. You can use namespace aliases, but only in the client code. It sounds like you might need to take a breaking change.

One way of doing it, if it is only one or two classes, would be to copy them from my.foo.Bar to my.foo.bar, deprecate the ones in the bad namespace using the Obsolete attribute, and slowly move clients over to the correct ones.

If the class is stateless, then the class in the my.foo.Bar namespace could delegate to the one in the my.foo.bar namespace as @JohnSaunders suggests, but only if client's usage of that class doesn't preclude delegation (everything is a method or a property, that class's Type isn't used via reflection, etc).

like image 144
Chris Shain Avatar answered Oct 12 '22 22:10

Chris Shain


The best you can do is to take all of the types in the badly-named namespace, and create versions of them in the correct namespace. These can delegate to the bad namespace versions.

like image 27
John Saunders Avatar answered Oct 12 '22 23:10

John Saunders