dimanche 22 février 2015

Organizing namespaces and classes in directories


When I put a class file inside a folder, Resharper suggest me to update the namespace. So if I have the file Classes/Game.cs (Class), it will suggest the namespace MyApplication.Classes.


The problem is that I have a subfolder called Game too, that have components for the Game class. And it is confliting with namespaces. For instance:



/Classes/Game.cs MyApplication.Classes.{Game}
/Classes/Game/Version.cs MyApplication.Classes.Game.{Version}


What is the best method to turn around that?


Currently I'm organizing like that:



/Classes/Game/Game.cs MyApplication.Classes.Game.{Class}
/Classes/Game/Player.cs MyApplication.Classes.Game.{Player}
/Classes/Game/Version/Version.cs MyApplication.Classes.Game.Version.{Class}
/Classes/Game/Version/History.cs MyApplication.Classes.Game.Version.{History}


So note that I rename the "main" class to Class to avoid conflict, but I keep a more accurate name in the filename. But it is ugly, not?





Aucun commentaire:

Enregistrer un commentaire