Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellisense for available 'using/import's in C# with Visual Studio Code

Tags:

Edit: Vidual Studio Code and Visual Studio are 2 different things. Yes it's confusing but I know that VS has this feature, I'm asking about VS code.

Is there some extension/setting that makes Visual Studio Code's c# have Intellisense for all available namespaces, including those that were not yet imported, and then imports them when selected?

Example: Collections are not yet imported and I want to type IEnumerable and import it. Being the average programmer this is quite tedious and I might screw up the spelling or capitalization, and then have to press ctrl+.. I would like to just be able to type "ienu" and then IEnumerable would pop up and would be autocompleted and auto imported.

This feature exists for Typescript in VScode (thanks to an extension), and even for C# but in Visual Studio with the Resharper extension.

I have searched everywhere for this feature but it seems to me like it doesn't exist. It honestly feels insane to code without this.

like image 512
Fudge Fudge Avatar asked Dec 28 '18 20:12

Fudge Fudge


People also ask

What is IntelliSense in C?

IntelliSense is a name given to a set of features that make coding more convenient. IntelliSense for C++ is available for stand-alone files as well as for files that are part of a C++ project. In cross-platform projects, some IntelliSense features are available in .

How do you show IntelliSense?

You can trigger IntelliSense in any editor window by typing Ctrl+Space or by typing a trigger character (such as the dot character (.)

What is IntelliSense what are the option inside IntelliSense?

IntelliSense is a code-completion aid that includes a number of features: List Members, Parameter Info, Quick Info, and Complete Word. These features help you to learn more about the code you're using, keep track of the parameters you're typing, and add calls to properties and methods with only a few keystrokes.

How do I enable IntelliSense in Visual Studio?

To access this options page, choose Tools > Options, and then choose Text Editor > C# > IntelliSense.


2 Answers

If you use "C# extension" for VSCode (this https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp)

you can try follow next steps:

  1. Right click on C# extension
  2. "Extension settings"
  3. In opened "Settings" tab, add import in search area
  4. Enable Checkbox (Screenshot of this step)
  5. Enjoy autoimport without "special" extension (Screenshot)
like image 106
Frip Avatar answered Sep 19 '22 13:09

Frip


I just went ahead and made the extension:
https://marketplace.visualstudio.com/items?itemName=Fudge.auto-using#overview
Currently it supports only the base C# libraries but I can make it use additional nugget libraries as well if there is demand for that. As of 24/11/2020 the official C# extension supports this feature, see other answer.

like image 23
Fudge Fudge Avatar answered Sep 19 '22 13:09

Fudge Fudge