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

前端 未结 8 738
野趣味
野趣味 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:32

    I'm not a big fan of nested projects, since it buries projects deep inside a structure and if you need to reuse that project in another application then what do you do, copy/paste the code? I like to follow somewhat of a flat structure but organized by namespace.

    This is how I do it:

    - DataHelpers\
    ---Factory\
    ---DataAccess\
    ---...
    - Components\
    --- EmailProcessor\
    --- ErrorLogger\
    - Desktop\
    --- WindowsApp1\
    - Services\
    --- WindowsService1\
    --- WindowsService2\
    - WebApps\
    --- WebApp1\
    --- WebApp2\
    

    Now, inside each major application I have, for example:

    - WindowsService1\
    --- WindowsService1\ (this contains all *.cs, bin, obj, etc and .csproj file)
    --- Solution\ (this contains the .sln file where you link to other projects like ErrorLogger, etc)
    

    I hope that makes sense!

提交回复
热议问题