jsonptr icon indicating copy to clipboard operation
jsonptr copied to clipboard

Fix debug visualization in vscode for `Pointer`

Open chanced opened this issue 1 year ago • 3 comments

Currently this:

let ptr = jsonptr::Pointer::from_static("/example");
let path = std::path::Path::new("/example");

is displayed as: Screenshot 2024-10-03 at 9 42 55 AM

chanced avatar Oct 03 '24 15:10 chanced

I haven't been able to get even a simple definition, such as the following spike, to display:

#![debugger_visualizer(natvis_file = "Pointer.natvis")]

#[cfg_attr(not(doc), repr(transparent))]
#[derive(Debug)]
pub struct Spike {
    inner: str,
}
<!-- Pointer.natvis -->
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
    <Type Name="spike::Spike">
      <DisplayString>{inner}</DisplayString>
    </Type>
</AutoVisualizer>

I also can't seem to find the definition for std::path::Path so I guess it is generated somewhere.

chanced avatar Oct 03 '24 15:10 chanced

I have a question on the forums here about it: https://users.rust-lang.org/t/natvis-for-a-str-newtype/119173

chanced avatar Oct 03 '24 16:10 chanced

It seems Natvis is specific to Windows. I have no idea if it is possible to fix the debug output in vs code on linux/mac.. or windows, for that matter.

chanced avatar Oct 08 '24 17:10 chanced