Skip to content

Commit d818dd0

Browse files
momrmedhatessmat
andauthored
Add C# cell executor support in VSCode (#606)
Co-authored-by: M Essmat <messmat.usa@gmail.com>
1 parent d9d1515 commit d818dd0

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

apps/vscode/src/host/executors.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,25 @@ const juliaCellExecutor: VSCodeCellExecutor = {
126126
},
127127
};
128128

129+
const csharpCellExecutor: VSCodeCellExecutor = {
130+
language: "csharp",
131+
requiredExtension: ["ms-dotnettools.dotnet-interactive-vscode"],
132+
requiredExtensionName: "Polyglot Notebooks",
133+
requiredVersion: "1.0.55", // Adjust minimum version as needed
134+
execute: async (blocks: string[], editorUri?: Uri) => {
135+
const extension = extensions.getExtension("ms-dotnettools.dotnet-interactive-vscode");
136+
if (extension) {
137+
if (!extension.isActive) {
138+
await extension.activate();
139+
}
140+
141+
await jupyterCellExecutor("csharp").execute(blocks);
142+
} else {
143+
window.showErrorMessage("Unable to execute code - Polyglot Notebooks extension not found");
144+
}
145+
}
146+
};
147+
129148
const bashCellExecutor: VSCodeCellExecutor = {
130149
language: "bash",
131150
execute: async (blocks: string[]) => {
@@ -147,6 +166,7 @@ const kCellExecutors = [
147166
bashCellExecutor,
148167
shCellExecutor,
149168
shellCellExecutor,
169+
csharpCellExecutor
150170
];
151171

152172
function findExecutor(

apps/vscode/src/host/hooks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function hooksExtensionHost(): ExtensionHost {
5555
switch (language) {
5656
// use hooks for known runtimes
5757
case "python":
58+
case "csharp":
5859
case "r":
5960
return {
6061
execute: async (blocks: string[], _editorUri?: vscode.Uri): Promise<void> => {

0 commit comments

Comments
 (0)