I want to force a root namespace on the contents of any .cs source files that don't have their contents wrapped in an explicit namespace
. In other words I want to keep classes and other namespace-level structures out of the default namespace.
(Working inside a Windows .NET environment with Visual Studio)
In the following example, I want to force the Car
class into the MotorIndustry
namespace by default even though it has no explicit namespace coded.
Vehicle.cs (has namespace)
namespace MotorIndustry {
public class Vehicle {
// ...
}
}
Car.cs (no namespace/default)
public class Car : Vehicle {
//...
}
Is there a way to accomplish this "root namespace" modification behaviour through project settings in Visual Studio, AssemblyInfo.cs file or some other means?
My understanding is VB.NET has a feature like this but C# acts differently?
Some context about why am I asking this: I have hundreds of classes and the programmer forgot to wrap the namespace around some. When I reference the assembly from other projects it's polluting the default namespace with classes that end up causing some ambiguous situations.