I have a class EventArgs(Of T) in my solution.
This class is located in the namespace Acme.Infrastructure.Interface.
A class with the same name EventArgs exists in the System namespace.
In another project in my solution I have a class Acme.BusinessModules.MyModule.MyClass
When attempting to use the EventArgs class I have to fully qualify the class name or the compiler thinks I am using the System.EventArgs class.
My understanding of namespace resolution was that the compiler would first look for the class in the current namespace, and then its parents. It seems that the compiler checks in System before it checks in sibling namespaces.
Is it correct that System is checked before the sibling? Or is this behaviour caused by other issues (Imports order?)?
Look at the namespaces involved:
Acme.BusinessModules.MyModuleAcme.Infrastructure.InterfaceThere’s no reason why the compiler would look in
Acme.Infrastructure.Interfacewhen compiling a class inAcme.BusinessModules.MyModule. Now if the code you were writing were in (say)Acme.Infrastructure.Interface.SomethingElsethen that would be a different matter – but here it looks like the compiler is doing absolutely the right thing. The fact that both namespaces start withAcmeis neither here nor there.As you yourself said:
The ancestor namespaces here are
Acme.BusinessModulesandAcme– notAcme.Infrastructure.Interface.I would also strongly advise you not to create class names which conflict with those in
System. It’s really just asking for trouble.