From d818dd022d803ea93db34d1a6ccca56a05d54348 Mon Sep 17 00:00:00 2001 From: Medhat Omr <1138835+momr@users.noreply.github.com> Date: Fri, 22 Nov 2024 10:05:12 -0600 Subject: [PATCH] Add C# cell executor support in VSCode (#606) Co-authored-by: M Essmat --- apps/vscode/src/host/executors.ts | 20 ++++++++++++++++++++ apps/vscode/src/host/hooks.ts | 1 + 2 files changed, 21 insertions(+) diff --git a/apps/vscode/src/host/executors.ts b/apps/vscode/src/host/executors.ts index 0fa1a570..fddfe2b5 100644 --- a/apps/vscode/src/host/executors.ts +++ b/apps/vscode/src/host/executors.ts @@ -126,6 +126,25 @@ const juliaCellExecutor: VSCodeCellExecutor = { }, }; +const csharpCellExecutor: VSCodeCellExecutor = { + language: "csharp", + requiredExtension: ["ms-dotnettools.dotnet-interactive-vscode"], + requiredExtensionName: "Polyglot Notebooks", + requiredVersion: "1.0.55", // Adjust minimum version as needed + execute: async (blocks: string[], editorUri?: Uri) => { + const extension = extensions.getExtension("ms-dotnettools.dotnet-interactive-vscode"); + if (extension) { + if (!extension.isActive) { + await extension.activate(); + } + + await jupyterCellExecutor("csharp").execute(blocks); + } else { + window.showErrorMessage("Unable to execute code - Polyglot Notebooks extension not found"); + } + } +}; + const bashCellExecutor: VSCodeCellExecutor = { language: "bash", execute: async (blocks: string[]) => { @@ -147,6 +166,7 @@ const kCellExecutors = [ bashCellExecutor, shCellExecutor, shellCellExecutor, + csharpCellExecutor ]; function findExecutor( diff --git a/apps/vscode/src/host/hooks.ts b/apps/vscode/src/host/hooks.ts index 9c826762..3b0b6965 100644 --- a/apps/vscode/src/host/hooks.ts +++ b/apps/vscode/src/host/hooks.ts @@ -55,6 +55,7 @@ export function hooksExtensionHost(): ExtensionHost { switch (language) { // use hooks for known runtimes case "python": + case "csharp": case "r": return { execute: async (blocks: string[], _editorUri?: vscode.Uri): Promise => {