microsoft / ClearScript

A library for adding scripting to .NET applications. Supports V8 (Windows, Linux, macOS) and JScript/VBScript (Windows).
https://microsoft.github.io/ClearScript/
MIT License
1.79k stars 149 forks source link

Allow for AwaitDebugger but don't pause on first #589

Open BinarySpike opened 3 months ago

BinarySpike commented 3 months ago

For performance/quality-of-life reasons, I'd like to wait for a debugger to attach, but not pause directly after. See: https://github.com/microsoft/ClearScript/blob/1ba26876fc9dc1dd290fac657914cc1a8cf4c487/ClearScriptV8/V8IsolateImpl.cpp#L737C1-L737C25

Would adding a flag and skipping the identified line be a reasonable way to implement this?

ClearScriptLib commented 3 months ago

Hi @BinarySpike,

I'd like to wait for a debugger to attach, but not pause directly after.

Interesting. Can you describe a situation in which this capability would be useful? To put it another way, why is AwaitDebuggerAndPause problematic in your case?

Would adding a flag and skipping the identified line be a reasonable way to implement this?

Well, we wouldn't want to make the API too clunky – e.g., AwaitDebuggerAndPause | DontActuallyPause 😅. Perhaps we could deprecate AwaitDebuggerAndPause and replace it with a pair of new flags.

Thanks!

wysisoft commented 3 months ago

@BinarySpike Hey Nathan small world its Todd, what you using ClearScript for?

BinarySpike commented 3 months ago

why is AwaitDebuggerAndPause problematic in your case?

Two issues, first if I Thread.Sleep(5000) before the execution, the debugger attaches during the sleep and the execution never pauses. Second, if I put a breakpoint deep in my code, it pauses at the beginning and I have to hit continue to reach the next breakpoint—this is just really annoying.

replace it with a pair of new flags.

That would be my preference. Seems the logical solution.

@BinarySpike Hey Nathan small world its Todd, what you using ClearScript for?

@wysisoft ! Mostly looking at it for a hobby project. However, I'm looking at exposing a partial API of our application layer so that we can implement configurable business logic. We have a system that manages tons of files & folders and each tenant uses the system differently. Being able to deploy a tenant, then build them a script where they can enter properties, then hit a button and the script creates files, creates folders, and applies permissions based on their specific needs would be chefs kiss 😗👌

DavidBal commented 1 month ago

Hi,

i would also like this.

Kind regards, David