I am reorganizing my source files into a single solution with a single project, due to various reasons:
- a paranoic configured antivirus software;
- Advices on partitioning code through .NET assemblies
- Control component dependencies to gain clean architecture
- Benefit from the C# and VB.NET compilers perf
This leaves me with many namespaces, which are splitted across multiple files. So far, I am using this convention: given the namespace Company.Project.A, the files are named A.f1.cs, A.f2.cs and so on, and the Company.Project.B namespace is splitted across B.f1.cs, B.f2.cs, etc.
Given the single project restriction, are there any better ways to organize multiple files in multiple namespaces?
Yes – use folders.
If you create a folder within a project, new classes within that folder will automatically use the folder name as the basis for the namespace.
For instance, if you have a project with a default namespace of ‘Company.Project’ and a folder ‘Foo’ containing ‘Bar.cs’ you’ll end up with: