Skip to main content

Import Missing Namespaces

Purpose

This refactoring locates types with missing namespace references and adds “using” directives. It relies on Visual Studio to retrieve the namespace list.

Note

This refactoring is available in Visual Studio 2019.

Availability

This refactoring works inside a selected code block with missing namespaces or for active code elements.

How to Use

  1. Select a code block with missing namespaces or place the caret in an active code element.

  2. Press the Ctrl + . or Ctrl + ~ shortcut to invoke the Code Actions menu.

  3. Select Import Missing Namespaces from the menu.

import-missing-namespaces-item

After execution, this Refactoring adds the using directives for each type with a missing namespace reference.

import-namespaces