Search code examples
c#visual-studiorefactoringautomated-refactoring

Name Can Be Simplified - Visual Studio


Is there a way to do all the lightbulb-action for a whole Solution and with a button or a shortcut?

Or to add a using for a term which could be simplyfied but is not shown through a lightbulb?

  • I have multiple Documents which include terms like "System." or "System.Threading."
  • I don't know exactly how many documents I have not checked them all
  • I don't want to use Search & Replace because I don't know how many things could possibly be simplified
  • I want the code to be readable and don't want a unnessecary difficult term to be left in there.
  • No I have not created the mess. I have to use the code which was created by an another person before

Solution

  • If you click the drop down next to the lightbulb, it will give the option to change all the occurences of the simplification in the document, project or solution.

    It looks something like this:

    Image of solution simplification

    Of course, for that to work you will need to add the necessary using statements to your files. I know that resharper has an option for you to add namespaces that should always be imported in your files. If you don't have access to it, can try the free trial they provide and see if it helps you.