I suggest you ...

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:
[=>Folder root<=]
MyBigClass
[=>MyBigClassPartials<=]
MyBigClass_SetUp
MyBigClass_Update
MyBigClass_OtherStuff

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.

64 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    I agree to the terms of service
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    KabwlaKabwla shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    5 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      I agree to the terms of service
      Signed in as (Sign out)
      Submitting...
      • Michael PatersonMichael Paterson commented  ·   ·  Flag as inappropriate

        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 MelgaardJens Melgaard commented  ·   ·  Flag as inappropriate

        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ásJuraj Juhás commented  ·   ·  Flag as inappropriate

        Yes, of course, the project folder properties (editable using Properties window) will be the best choice... .

      • Juraj JuhasJuraj Juhas commented  ·   ·  Flag as inappropriate

        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.).

      Feedback and Knowledge Base