Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I quickly resolve namespaces in Visual Studio 2015

Tags:

When I type a method for which the namespace has not been imported, I get a red wavy underline (aka squiggly red line) that indicates there is an error. Using Visual Studio 2012, I can right click this red line and quickly select the desired namespace using Resolve > using System.Text.RegularExpressions from the right-click context menu. I also have the option to fully qualify my method with the complete namespace.

Using Visual Studio 2012:

Visual Studio 2012 resolve namespace options

In Visual Studio 2015 preview, this option is missing from my right-click context menu. Does anyone know how to enable this -or- quickly choose the namespace I want?

like image 815
laylarenee Avatar asked Jan 28 '15 13:01

laylarenee


People also ask

How do I refactor namespace in Visual Studio?

Place your cursor in the namespace name. Press Ctrl+. to trigger the Quick Actions and Refactorings menu.

How do you change the namespace of a project in Visual Studio?

You can change the default namespace: -> Project -> XXX Properties... Instead of Find/Replace, you can also right click the namespace in code and Refactor->Rename.


Video Answer


2 Answers

This menu has been changed and a new feature was added. The original menu item has been replaced by "Quick Actions...", which brings up its own sub-menu where I can find the things I'm looking for such as importing namespaces and refactoring options:

Visual Studio 2015 Quick Actions

like image 101
laylarenee Avatar answered Sep 17 '22 21:09

laylarenee


@dotnetstep is absolutely correct.

For an even faster resolution process:

  1. Place the text cursor on the word that is squiggled in red.
  2. Press Ctrl + . (period).
  3. Hit enter.
  4. Enjoy quick namespace resolution :)
like image 36
N. Taylor Mullen Avatar answered Sep 17 '22 21:09

N. Taylor Mullen