How can I view compose value classes like `Offset`...
# compose
u
How can I view compose value classes like
Offset
in the debugger? It's giving me the long, and I only see the
x,y
components after I evaluate the expression, which is super annoying
r
That's the way. To avoid allocations offset packs x and y in a Long. You can probably create a renderer in the IntelliJ debugger to make them easier to read
u
The problem seems to be that the renderer "context" where I'd format it my way, is java. And java doesn't seem to see the value class constructor (?)
Copy code
object OffsetDebug {
    @JvmStatic
    fun createOffset(long: Long): String {
        val offset = Offset(long)
        return "Offset(x=${offset.x}, y=${offset.y})"
    }
}
So I had to expose a static java method like this and this is now callable in the renderer and works....but it took a while to figure out
r
Value classes are just static functions at the bytecode level. There's no constructor etc. And unless you need boxing the type isn't used. It's just a long all the way through
u
Yea.. its just not a great debugging experience out of the box
1
i
Is this issue relevant for you? https://youtrack.jetbrains.com/issue/IDEA-335220
I think the custom type rendered is workaround here, and debugger should show a convenient
x, y
representation because the
Offset
overloads
toString
u
yes, the type appears as the raw type in debugger also
offset.toString
is not ideal, as it rounds up the values for some reason (i.e. small x,y appear as
Offset(x=0.0, y=0.0)