title | description | ms.date | ms.topic | author | ms.author | manager | ms.subservice | dev_langs | helpviewer_keywords | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Generate usings |
Learn how to use the Quick Actions and Refactorings menu to immediately add the necessary imports or using directives for copy-and-pasted code. |
03/10/2020 |
reference |
mikadumont |
midumont |
mijacobs |
general-ide |
|
|
This code generation applies to:
-
C#
-
Visual Basic
What: Lets you immediately add the necessary imports or using directives for copy-and-pasted code.
When: It's common practice to copy code from different places in your project or other sources and paste it in to new code. This Quick Action finds missing imports directives for copy-and-pasted code and then prompts you to add them. This code fix can also add references from project to project.
Why: Because the Quick Action automatically adds necessary imports, you don't need to manually copy the using
directives that your code needs.
-
Copy code from a file and paste it into a new one without including the necessary
using
directives. The resulting error is accompanied by a code fix that adds the missingusing
directives.[!NOTE] You need to enable this suggestion in Tools > Options > Text Editor > C# > Advanced > Using Directives.
-
Select Ctrl+. to open the Quick Actions and Refactorings menu.
-
Select using <your reference>; to add the missing reference.