metaplex-foundation / SolanaKT

This is a open source library on kotlin for Solana protocol.
MIT License
71 stars 36 forks source link

Annotation Processing Tweaks #38

Closed creativedrewy closed 3 years ago

creativedrewy commented 3 years ago

I was attempting to consume the deserialization in an app and I kept getting the intentional exception even though the annotations were in the classes I was trying to parse. Basically, the code that was throwing the exception was wrong, but also I think I may have originally had the annotation setup wrong.

Anyway, with these changes the code works great when consumed by another app.

ajamaica commented 3 years ago

I might rethink this since it requires user to force an action. I think it might be possible to non make it force and use the order of the constructor to get the order.

What I can to say is that if that is forcing the user to do an action I might prefer go with developer an adapter. Similar to moshi.

What if we do

@BorshCodable class A @Field(order = 0) val x <- Optional

or

@BorshCodable(with adapter) class B val x

class BAdapter

decode() throws x = try.string

creativedrewy commented 3 years ago

Okay if you make that change go ahead and just close this PR and I'll start using those changes.

ajamaica commented 3 years ago

Perfect I just need check it again locally. But is mostly fine