Quick Actions and Refactoring - Extract Method not working

When I select “Quick Actions and refactoring tool” I am not getting the "Extract Method " button.
Is it a keypress or something I am missing? In the video it looks like it just shows up. I have tried right clicking again and a left click. Please explain.
Thanks

1 Like

Hi @CatttDaddy,

You need to make a selection first.

In the case of renaming a method for example, select the existing method name, then right-click and select Quick Actions…

In the case of extracting code to a new method, select all of the code you want to extract, then right-click, left-click on the Quick Actions option, the Extract Method option will appear to the left of the Quick Actions menu.

Hope this helps :slight_smile:

Yeah for some reason I am not getting the bulb after selecting the code and selecting “Quick Actions and refracturing tool” to extract a new method. In the video a light bulb appears to the left where he then selects “Extract Method”. For some reason I am not getting the option to extract the method.
I am using Visual Studio 2017 image

What happens if you try the shortcut keys directly, CTRL+.? (with the code selected)

or
CTRL+R, M?


Updated Fri Nov 24 2017 00:19

Check you are selecting the correct block of code before clicking on Quick Actions… note the brackets in this short video clip;


See also;

Thank you for your help. I’m not sure what happened but I closed VS and opened another lesson on Refactoring from YouTube. When I went back and reopened playermovement.cs it worked. I will say that I don’t get a light bulb but a screw driver. I assume that is because I may be using a later version. Thanks!

1 Like

Hmmmm… Bit odd, no idea about the icon, glad to hear it is working though. :slight_smile:

I’m really not sure myself.
image

In your screenshot you have a closing brace selected.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms