Reputation: 4192
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
?
Upvotes: 7
Views: 167
Reputation: 51339
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).
Upvotes: 7
Reputation: 161773
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.
Upvotes: 6