https://www.alternetsoft.com.au/blog/integrating-script-debugger-into-your-application

INTEGRATING SCRIPT DEBUGGER INTO YOUR APPLICATION

Explains how to use various debugger UI elements such as stack trace, output, breakpoints, watches, debug toolbar and menus.
5 min read

AlterNET Studio includes script debugging engines for various popular programming languages such as C#, Visual Basic, TypeScript, JavaScript, and IronPython.

Script debugger is a non-visual component that provides basic debugging functionality via IScriptDebuggerBase interface, such as Start/Stop/Break/Step Into/Step Over commands and a list of Breakpoints. It also triggers events during step-by-step debugging; for example, when the execution stops, the debugger state changes, or the stack frame switches.

Our three script debugging engines for C#/Visual Basic, TypeScript/JavaScript, and IronPython implement this base interface using a different set of tools - .NET Framework debugging API for debugging C#/Visual Basic, Google Chrome Debugger development tools TypeScript/JavaScript and Microsoft Script Hosting for IronPython.

In addition to the Script Debugger itself, we provide a set of debugger UI widgets for both WinForms and WPF platforms, including Breakpoint, Stack Frame, Output, Locals, Watches, and Threads User controls, as well as Debugger Toolbar and Menus.

These components are used in our AlterNET Studio demo project; however, that demo source code also includes lots of code related to file/project management, form designing, etc., which may create difficulty in understanding how it all works.

So we have decided to develop a simplified quick-start project, demonstrating how debugging logic is glued together.

There are three main components in this demo project:

DebuggerPanelsTabControl - it contains all Debugger user control widgets such as Output, Breakpoints, Locals, Watches, and Stack Frames

DebugCodeEditContainer/DebuggerUIController - these classes are responsible for displaying relevant script code during debugging (as an example, when script execution stops in the source code, DebuggerUIController focuses relevant page containing Code Editor, which displays script text or opens a new page if the script file was not opened yet)

DebugMenu/DebuggerControlToolbar - provide debug menus and toolbars for debug commands such as Start, Stop, Break, Step Into and Step Over.

Integrating script debugger into your application

All the above elements are linked to the ScriptDebugger, but all glue logic is implemented inside them, so there’s little code required to work script debugger application together:

var debugger = new ScriptDebugger
{
 ScriptRun = scriptRun1
};

codeEditContainer = new DebugCodeEditContainer(editorsTabControl);
codeEditContainer.EditorRequested += EditorContainer_EditorRequested;

debuggerControlToolbar1.Debugger = debugger;
debuggerControlToolbar1.DebuggerPreStartup += OnDebuggerPreStartup;

debugMenu1.Debugger = debugger;
debugMenu1.DebuggerPreStartup += OnDebuggerPreStartup;

debuggerPanelsTabControl.Debugger = debugger;

var controller = new DebuggerUIController(this, codeEditContainer);
controller.Debugger = debugger;
controller.DebuggerPanels = debuggerPanelsTabControl;
codeEditContainer.Debugger = debugger;

QuickStart projects showing how to integrate script debugging logic are available for WinForms, WPF, IronPython, and TypeScript.

Dmitry Medvedev
Dmitry Medvedev
We now support the Visual Studio code theme and descendant TextMate color theme, which provides the distinct appearance of outlining sections, guidelines, folded sections, and the current line. It supports dark, light, and all other VS Code color themes.