Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static interfaces, remove AdHoc Encoding. #132

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

gusty
Copy link
Member

@gusty gusty commented Nov 12, 2022

This will take advantage of static interfaces, which is the natural way of conding the IEncoding interface.

The question is what do we do with codec for interfaces which uses Ad-Hoc Encoding which relied in an instance to call the interface methods.

@@ -577,7 +579,9 @@ module TestInterfaces =
Assert.StringContains ("", "brand", stjCarJson)
Assert.StringContains ("", "brand", stjGCarJson)

do ICodecInterface<IVehicle>.RegisterCodec<AdHocEncoding, Truck> Truck.ObjCodec
do ICodecInterface<IVehicle>.RegisterCodec<Fleece.SystemJson.Encoding , Truck> Truck.ObjCodec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@wallymathieu
Copy link
Member

My feeling is that you could register multiple for the subset that you care about, why ad hoc encoding might be less useful in reality.

@wallymathieu
Copy link
Member

There was surprisingly few changes that I had to do in order to get it working with a sample project:
wallymathieu/auctions-api-fsharp#38

@gusty
Copy link
Member Author

gusty commented Nov 13, 2022

Well it seems only one in the code: Decode.Fail.propertyNotFound prop (o |> map (fun x -> x :> IEncoding)).
Which makes sense, because the old code was definitely wrong, the function should had always take care of the cast for you.
Actually I think if you used the 0.10.0 release you could had removed it.

@wallymathieu
Copy link
Member

I'll try it then 👍

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

Successfully merging this pull request may close these issues.

None yet

2 participants