Open marspion opened 2 years ago
Hey, thanks! In principle, I'm certainly happy to support ObjectId
🙂 I wonder if this is the right way to handle it though 🤔 Would it be better to have ObjectId
as a backing type, rather than just a serializer? Given you can't use any old string with objectid, the approach here looks like it could have some problems to me..
Hi, I thought about your opinion and you have right. I added ObjectId backing type and modified MongoSerializer to work with all backing types instead of only string and nullable string. Please have a look after changes. If everything will be fine I will implement some unit and integration tests.
Hi, I thought about your opinion and you have right. I added ObjectId backing type and modified MongoSerializer to work with all backing types instead of only string and nullable string. Please have a look after changes. If everything will be fine I will implement some unit and integration tests.
I think that looks much better @marspion, thanks! 🙂
Hello @andrewlock, I added some integration tests. Please verify it in your free time. Thanks!
@andrewlock Thank you for comment! I will correct code as soon as possible based on your review and also I will look up into errors returned from build pipeline.
@andrewlock I am not familiar with snapshots in tests. Do I have to change something before run StronglyTypedIds.Tests or everything should be green?
Thanks @marspion - snapshot testing is a way of confirming the output is what you expect. It's using this library, Verify. Dan Clarke has a good introduction to it here.
When you run the tests locally, the tests will all fail initially, as there aren't any "verified" files. The process to create them is generally:
We currently generate every combination of serializer and attribute etc, so there's a lot of snapshots. You don't have to check every one, just make sure they look about right 🙂
P.S. You can also install the DiffEngineTray tool to make your life a little easier!
If you don't want to/can't get this working, I don't mind taking a look and pushing the snapshots for you to review instead
Thank you @andrewlock for brief summary about test with snapshots! It is awesome!
As you recommended I used DiffEngineTray and I can agree that it is very helpful tool 🙂
To be honest I wasn't able to verify all snapshot files. I randomly verified some of them (different combinations).
I provided some changes to solve your CodeReview suggestions. Please take a look in your free time.
To be honest I wasn't able to verify all snapshot files. I randomly verified some of them (different combinations).
Yeah, there's so many combinations now that's about the best we can do 😆 I think it's going to be best to cut them down in a later PR.
It looks like there's a problem running Mongo2Go on Linux 🤔 Will take a look when I get a chance if you don't get to it first!
I also will try to investigate what's going on with Mongo2Go on Linux
Hi @andrewlock I found some issue on Mongo2Go repository. Probably there is a problem with binaries search pattern on Linux OS (only some versions) but it has not resolved yet. As a workaround with access only to code I was able to override it.
Can you try to run build pipeline? I hope that will solve the problem.
Thanks!
Nice work on the Mongo2Go @marspion. I was just looking through the serializer changes, and I'm not entirely sure whether the serializers are completely consistent? Should we handle nulls explicitly or not worry about them? At the moment I'm concerned we might get null references when deserializing "invalid" values. I need to look through properly, but just to want make sure we're handling all the cases that we could hit 🙂
Hi, pull request is in draft but I would like to know your opinion about my idea for ObjectId support.