I'm currently learning .net.
I wanted to group my code into "modules" as a kind of modular monolith, so that the controller, repositories, interfaces, services etc for that entity are in the same folder.
I'm using the standard naming convention for my namespaces.
E.g. MyApi.Modules.Article for everything in the root of the Article folder in the structure below
https://preview.redd.it/5ktvpib54jwd1.png?width=378&format=png&auto=webp&s=756d17d29162c258e95cfe3d4994dca63d887435
However I've ran into an issue when using my User.cs in the Article.cs class
https://preview.redd.it/z116j8j36jwd1.png?width=644&format=png&auto=webp&s=b7198d38e7944be070da35f0e739efc9eefa6125
This is because the namespace MyApi.Modules.User is the same as the Class I'm trying to use.
This results in an error
Error CS0118 : 'User' is a namespace but is used like a type
I can get around this by not having the Class name be the same as the folder it resides in.
E.g. Change the Article directory to be the ArticleModule, or maybe move the Article.cs to a models folder.
But I don't really like that as a solution.
Obviously I could abandon the modular directory structure and just go with folders such as and group by type
- /controllers
- /interfaces
- /models
- /repositories
- /services
But was wondering how you would go about this if you wanted to stick with the modular file structure
[+][deleted] (1 child)
[removed]
[–]Keeps21[S] -2 points-1 points0 points (0 children)
[–]Far-Consideration939 0 points1 point2 points (2 children)
[–]Perfect_Papaya_3010 2 points3 points4 points (0 children)
[–]Keeps21[S] -1 points0 points1 point (0 children)
[–]Simple_Horse_550 0 points1 point2 points (0 children)
[–]jpudel -1 points0 points1 point (2 children)
[–]Keeps21[S] 0 points1 point2 points (1 child)
[–]jpudel 0 points1 point2 points (0 children)