Wondering if it's possible to have Custom Object Formatter for debugger, since v8 inspector protocol now supports that.
Chrome DevTools now has it: https://medium.com/@paul_irish/debugging-node-js-nightlies-with-chrome-devtools-7c4a1b95ae27
@roblourens
Yeah I've seen that, but it doesn't seem to have gotten a lot of traction. And might be an awkward fit into the vscode way of doing things.
Let's keep this open as a feature request
This is pretty essential to working with immutablejs: https://github.com/andrewdavey/immutable-devtools
Also would be useful for working with MobX: https://github.com/motion/mobx-formatters
Investigating this. Looks like this is where the action happens:
Edit: this probably should happen in the vscode-chrome-debug repo
Then here is the code for immutable formatters:
https://github.com/andrewdavey/immutable-devtools/blob/master/src/createFormatters.js
Also useful for https://github.com/emmanueltouzery/prelude-ts
Adding another use-case: BuckleScript, compiling OCaml to JavaScript. The internal representation of runtime values is very OCaml-specific; but they have a Chrome formatter to aid debugging in Chrome.
It'd be really nice to be able to actually use VScode for debugging BuckleScript projects. /=
I've investigated Custom Object Formatters (aka COF or Human Readable Objects) across different language environments/runtimes and here are the results:
class Formatter {
header(object: object, config): JsonML;
hasBody(object, config): boolean;
body(object, config): JsonML;
}
// ...
window.devtoolsFormatters= [ new Formatter() ]
repr(object) method on class toString() method or separate "Detail Formatter" class[DebuggerDisplay("...โ)] annotation syntax at the top of a classCustom Object Formatters in generic debuggers:
For VS Code the fundamental question is:
can Custom Object Formatting be implemented generically on the VS Code side based on DAP, or is it done inside Debug Extensions (i.e. the Debug Adapter)?
IMO the answer is "no": COF needs to be done in debug extensions. Here is why:
The verdict:
We will not provide COF generically but instead rely on debug extensions/debug adapters to support COF (ideally based on a native COF mechanism).
DAP already provides mechanisms to send hierarchical structures to the debug console, the variables and watches views, and value hovers. These mechanisms can be easily used to support those COF implementations from above that actually support hierarchies (Chrome Dev Tools, C#, C++, LLDB).
I recommend that we add support for the Chrome DevTools COFs to the "Debugger for Chrome". I will create a corresponding feature request.
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!
Hi @weinand - I'm having trouble following the issue chain for this use case. #46829 (which was JS-specific) was closed in favor of this issue which is more generic. But this issue punts the ball back to each language's debugger. Is there a new issue to replace #46829 for the JS debugger?
I'm asking because I'm part of the team that's working on the polyfill for the soon-to-be-Stage3 JS Temporal proposal and we'd like a good way to show a text representation of Temporal objects in the VSCode debugger. My understanding of Chrome's Custom Object Formatters is that they need to be installed on the debugging-console side and opted into by every user, as opposed to letting library authors to control their own objects' string representation in the debugger. The latter is what we are looking for.
@justingrant yes, you are right: our investigation in this issue showed that Custom Object Formatters need to be implemented by individual debug extensions, but consequently we should reopen #46829 .
Most helpful comment
This is pretty essential to working with immutablejs: https://github.com/andrewdavey/immutable-devtools