question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change default namespace associated to a folder when creating new class

See original GitHub issue

This issue has a corresponding ticket on Developer Community. Please vote and comment there to make sure your voice is heard.


It would be nice if there is a feature to set a default namespace for each folder when creating a new class. For example, if we have the following file structure:

MyProject
     MyFolder
          MyClass1

Then if we create MyClass2 under MyFolder, the created class will be under the MyProject namespace instead of MyProject.MyFolder.

Additional references: https://stackoverflow.com/questions/1317901/change-default-namespace-when-creating-class-in-folder-visual-studio

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:75
  • Comments:37 (14 by maintainers)

github_iconTop GitHub Comments

20reactions
drewnoakescommented, Aug 26, 2019

To paraphrase, the request is to be able to mark a folder with metadata to stop it from participating in namespace construction.

19reactions
MhAllancommented, Nov 17, 2020

This is not flexible

<ItemGroup>
  <Folder Include="Models\" IsNamespaceProvider="False" />
</ItemGroup>

Should be

<ItemGroup>
  <Folder Include="Models\" Namespace="whatever I want or empty" />
</ItemGroup>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Change Default Namespace when creating Class in Folder ...
Right click on the project, go to properties and under the 'Application' tab there is a 'Default namespace' field. Note that this doesn't...
Read more >
Sync namespace and folder name - Visual Studio (Windows)
Place your cursor in the namespace name. · Press Ctrl+. to trigger the Quick Actions and Refactorings menu. · Select Change namespace to...
Read more >
Creating a class in a non-namespace provider folder will ...
Create a new folder (called 'Folder') in a C# solution. ... under the namespace name and suggests that I change it to 'DefaultNamespace'....
Read more >
Adjust Namespaces | JetBrains Rider Documentation
This command is a bulk fix that helps you synchronize namespaces with folder structure in any scope, which can be as large as...
Read more >
Adjust Namespaces | ReSharper Documentation
To assign a shortcut, go to Tools | Options | Environment | Keyboard and find the ReSharper_RefactoringsAdjustNamespaces command. This command ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found