Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you add prefix to namespaces that ReSharper's "Adjust Namespaces" generates?

I'm working on a Unity/C# project where none of the files have namespaces. I like the idea of not having to manually add namespaces, and I like the idea of namespaces (somewhat) matching the folder structure. However, at the moment, using ReSharper's Adjust Namespaces causes namespaces of the type Game, Network, etc, which can obviously cause problems with other namespaces.

Is it possible to somehow tell ReSharper to use a prefix (e.g. "projectname.", "companyname.", "com.company.project.", etc) for the randomly generated prefixes? Or do we actually have to put all the files in anther folder just to get this structure (a bit like what you'd do in Java, I guess)?

like image 368
Svend Hansen Avatar asked Sep 12 '25 05:09

Svend Hansen


1 Answers

ReSharper uses the project's default namespace as prefix to the folder names.

So maybe it's enough for you to set this default namespace to your desired prefix and use "Adjust Namespaces" again.

To set the default namespace:

  • right click on the project item in the project explorer
  • choose "Properties..."
  • on the project's property page, choose "Application" on the top left
  • set "Default namespace" to your desired prefix

In Unity projects you'll have to set the "root namespace" in the Unity projects settings (as OP pointed out himself):

Edit -> Project Settings -> Editor -> Root namespace
like image 54
René Vogt Avatar answered Sep 13 '25 17:09

René Vogt