开发VS Code Extension时如何调用dll

How to call a dll when developping a VS Code Extension

我尝试编写一个 SQL 美化器作为 VS 代码扩展。 SQL 美化器 engine/parser 已经作为 .dll 可用,因为我几年前用 C# 编写了它(超过 10K 行代码)。 由于 VS 代码扩展是用 typescript / Javascript 编写的,所以看起来你不能调用 dll 或者我太笨了!?你知道我如何从 VS 代码扩展中调用我的 dll 吗? 谢谢

because I wrote it a couple of years ago in C#

您可以使用 Edge

从 JavaScript (TypeScript) 调用 C# 代码

更多

官方文档https://github.com/tjanczuk/edge

您可以 运行 您的 dll、jar 或 exe 文件,方法是将它们放在资产文件夹中。可以使用 child_process.

来完成
const vscode = require('vscode');
const path = require('path');
const child_process = require('child_process')

let myAppPath = vscode.Uri.file(path.join(context.extensionPath, "assets/myapp.dll"));
let execCommand = `dotnet ${myAppPath.fsPath}`;
child_process.exec(execCommand, (err, stdout, stderr) => {
    if (stdout) {
        vscode.window.showInformationMessage(stdout);
    }
    if (stderr) {
        vscode.window.showWarningMessage(stderr);
    }
    if (err) {
        vscode.window.showErrorMessage("" + err);
    }                           
});