oleg-shilo / cs-script.vscode

VSCode extension for CS-Script
MIT License
37 stars 7 forks source link

Check syntax in scripts lacking Main method #26

Closed Bukran closed 2 years ago

Bukran commented 3 years ago

Hi, Oleg.

I work with CS-Script in a hosted environment. I find it very usefult to check the scripts syntax beforehand. Otherwise, an exception will be thrown in time of execution.

But VSCode extension always shows 2 errors: the program does not contain any 'Main' static method as entrypoint (translated from spanish). Is there any means to 'inform' the extension: this is not a program, but a single script?

oleg-shilo commented 3 years ago

Not sure I follow. In this example you can see that C# code does not have static main: Are we talking about different things?

Bukran commented 3 years ago

I was trying to check the syntax of the scripts in this sample https://github.com/oleg-shilo/cs-script.core/issues/24 It's like the extension was trying to find a .csproj

csscript-vscode

oleg-shilo commented 3 years ago

Ah, I see. Your are not checking the script (your code is not an executable code) but an effectively class library code.

Well it's not the intended use case but it is a useful one anyway. I am adding to the backlog as an enhancement. Will be available with the next release.

In a mean time you can check the syntax from the terminal window with the following command:

css -cd -check script.cs
Bukran commented 3 years ago

Thank you, that's great news.

oleg-shilo commented 2 years ago

The latest release (v2.0.1) has an additional setting cs-script.extra_args which allows passing CS-Script engine arguments (not script arguments): image

Please note that there is no good reliable solution for your problem.

You can add the -cd arg and then all your scripts will be checked for being able to be compiled into dll. Great but then your executable scripts will not be able to run :(

Meaning that this new setting is something that you can use but I cannot say that it is particularly convenient

Bukran commented 2 years ago

Thanks for the follow-up