orlandos-nl / BSON

Native Swift library for BSON (http://bsonspec.org)
https://orlandos.nl/docs/mongokitten/articles/bson
MIT License
108 stars 36 forks source link

Added support for setting BSONDecoder.userInfo #44

Closed neallester closed 6 years ago

neallester commented 6 years ago

This change enables application developers to set BSONDecoder.userInfo. A test was added in BSONCodableTests and it passes on High Sierra but it appears that none of the BSONCodableTests run on Linux so it has not been run there.

Joannis commented 6 years ago

From our conversation on slack:

Anything in the above that does not get fixed before merging should get an issue on github after merging.

neallester commented 6 years ago

I wrote a test which deserializes an object with the attributes in the following pattern and it passes. I thought I had found all the locations where the BSONDecoder is created and passed along the userInfo, although it’s certainly possible I missed some.

var customType: CustomTypeUsingUserInfo var other: OtherEntity var customType: CustomTypeUsingUserInfo

So it looks like userInfo is passed back up.

I don’t have an immediate need for encoders so I didn’t implement them.

Neither of the v6 branches I tried gave me passing tests. Which branch should I submit an updated pull request (with the additional test) on?

Joannis commented 6 years ago

@Obbut We should have a look at this tuesday

Obbut commented 6 years ago

The new en/de-coders in BSON 6 should already support this. As for the behavior of passing back up, I think we should look at the behavior of the Foundation encoders, and copy that.

Edit: sorry, I accidentally pressed "close & comment" instead of comment 😬

neallester commented 6 years ago

I found a work around for the minor SPM bug which was preventing me from working against my own forked version of BSON which includes this patch. I'm finding some small additional changes which will be required in the patch so at this point it makes more sense to wait until I finish this work and I can then resubmit the patch updated or maybe just skip straight to v6.