dotnet-script icon indicating copy to clipboard operation
dotnet-script copied to clipboard

Create a VS Code extension

Open filipw opened this issue 8 years ago • 13 comments

We could create a VS Code extension that would streamline some of the scripting stuff:

  • run script
  • run code block
  • init a script + launch.json
  • help with omnisharp.json?

We could even have a terminal-like feature in there to be used with REPL. In the past I experimented a bit with this for scriptcs - here is the ancient repo https://github.com/filipw/vscode-scriptcs-runner

filipw avatar Dec 04 '17 17:12 filipw

Just to summarize what we've got already

dotnet script init

Creates Helloworld.csx, .vscode/launch.json and omnisharp.json

It would be awesome to get a question asking to create these assets in VS Code in case they are missing.

When it comes to running the script from within VS Code that is already there given that we have a .vscode/launch.json file created from dotnet script init

Debug Menu

  • Start Debugging
  • Start Without Debugging

If we should want to do initialization from VS Code, we could simply call into what we already ship today.

seesharper avatar Dec 04 '17 21:12 seesharper

It would also be nice if we had a story for testing scripts. No idea how that would look like yet, though :)

seesharper avatar Dec 04 '17 21:12 seesharper

Yeah the way I see it, most of the extension features would be simply calls into dotnet-script itself (this is what many VS Code extensions do - simply call into the CLI tools). But being able to bootstrap everything from the editor level (command palette, shortcuts etc), as soon as you just create a CSX file would be great.

filipw avatar Dec 05 '17 08:12 filipw

Would it be possible to hook into the editor to provide statement completion for NuGet packages?

#r "nuget: dropdown here to select packages"

Cause that is what I want for Christmas 🎄 😄

seesharper avatar Dec 05 '17 09:12 seesharper

yeah I guess so - while C# for VS Code doesn't do it for the time being, this extension does it for csproj https://github.com/tintoy/msbuild-project-tools-vscode

You could also imagine other features i.e. convert to full C# command line project etc.

filipw avatar Dec 05 '17 10:12 filipw

https://marketplace.visualstudio.com/items?itemName=jmrog.vscode-nuget-package-manager I use this for projects. However it only works with ctrl+shift+p, no drop down and it doesn't work with .csx There is also Paket through ionide

SlowLogicBoy avatar Dec 05 '17 11:12 SlowLogicBoy

for me the most handy feature would be the possibility to run the content of the VS Code editor without creating any "project" (via dotnet script init)

just run VS code, create new file, type some code and run it.

kind of like LINQPad ...

migajek avatar Dec 15 '17 08:12 migajek

@filipw Just briefly started to look into creating an extension for dotnet-script

I was thinking that the very first feature could be running dotnet script init to setup launch.json and omnisharp.json.

We could do something similar to what happens when opening a standard .Net core console app in VS code

image

We could display something like

Required assets to debug and reference inline NuGet packages are missing from 'ScriptFolder'. Add them?

seesharper avatar Dec 19 '17 10:12 seesharper

Guys, really great tool!

Scripting C# is convenient in VSCode because of Code Completion but lacks good REPL.

Some of the immediate wishes for basic REPL in VSCode:

  • to run code per line or selected block from the main code window in VSCode (ideally Ctrl-Enter like in RStudio, or at least F8 in Powershell ISE).
  • to execute ad-hoc code from VSCode terminal in the current session (like RStudio, Powershell ISE). -- kinda workaround would be staying in always-on-debugging and running code from VSCode console. But then we need code completion (including current session variables and functions) and syntax highlighting.
  • to store all the session variables and functions in a session common to both the main code window and the terminal.

Console is convenient for quick "lemme check" REPL but needs Code Completion and Syntax Highlighting (like Powershell or bpython).

I understand that some of this may not be possible with dependencies like OmniSharp Thank you for making dotnet-script such a consistent and modern tool, enjoying it!

ivanakcheurov avatar Nov 28 '18 22:11 ivanakcheurov

I would very much need code completion to make it worth using dotnet script.

jetersen avatar Dec 20 '19 13:12 jetersen

You can use the markdown-preview-enhanced extension to execute code chunks with dotnet-script.

``` csharp {cmd="dotnet" args=["script"]}
Console.WriteLine("Hello babe!");
```

duncanawoods avatar May 04 '20 22:05 duncanawoods

@ivanakcheurov This tool was able to achieve code completion and syntax highlight in the terminal https://github.com/waf/CSharpRepl. I really hope dotnet-script can do it too.

iSeiryu avatar Jan 27 '22 16:01 iSeiryu