我可以为 C# 制作自己的 JIT\Interpreter\Compiler 并在 Visual Studio 中使用它吗?

Can I make my own JIT\Interpreter\Compiler for C# and use it in Visual Studio?

我目前正在编写一个编译器,它可以从 C# 生成类似 JIT 的 EXE(重写自身),是否可以使 Visual Studio 和它的调试器识别我想要构建它的方式(使用我的编译器)并调试输出?

我的编译器输出的是EXE,但是里面没有MSIL,里面有我的中间语言,剩下的内容就是用C++写的JIT。 (C++ 读取 itself\EXE 并执行)

我很清楚让它兼容并不神奇;我来这里是为了尽可能得到一个直接的答案和开始的提示;例如使用此类函数和参数编写一个 C++ DLL,并将 DLL 路径提供给 Visual Studio 的调试器参数,或者只是指向我在 MSDN 上的参考。 (我从 Google 得到了零个有希望的结果)

看来你想做的事是可以的。 MSDN 的相关部分是:

The Visual Studio integrated development environment (IDE) provides the user interface (UI) for standard components, such as compilers, editors, and debuggers. Features like Visual C++ and Visual Basic that are included with Visual Studio are themselves extensions of the IDE. The Visual Studio SDK provides tools, samples, wizards, designers, and documentation that helps you develop your own applications that extend the IDE and integrate seamlessly with it.

特别注意:

Visual Studio includes a fully interactive source code debugger, providing a powerful and easy-to-use tool for tracking down bugs in your program. The debugger has complete support Visual Basic, C#, C/C++, and JavaScript. However, with the Visual Studio SDK, that is available from the Microsoft Download Center,, other programming languages can be supported in the debugger with the same rich features.

另请注意 Language Services 部分 - 这描述了向 visual studio 添加对新语言的支持的方法。特别是,您还可以为该语言添加调试支持。

参见:Language Service Support For Debugging

The type of compiler determines what you need to do to implement debugging for your language. If your compiler targets the Windows operating system and writes a .pdb file, you can debug programs with the native code debugging engine that is integrated into Visual Studio. If your compiler produces Microsoft intermediate language (MSIL), you can debug programs with the managed code debugging engine, which is also integrated into Visual Studio. If your compiler targets a proprietary operating system or a different runtime environment, you need to write your own debugging engine.

强调我的 - 即:你 可以 调试你想要的任何东西,但你需要自己编写调试器。

您可能需要下载 Visual Studio SDK