Open SeeminglyScience opened 6 years ago
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 :)
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 aDebugInfoGenerator
object as a parameter, but it looks like that can only mark sequence points forLambdaExpression
s. In a quick search I haven't found a way to use theDebugInfoExpression
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, andyield
enumerables significantly easier to implement.All of that assumes that the
C#
vscode extension can even handle being directed at a.ps1
file.