I've decided to try to learn to code in C#, mostly due to the fact I want to try my hand at deving games in the distant future. However, I now use a Macbook, and so I figured I should use VS Code. However I am unsure of how to actually execute the code once it's done.
C# execution is an add-on to the latest version of VS code. Go to the add-on tab, then search 'c#'. Install the first item on the list.
You can also consider using Visual Studio for Mac, which has C# built-in.
Maybe you can inspire from this tut http://zablo.net/blog/post/run-and-debug-asp-net-core-rc2-ubuntu-16-04
Related
SOLVED
Just to clarify this is about VS code not just VS
I've had the worst 3 hours looking for anything that could possibly fix my Visual studio code. I'm using the program to develop a game on unity but I can't seem to get the auto complete thing (I think its Intellisense) to auto complete my code causing spelling mistakes and making coding 10x longer than it needs to take.
Heres a list of things I have tried:
Install .Net Framework v4.7.1 (which is what the console says to do)
Fix the Assembly file made by unity multiple time
Reinstall Visual studio, C# plugin and .Netframework
Change the OmniSharp to the latest version
I will add that when ever I type anything it comes up with "[info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService Could not find document for file c:\Users\Bruhman\Grinder\Assets\Scripts\PlayerMovement.cs"
and when I open visual studios and write anything in the script it'll come up with an error that states "Some Projects have trouble loading. "Source: C# (Extension)" "
Below is a screen shot of what comes up in the console (It's the same every time)
Console
Never Mind I found out the issue, apparently I need to install Visual Studios Community version and then the .Net developer packs from visual studios and not just online, I'm assuming that it doesn't get detected or something when installed through the exe file...
I don't really know much, but I use it every day : have you tried the unity tools extension ?
It features a lot and also the c# auto completion.
If it still bugs, have you installed the .Net for the EXACT version. I also struggled because I had the upper version and not the exact.
Finally is it linked with unity (I don't know if it could interfere if not done)
Sorry I don't know anything else if this don't work.
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
Manually add a NuGet dependency in project.json and then
Manually add a 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?
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.
Is there C# interactive window for VS 2013, or any other similar way, without installing VS 2012.
I tried C# Repel, C# Snippet Compiler and Mono Command Prompt, but, all of them don't provide the features of C# interactive window packed with Roslyn for VS 2012.
UPDATE: Found a total better alternative!!! Try CShell, it is free and open source! "A simple, yet powerful, C# scripting IDE" as they promote it.
Check my tweet which was also favorited by Scott Hanselman :)
My old recommendation was: LINQPad
Best way is to install VS 2012 and use C# interactive window provided with its Roslyn. While doing that, wait Microsoft to release C# interactive to VS 2013.
This is taken from one of the links above:
http://social.msdn.microsoft.com/forums/vstudio/en-US/0da45fe7-fbe2-4074-b52f-dc8d7c4b2ba3/c-interactive-in-vs-2013
It worked for me, so hopefully this will help the next person :)
Hi SpencerGR,
I just got upgraded to VS 2013 and wanted C# Interactive, and this is
the first hit when I searched for it, so I figured I would place my
answer here...
Didn't make sense to me that the extension from VS 2012 wouldn't work;
so I hunted down the Roslyn keys in my registry for VS 2012 and was
able to kinda figure out what was going on. After a bit of futzing
around, I finally got it working, so here's the instructions for
whoever might care to try [be warned, I'm sure this isn't supported by
MS, I take no responsibility if something happens to mess up your
computer, and so forth ;)].
Basically it was a matter of
copying some registry keys with slight modification copying some files
and this one is annoying but oh, well] there's a file you have to
change the datestamp on (I did it by opening the file in Notepad++ and
saving it out.) If you don't already have VS 2012 or you don't have
the Roslyn CTP installed you'll need to get the files somehow, and I'm
not sure if there are other registry settings needed or not, but I
imagine if you just manage to get the files out of the CTP distro it
would be enough... No guarantees of course.
Not-Instructions-Just-An-Explanation-Of-What-I-Did-I-Am-A-Trained-Professional-...-Or-Something
;)
copying some registry keys with slight modification; I replaced '11.0' with '12.0' in the keys and values, you might need to change
the paths too if you didn't install Visual Studio in it's default
location. (also posted to pastebin.com/XeP5ai8F )
Save this as a .reg file and open it to import the new keys easily:
Windows Registry Editor Version 5.00.
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0\InteractiveWindows\0] "ContentType"="Roslyn C#"
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\InstalledProducts\Roslyn] ""="Microsoft Roslyn CTP" "ProductDetails"="Microsoft Roslyn CTP"
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{c5edd1ee-c43b-4360-9ce4-6b993ca12897}] "Class"="Roslyn.VisualStudio.CSharp.Repl.CSharpReplPackage" "CodeBase"="C:\\Program Files (x86)\\Microsoft Visual Studio
12.0\\Common7\\IDE\\Extensions\\Microsoft\\Roslyn C# Interactive Window\\1.2.20906.1\\Roslyn.VisualStudio.CSharp.Repl.dll"
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\Packages\{f5199a4e-6a60-4f79-82e9-fc92a41c4610}] "Class"="Roslyn.VisualStudio.InteractiveWindow.InteractiveWindowPackage" "CodeBase"="C:\\Program Files (x86)\\Microsoft Visual Studio
12.0\\Common7\\IDE\\Extensions\\Microsoft\\Roslyn Components\\1.2.20906.1\\Roslyn.VisualStudio.InteractiveWindow.dll"
[HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\12.0_Config\ToolWindows\{2d0a56aa-9527-4b78-b6e6-ebe6e05da749}] "Name"="Roslyn.VisualStudio.InteractiveWindow.VsInteractiveWindow"
copying some files; basically just need to copy the files mentioned above to the locations mentioned above; I just copied the
'Common7\IDE\Extensions\Microsoft\Roslyn C# Interactive Window' and
'Common7\IDE\Extensions\Microsoft\Roslyn Components' folders from my
11.0 install to my 12.0 install. easy peasy.
and yeah... there's a file in the aforementioned 'Common7\IDE\Extensions' directory called
'extensions.configurationchanged'; I couldn't get things to take, then
I noticed that file. so, as mentioned, I just opened in Notepad++ and
saved back out; I think I had to make a change to the file, so I added
a space. kinda felt kludgy, but I guess it beats VS taking longer to
load due to having to scan the Extensions every time you open it up.
So, that's it! Worked for me, I hope someone else may find this
useful, as it probably took longer to post this than it did to
actually get it working in the first place. ;) It's possible I missed
a step in here somewhere, since I had made a few other attempts before
I found the 'changed' file, so I could have possibly twiddled another
bit somewhere that was necessary that I don't remember. Should be a
good start tho.
I haven't tested it out fully by any means but it shows up in the
'View > Other Windows' list, it opens up just find, and it looks like
Intellisense is working too. Good luck and great code to all! :)
--- Chelle L.
You could also use LinqPad. You can use it to test C# code. It has built in support for loading DLLs and Nuget Packages. Its what I use personally and I love it.
It has a free version, but the paid version has intellisense and debugger
C# interactive finally arrived to VS 2015... You may need to install vs2015.1 to get it..
http://blogs.msdn.com/b/visualstudio/archive/2015/10/08/visual-studio-2015-update-1-ctp.aspx
Good luck... and happy interactive coding!
IWIH describes how to install it and which prerequisites you need.
Let me give you some
Additional information:
After you have installed VS 2015 and its updates (update 3 KB3165756 patch has just arrived) you can bring C# interactive to your screen as follows:
Either via the menu
View -> Other Windows -> C# Interactive
Or press Ctrl + Q and type into the quick launch box:
C# interactive
which allows you to click on View -> Other Windows -> C# Interactive with the mouse.
Afterwards, you have the C# Interactive beneath the error list. Here is an example how you can use it:
Quickstart:
To get help in this window, type #help and press enter.
To execute a statement, simply press ENTER. To type in multiple lines, press SHIFT+ENTER for each line, and for the last line press ENTER to execute the entire statement.
To print the values of a variable, type its name and press enter (in the screen shot, I have done this for variable q)
I wrote a few VS Extensions and Roslyn seems to be an interesting tool in such endeavors. I would be really curious to try it.
But
Is there a safe way to install it? Can I install it in an isolated hive? How cleanly does it uninstall?
Correct me if I am wrong but the Roslyn compiler replaces the 'Standard' C# compiler. If it breaks the result will be quiet unpleasant
I think this thread should have answers to your questions. When you install the CTP it replaces the C# and VB language services under the 'Roslyn' rootsuffix inside Visual Studio. The 'Standard' C# and VB compilers (including the command line compilers vbc.exe and csc.exe) are not replaced and your regular code editing experience inside VS is left unchanged.
In other words, the intention is that the CTP shouldn't impact your existing setup - but to be sure you could follow Hank's suggestion and install it on a Virtual PC.
This thread also has some discussion around this.
Disclaimer: I work for Microsoft on the Roslyn team.
Yes, it's safe to install. I installed on VS 2012 and it was working fine, but it causes problem when used with Resharper. You can even uninstall it with Tools->Extensions and Updates.
In VB.NET projects, errors are highlighted immediately after cursor leaves the line. In C#, I have to wait several seconds for IntelliSense to highlight it. Also, the C# version doesn't show all project errors in "Errors List", unless you start to build it. Actually, it seems to work differently in every way. Is it possible to adjust that behavior?
I am using both Visual Studio 2008 and Visual Studio 2010.
It's because VB.NET does full background compilation whenever the IDE is idle, so it always has the latest information ready. C# doesn't do this and instead have a separate process that creates the IntelliSense information.
You can't really adjust it without a lot of work or buying some third party tool. It's one of the differences between the languages, the VB.NET team concentrates on certain aspects and the C# team on others.
Though I think some of the addins you can buy (possibly ReSharper and others) are advertising better IntelliSense if you really want it.
When using Visual Basic, Visual Studio instantly compiles the new code, whereas with C#, only syntax errors are highlighted directly, and compile errors after you build the code.