jonsequitur / jonsequitur/dotnet-repl

Repl --run Output Notebook Crashes VS Code C# Language Server

Open
#88 1 comment 0 reactions 0 assignees View on GitHub
waiting-on-feedback
Dominant language
C#
Stars
844
Forks
42
PR merge metrics
No merged PRs in 30d

Description

Issue Type: **Bug**

Description: Using `--run` with inputs causes the `ipynb` output file to crash the C# Language Server in VS Code when opening with Polyglot Notebooks v1.0.4403010 resulting in the notebook's Output cells being cleared. Possible fix below.

## Command

```sh
dotnet-repl --run input.ipynb --exit-after-run --input id=1 --output-path output.ipynb
```

## Repro Files

- [Input File](https://gist.github.com/andy-merrick/e54cb527faa5b88522bfbfcd4e5a8530?short_path=41c1c7e)
- [Current `dotnet-repl` Output File](https://gist.github.com/andy-merrick/e54cb527faa5b88522bfbfcd4e5a8530?short_path=8b74537)
- [VS Code Output File - 3rd file](https://gist.github.com/andy-merrick/e54cb527faa5b88522bfbfcd4e5a8530?short_path=28e75ac)

## VS Code C# Terminal Output Error

```sh
[LanguageServerHost]System.InvalidOperationException: didOpen received for vscode-notebook-cell:/c:/Users/xxxxxxxxxxx/repos/polyglot/playground/dotnet-repl-error/dotnet-repl-output.ipynb#W1sZmlsZQ== which is already open. - line 106
at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
...
...
```

## Cause

`dotnet-repl` writes the following json key into the output file:

```json
"language_info": {
"file_extension": ".cs",
"mimetype": "text/x-csharp",
"name": "C#",
"pygments_lexer": "csharp",
"version": "10.0"
},
```

## Fix

Replacing this key with how VS Code writes it results in the `dotnet-repl` file successfully loading in VS Code:

```json
"language_info": {
"name": "polyglot-notebook"
},
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.