Namespaces and folder structures in c# solutions: how should folders on disk be organised?

前端 未结 8 741
野趣味
野趣味 2021-02-04 06:26

First off, let’s agree that namespace should match folder structure and that each language artefact should be in its own file.

(see Should the folders in a solution ma

相关标签:
8条回答
  • 2021-02-04 06:42

    I use the flat approach. I find a nested hierarchy too hard to maintain. I group my projects into several solutions, with maximum reusability and cross-referencing in mind, and always found this satisfactory. Example (projects are indented):

    CompanyName
      CompanyName.Core
        Class1
        Struct2
        Enum3
      CompanyName.Data
      CompanyName.Web
    
    CompanyName.Projects
      CompanyName.Projects.Core
    
    CompanyName.Projects.ProjectX
      CompanyName.Projects.ProjectX.Core
      CompanyName.Projects.ProjectX.Website
      CompanyName.Projects.ProjectX.ToolY
    

    etc. etc.

    Edit: removed nonsense remark

    0 讨论(0)
  • 2021-02-04 06:47

    I have always done the nested hierarchy. It makes it painfully obvious where to add new projects to an existing solution and keeps your namespaces nicely organized on disk. It also makes the deliniation of namespace versus project more obvious.

    0 讨论(0)
提交回复
热议问题