I’m really annoyed by the way C# handles partial namespace references. Mainly because I never want to do it. I always specify the full namespace (albeit in a using clause at the top). Sometimes it makes sense to alias a namespace like we do with NHMA = NHibernate.Mapping.Attributes.
I just never have a need to reference other namespaces partially. It seems fraught with peril. Does anyone do this?
So, then, what’s really annoying though is when I don’t change any code, but I add a new folder and a new class in a new namespace, and suddenly all my existing code breaks, because of this stupid namespace approach.
Update: There is a solution, sort of
Well, there seems to be a solution. I stumbled across a quasi-solution while reading this article: C# 2.0: Create Elegant Code with Anonymous Methods, Iterators, and Partial Classes.
I haven’t tested it yet, but apparently I can use the global namespace qualifier, “::”, which indicates that the reference should start at the global namespace (obviously).
So now I just need to update every single using reference to be prefixed with ::? Seems like there is still the potential for collisions.
Annoying.
More info:
How to: Use the Namespace Alias Qualifier (C# Programming Guide)
Discussion
No comments for “C# Namespace Paths are Annoying”
Post a comment