Make namespace configurable for folder
The namespace for new files created are automatically determined by the folder structure.
This often creates a problem if you wish to make a logical group of files (by placing them in a folder) that is not supposed to be a new namespace.
Creating the folder and moving the files is not a problem, but the trouble starts as soon as someone uses 'add class' on the folder.
Now the new file does not sit in the same namespace as the other files in the folder.
One example would be to use a folder to store partials of a big class:
it would be nice if I could assign [=>MyBigClassPartials<=] to the same namespace as the root,
So that new files end up in the correct namespace.
Michael Paterson commented
Think of the App_Start folder that is popping up all over the place. Also, I like to keep extension method classes in an Extensions folder but would really like to have the namespace be the root namespace. Great idea.
Jens Melgaard commented
Although resharper adds this, ill vote for it here as ReSharper stores it in its files rather than in the project file, so we often experience it switching on and of...
Juraj Juhás commented
Yes, of course, the project folder properties (editable using Properties window) will be the best choice... .
Jan Kučera commented
This does not belong into the code. I would prefer to set it as a property of the folder, as suggested in https://connect.microsoft.com/VisualStudio/feedback/details/372405/allow-default-namespace-for-solution-folders
Juraj Juhas commented
I'm voting for this idea.
It can be nice to have property like "IsNamespaceProvider" on folders in C# (VB) projects.
If this property will be set to true (default value), than, if I add new class into this folder, folders's name will be automatically added to the class namespace (the same behavior as today). If the value of IsNamespaceProvider property will be false, than new class will be placed into the namespace of parent folder (or project namespace for the 1. level folder).
It can be usefull if I want to place classes to the same namespace, but, I want to place files into the separated folders. I can do it now, but, I have to always remember, that I need to remove folder name from the namespace in all files (.cs, .designer.cs, .xaml, etc.).