typeshare icon indicating copy to clipboard operation
typeshare copied to clipboard

Use `serde-derive-internals` to process related serde attributes

Open snowsignal opened this issue 2 years ago • 1 comments

Right now we are using hacky workarounds to resolve serde attributes on typeshared types - ideally, we should be utilizing serde's internal attribute parser instead.

snowsignal avatar Feb 14 '23 22:02 snowsignal

@InquisitivePenguin I had a first look at this and it would probably also require #120 to be done either beforehand or together with this task. In my opinion #120 should also be included in the same milestone.

Additionally, moving to syn2 seems like a big endeavor:

  • Since the serde-derive-internals parser seems to be consuming the input, we'd need to perform two parsing passes. One performed by serde-derive-internals, one performed by our own parser.
  • We should mimic a similar structure that serde-derive-internals has i.e. a Container struct maybe implementing the Parse trait, which would parse a given struct or enum and provide accessors to all the required #[typeshare(...)] annotations, both on the whole Container as well as the fields or variants.

After both passes - by serde-derive-internals and our own parser - we'd need to merge both results into a single one based on the struct/enum/field idents.

At this moment I don't see any way to perform this operation in steps. This means that the parser should probably be rewritten from scratch in one go.

czocher avatar Jun 20 '23 07:06 czocher