Skip to content
This repository has been archived by the owner on Feb 8, 2022. It is now read-only.

Add interface implementation of IMessage to Froto.Serialiation to make code gen have less dependencies #91

Open
7sharp9 opened this issue Aug 15, 2018 · 6 comments

Comments

@7sharp9
Copy link
Collaborator

7sharp9 commented Aug 15, 2018

    type IMessage =
        abstract member SerializedLength: unit -> uint32
        abstract member Serialize: ZeroCopyBuffer -> unit
        abstract member ReadFrom: ZeroCopyBuffer -> unit

Currently when you are generating code you have to make a dependency on Froto.serialization which if fine, its the serialization lib after all, but then you also have to include Froto.codec too as you have to have a concrete interface or rely completly on SRTP which is not always easy and gets rapidly more complex if you have to add reflection into that mix. Having the interface as a hard reference in Froto.Serialization means you can more or less eliminate Froto.Codec from the type provider implementation and any custom code gen, which is what I have been doing. Ive been whittling away Froto.Codec but now Ive come to the point where the basic interface implementation of IMessage needs to have a home.

@7sharp9
Copy link
Collaborator Author

7sharp9 commented Aug 15, 2018

Basically this:

type Message() =
member this.SerializedLength =
let buffer = NullWriteBuffer()
this.Serialize buffer
buffer.Length
abstract Serialize: ZeroCopyBuffer -> unit
abstract ReadFrom: ZeroCopyBuffer -> unit

Becomes an interface defined in Froto.Serialzation

@7sharp9
Copy link
Collaborator Author

7sharp9 commented Aug 15, 2018

The Message implementation can still live in froto/TypeProvider/Core/Message.fs just it implements the interface, then other code generators have a point or reference implementation.

@7sharp9
Copy link
Collaborator Author

7sharp9 commented Aug 29, 2018

Any thoughts @ctaggart / @jhugard

@7sharp9
Copy link
Collaborator Author

7sharp9 commented Aug 29, 2018

Basically I just want that interface in the first comment to be defined here.

@jhugard
Copy link
Collaborator

jhugard commented Aug 31, 2018

Sounds quite reasonable. Should IMessage also define a WriteTo?

@7sharp9
Copy link
Collaborator Author

7sharp9 commented Aug 31, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants