I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. In order to use new classes (framework or third-party) in my .cs
file, I need to
project.json
and then using
statement to my .cs
file.It seems that there should be a better way to import new functionality that doesn't involve searching for the right NuGet and the correct namespace. Any suggestions?
To find and install a NuGet package with Visual Studio, follow these steps: Load a project in Solution Explorer, and then select Project > Manage NuGet Packages. The NuGet Package Manager window opens. Select the Browse tab to display packages by popularity from the currently selected source (see Package sources).
Well, once I got my IntelliSense issues figured out (Visual Studio Code on Mac), I don't have to type using
statements anymore. OmniSharp-based IntelliSense is smart enough to suggest (Cmd + .
on Mac) adding them for me:
I still have to add a NuGet dependency manually, but I think this is the default behavior in the full Visual Studio too and you need ReSharper to get smarter than that.
Unfortunately, as far as I know of, the short answer is no.
Visual Studio Code is meant to be a light weight editor, so does not have support for the kind of feature you are describing out of the box. The full Visual Studio on Windows does have support for that. When you type the name of a class/type you want to use, eg. JsonConvert, it will detect that the missing type is available on NuGet and offer you the ability to download the correct package and add the using statement. (In the screenshot I already have the NuGet package installed, so it only needs to add the using statement)
This feature is available in the Community edition of Visual Studio, which you can download for free from the visualstudio.com website. This does require you to run Windows, so I'm not sure if you consider this an option.
Now on the wishful thinking side: VS Code does support extensions these days and it has the power of the Roslyn engine, so theoretically someone could write an extension that will offer this functionality in the future. You could also try getting it added to the core editor, by opening an issue on GitHub: https://github.com/Microsoft/vscode/issues I'm afraid neither of these will really help you in the short term though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With