Name Can Be Simplified - Visual Studio
Asked Answered
T

1

9

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
Torchier answered 12/4, 2017 at 9:3 Comment(1)
Resharper (jetbrains.com/resharper) should help you.Garrick
I
18

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.

Insertion answered 12/4, 2017 at 9:23 Comment(2)
okay, found that! But with this solution I still need to check all documents for possible simplifications right?Torchier
Well yes, that's why i mentioned Resharper. If you can identify your most used namespaces, it can add them to your documents for you and subsequently do the namespace simplification. For more pinpoint refactoring you would have to add the using statements yourself, then simplify the names. Maybe you could create some Visual Studio macros to do that for you ?Insertion

© 2022 - 2024 — McMap. All rights reserved.