Skip to content

Commit

Permalink
Add C# cell executor support in VSCode (#606)
Browse files Browse the repository at this point in the history
Co-authored-by: M Essmat <[email protected]>
  • Loading branch information
momr and medhatessmat authored Nov 22, 2024
1 parent d9d1515 commit d818dd0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions apps/vscode/src/host/executors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) => {
Expand All @@ -147,6 +166,7 @@ const kCellExecutors = [
bashCellExecutor,
shCellExecutor,
shellCellExecutor,
csharpCellExecutor
];

function findExecutor(
Expand Down
1 change: 1 addition & 0 deletions apps/vscode/src/host/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> => {
Expand Down

0 comments on commit d818dd0

Please sign in to comment.