oleg-shilo/cs-script.vscode

cscs command dont work with C#7

LuckJMG opened this issue · 3 comments

Issue Description

In the command console when I use the cscs command to execute some C# script, it appears to me that there is incompatibility with the "$" sign for string concatenation (this function was set in the C # 6 version), but when occupying the "CS-Script: Run in Terminal" button does work and there are no problems, so I don't know why I usually use the command console instead of the button.
Thank you for your attention, I hope you are well.

CS-Script Log

Error: Specified file could not be compiled.

csscript.CompilerException: c:\Users\Luck\Projects\Demo\Program.cs(10,31): error CS1056: Unexpected character '$'

at csscript.CSExecutor.ProcessCompilingResult(CompilerResults results, CompilerParameters compilerParams, ScriptParser parser, String scriptFileName,
String assemblyFileName, String[] additionalDependencies)
at csscript.CSExecutor.Compile(String scriptFileName)
at csscript.CSExecutor.ExecuteImpl()

Versions

VSCode v1.44.2 (system setup)
VSCode Extension v1.6.4
CS-Script Engine v3.29.0
.NET Core v3.1.2

This is because cscs.exe is the script engine that targets a .NET Full, which lacks compilers for C# syntax higher than v5. Thus you need to enable Roslyn engine for that. See https://github.com/oleg-shilo/cs-script/wiki/C%23-7-support

To check what exactly you are using execute cscs
image

"Run in Terminal" uses a different engine that targets .NET Core, which has support for the latest C# syntax out of box. If you have CS-Script core installed it will be accessible via css:
image

Thanks! Now it works after enable the Roslyn engine, now I can continue with my practice, thank you very much and I hope you are well, greetings!

Glad it helped.
Good luck with your studying. :o)