Giter Site home page Giter Site logo

vscode-scriptcs-executor's Introduction

C# script executor (scriptcs for Visual Studio Code)

VS Code extension for running C# snippets using scriptcs.

Pre-requisities

scriptcs should be installed on your machine.

Usage

Snippet

  1. Highlight a snippet of C# code
  2. Press CMD+shift+r (Mac) or Ctrl+shift+r (Linux, Windows) to run the code. Alternatively, press F1 and choose Execute with scriptcs option
  3. A new scriptcs window will pop up, with your script output.

Whole file/script

  1. Just set focus to a window with C# code. Do not highlight anything.
  2. Press CMD+shift+r (Mac) or Ctrl+shift+r (Linux, Windows) to run the code. Alternatively, press F1 and choose Execute with scriptcs option
  3. A new scriptcs window will pop up, with your script output.

Building

Clone the repo and open in VS Code, then just press F5 to run. This will launch a new instance of VS Code with the extension installed.

Alternatively, you can build from command line. Navigate to the folder with the extension and run:

node ./node_modules/vscode/bin/compile -watch -p ./

Contributing and issues

All the code is on github. Please report any issues or suggestions there.

License

MIT

vscode-scriptcs-executor's People

Contributors

byfe avatar filipw avatar tiesmaster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

vscode-scriptcs-executor's Issues

Feature request: Execute code in REPL terminal

I think it makes a lot of sense to be able to execute code from scriptcs files in scriptcs REPL terminal window instead of using output window. Exactly the same as "F# interactive / FSI" works with fsharp ionide extension, or standalone CShell app. You write code in a file, hit alt+enter, and the code is executed in REPL. I really love the experience, because by writing code in files you have intellisense and all nice features you don't have in simple REPL shell.

I suggest a new configuration value should be added that indicates if you want to send code to output window or REPL terminal.

There are also other useful REPL related features in ionide extension that could be ported to scriptcs runner, like one click importing of all referenced nuget packages to REPL (VS2017 can do that too) etc.

EDIT: I realized this feature can be done also right now by using "Terminal: Run Selected Text In Active Terminal" but the experience is bad => you have to manually start the scriptcs in terminal (it should be started automatically like ionide does), and there is an annoying bug (VS Code or scriptcs REPL) that after every code sent to REPL there is "^J" added to REPL.

image

new release

Latest code must be published as extension.

Output contains random newlines, if it works at all.

Given the following code in a csx file:

for (int i = 0; i < 200; i++)
{
    System.Console.Write(i);
    System.Console.Write(": ");
    System.Console.WriteLine("Hello!");
}

I run that a few times, and I get the following output on successive runs:

0: Hello!
1: Hello!
2: Hello!
3: Hello!
4: Hello!
5: Hello!
6: Hello!
7: Hello!
8: Hello!

9: Hello!
10: Hello!
11: Hello!
12: Hello!
13: Hello!
14: Hello!
15: Hello!
16: Hello!
17: Hello!
18: Hello!
19: Hello!

0: Hello!
1: Hello!
2: Hello!
3: Hello!
4: Hello!
5: Hello!
6: Hello!
7: Hello!
8: 
Hello!
9: Hello!
10: Hello!
11: Hello!
12: Hello!
13: Hello!
14: Hello!
15: Hello!
16: Hello!
17: Hello!
18: Hello!
19: Hello!

0: Hello!
1: Hello!
2: Hello!
3: Hello!
4: Hello!
5: Hello!
6: Hello!
7: Hello!
8: Hello!
9: Hello!
10: 
Hello!
11: Hello!
12: Hello!
13: Hello!
14: Hello!
15: Hello!
16: Hello!
17: Hello!
18: Hello!
19: Hello!

Even with only a single WriteLine I get random newlines in the output, but it won't break up the string. It's only after random Write or WriteLine executions.

Like others have mentioned, sometimes I get no output at all.

VSCode:

Version: 1.52.1 (user setup)
Commit: ea3859d4ba2f3e577a159bc91e3074c5d85c0523
Date: 2020-12-16T16:34:46.910Z
Electron: 9.3.5
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19042

Output from scriptcs remains empty

Hello,

I decided to try scriptcs a go and it really really works great. Executing c# scripts from a terminal is literally a dream. I tried to integrate this into VS Code by installing the scriptcsRunner extension. Sadly this didnt work so great.
I followed the instructions in this guide. I may have missed something, but I tried it a couple of times and no matter what I try the "Output" window for scriptcs remains empty. Even simple one-liners where I write something to the console dont work.

  • I have an empty project.json file containing only "{}" (for code completion with omnishaper) ;
  • I have a script.csx file containing "Console.Writeline("Some string");" ;
  • I can use scriptcs in a terminal (babun) just fine, script runs and I see the output;
  • BUT the output window in VS Code remains empty;

I hope its something stupid on my end.
Regards!

Scriptcs not outputting result.

I'm switching to VS Code from Visual Studio 2015 because VS 2015 is killing my laptop. I'm attempting to run one of my old code on VS Code, but it claims that I have to install scriptcs in order to run C# on it. So I go to do that, and I press F1 and choose Execute with scriptcs, but nothing gets outputted.

OmniSharp intellisense not working

Hi,

I have followed the steps described (created a project.json with just {} in the folder, installed scriptcs, installed the c# VSCode extension) but have no luck.

The OmniSharp logs are giving me the following:

[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Must be able aggregate the response to spread them out across all plugins for /updatebuffer
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /updatebuffer: 500 0ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Must be able aggregate the response to spread them out across all plugins for /autocomplete
[INFORMATION:OmniSharp.Middleware.LoggingMiddleware] /autocomplete: 500 10ms
[ERROR:Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware] An unhandled exception has occurred: Must be able aggregate the response to spread them out across all plugins for /currentfilemembersastree

Am I using the wrong VSCode plugin perhaps? Or a wrong version of dotnetcore?

Where is it ?

Hi,
I've installed this using the extensions tab of vscode. If I try to run HelloWorld.cs all I get is
/bin/sh: scriptcs: Kommando nicht gefunden. <- command not found

So, where is it ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.