ugorji / go

idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go]
MIT License
1.85k stars 295 forks source link

Generate encoders with canonical support #383

Closed mxmauro closed 1 year ago

ugorji commented 1 year ago

I'm not sure about this commit.

It should be sufficient to just change genStructCanonical = true. Can you try that and let me know if it works well?

Better yet, maybe we should make it a codecgen option. For folks that don't care about Canonical, it bloats the generated code, which has detrimental effects.

@mxmauro lemme know your thoughts please.

mxmauro commented 1 year ago

If I remember correctly, the problem was tisfi was generated from ti.sfi.source() but later, the code generator calls fn twice, one for canonical and then for non-canonical. This causes the j index to be wrong. That's why I added the position.

ugorji commented 1 year ago

Got you.

If you don't mind, lemme try to rework this a bit. Make sure I'm not missing anywhere else that the source index should be used.

mxmauro commented 1 year ago

Of course. Go ahead. 😉

ugorji commented 1 year ago

Fixed at e8f277c38f5c0724e5a7be7dbe09d1a60f0e6010

ugorji commented 1 year ago

Fixed at e8f277c38f5c0724e5a7be7dbe09d1a60f0e6010