I have a problem regarding the name resolution of a type called Action. While the project was in an early state and everything was declared in the same project the compiler always preferred my own class. However since it has become necessary to separate the project into different assemblies (i.e. ProjectName.Common, ProjectName.Engine, etc.) a naming conflict between System.Action and ProjectName.Common.Action arised.
I found out that I can explicitly import the project internal namespace inside of the namespace declaration of any project file, while System is still imported in the global scope as initially created by the IDE. In fact this works but does not look very elegant. Is there a better approach to solve this problem? Renaming my Action class is not really an acceptable solution, since it is quite a common domain-name and not anything special like i.e. Math etc.
Code Example:
using System;
...
namespace ProjectName.Engine {
using ProjectName.Common;
class SomeClass {
private Action action;
...
}
}
Maybe someone knows a recipe for those kind of naming conflicts …
Consider placing your
Actionclass in the rootProjectNamenamespace instead ofProjectName.Common. If you do that, then inside theProjectNamenamespace or any subnamespace,Actionwill refer toProjectName.Actioninstead ofSystem.Action, and you won’t have to addusingdirectives to all your other source files.