Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper - how to import all missing namespaces?

I replaced the usage of an extension method with Find-Replace, because Resharper unfortunately could't replace it properly. Now, I have 4000 errors in the solution, and all of them are because the namespace for the new method is missing, so I'm in a desperate need of a "fix/import all missing namespaces in the solution" functionality.

Does Resharper or some other tool have such a thing or I'm going to spend the next hours going through the files, pressing ALT+ENTER?

like image 920
Kornél Regius Avatar asked Feb 13 '23 03:02

Kornél Regius


1 Answers

Been there, done that.

This might be not the most elegant way, but it worked for me and took like 10 minutes on a massive project. I've used global replace tool and added using MyApp.Domain.Required.Namespace to the top of all files. Then used R# on all the files to cleanup namespaces: select project in Solution Explorer, hit Ctrl+Shift+R and select "Adjust namespaces".

But do a checkin/shelf/stash whatever with your version control so you can roll back. It took me a few attempts before I got R# to cleanup namespaces correctly.

like image 127
trailmax Avatar answered Mar 16 '23 05:03

trailmax