I am building a library in Visual Studio, and I have decided on my namespace structure as CompanyName.Type.Action e.g. MyCompany.Common.DataFile.
In Visual Studio I accomplish this by creating a new solution with name MyCompany.Common and then adding to the MyCompany.Common project the class DataFile.
First of all, this leads to the solution and the project having the same name, which I don’t think is best practice.
Second, I would end up with a lot of files in the MyCompany.Common project, instead of a lot of projects in the MyCompany.Common solution.
I could rename the solution to MyCompany and then have a project called Common, but I would still have a lot of files related to Common inside a single project.
Is this the best way of doing libraries?
How do you guys go about it?
It depends if you’re going to have any other projects within the solution. The solution name really doesn’t matter – most of the time, the solution is just a container for projects. You can have the same project in multiple solutions perfectly easily.
Your project should definitely be
MyCompany.Commonrather than just Common, IMO. Don’t forget that the name of the generated assembly and default namespace are defaulted to be the same as the project name.