Add 'Namespace does not correspond to the file location' to Code Cleanup

I've recently had to undertake the task of separating all the business logic of a website from a website project and move it into an external DLL and part of the process requires me to update all of the namespace declarations in each class in the new DLL. I've been using Resharper's code assistant 'Namespace does not correspond to the file location' to make these updates a little simpler, but this is an extraordinarily tediuous process given the shear number of files. I would really love to see this option added to the Code Cleanup options if possible.

Any chance we might see this addition at some point?

8 comments

Have you tried renaming the namespace itself, rather than trying to move each file to the new namespace?
Right-click the namespace declaration in any file, refactor->rename.  This will of course affect everything that R# knows about that is in that namespace. I suggest un-loading the web project before doing this, so that you don't inadvertantly change those namespace declarations as well.

0

I am trying to rename a project full of Namespaces, not just one file. Moving the file is only part of the operation. If I use Reflector>Rename on the Namespace that is the same as using the code inspection helper- I'd simply like to automate it so I can run code cleanup on the whole project and have it update every single namespace that violates "Namespace does not correspond to the file location".

0

Hello,

This cannot be added to Code Cleanup because it's not a safe operation in
any sense. It's a refactoring that affects many other files, some of them
potentially being in another solution. The Code Cleanup has been designed
to be safe to run at any moment to neat up the files without affecting the
semantic of the code. Unsafe transformations are not promoted to Code Cleanup.

There're plans to add a feature that helps with laying out files in folders
and classes in namespaces, but the details on its schedulle are not yet available.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Ah that certainly makes sense! Is this something that could be achieved with a plugin? If so where do I grab the plugin SDK for version 4.5?

Thanks!

0

Hello,

Ah that certainly makes sense! Is this something that could be
achieved with a plugin? If so where do I grab the plugin SDK for
version 4.5?


Certainly, a plugin could do this.

There're a few materials on the http://www.jetbrains.net/confluence/display/ReSharper/ReSharperPluginDevelopment
Wiki page.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

That link doesn't seem to work correctly (Page Not Found). Do you have one that works?

0

Hello,

There're some formatting problems when transferring the community newsgroup
contents to the Web forums mirror.

See ReSharper Plugin Development on http://www.jetbrains.net/confluence.


Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”


0

Perhaps I am confused.  I think you have a project with M namespaces and N classes per namespace, and you are trying to rename everything.  Using the code inspection helper you will have to touch M*N files manually.  Renaming the namespace affects all members of that namespace, so you will only have to touch M namespaces.  Not ideal, but far better.  I agree that a feature to automate this would be nice, but that it should not be part of code cleanup.

0

Please sign in to leave a comment.