Attach VSCode Debugger for Typescript/Javascript Debugging to a C# Winforms Application

Viewed 137

In my C# WinForms application I execute javascript with jint. The javascript code is the result code of my transpiled typescript file. I use inline source mapping.

Now I want to give the users of my application the possibility to debug the javascript I am executing. For that job I want to use VSCode.

The question is, how I can realize that? What I have to do on the c# side? Has anyone done that before?

1 Answers

I'm looking at almost exactly the same scenario (jint and a desire to let users debug their scripts using VS Code) and the answers that I've come up with are as follows:

Low effort

Launch the code using npm, because VS Code already knows how to debug that. Depends on npm being installed and on the path. This is not a big ask in today's world.

High effort

Use Jint.Runtime.Debugger.DebugHandler to integrate with VS Code.

This has the advantage of not being susceptible to differences between runtimes.

It is, however, a lot more work for a small improvement, and like most of Jint despite being high quality work the documentation is lame even by open source standards.

Involving dotnet will make the cross-platform support story a lot more complex. The problem isn't executables for another platform or the need for a different runtime, it's deployment. Probably the most polished solution would be a VS Code extension responsible for installing and configuring platform appropriate dependencies. You could manually satisfy dependencies as for the low effort path but that somewhat dilutes the value of the high effort path.

There is also some risk that this approach depends on unfinished work - see https://github.com/sebastienros/jint/issues/674#issuecomment-735478529

Related