PSLambda icon indicating copy to clipboard operation
PSLambda copied to clipboard

Debugging support

Open SeeminglyScience opened this issue 7 years ago • 1 comments

The largest hurdle towards using PSLambda for anything outside of interactive use is lack of ability to debug. From a glance it doesn't look easy. The LambdaExpression.Compile method does take a DebugInfoGenerator object as a parameter, but it looks like that can only mark sequence points for LambdaExpressions. In a quick search I haven't found a way to use the DebugInfoExpression throughout the expression tree.

A last resort would be to implement my own stack spiller and translate the expression tree into IL. As much as I would absolutely love to do that, maintainability would be quite difficult. That would however also make some things like async/await, class definitions, and yield enumerables significantly easier to implement.

All of that assumes that the C# vscode extension can even handle being directed at a .ps1 file.

SeeminglyScience avatar Apr 30 '18 13:04 SeeminglyScience

Compiling to IL would have been a bust. ModuleBuilder.DefineDocument isn't in netstandard2.0 and even if it was, it would only create Windows PDB's. Meaning it would only work on Windows, and VSCode wouldn't be usable.

That said I had an idea to inject "sequence point" expressions that conditionally reduce to a hook for debugging. Using that it should be possible hook into PowerShell's debugging which would be a better experience anyway.

I say "I had an idea" here but really I'm just ripping off what the PowerShell engine does :)

SeeminglyScience avatar May 03 '18 23:05 SeeminglyScience