-
Notifications
You must be signed in to change notification settings - Fork 5
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
Migration breaks when using PreserveReferencesHandling #20
Comments
Basically, migrations are not getting called for some serialized objects that happen to be referenced by "$ref" later on. I attempted to fix MigrationConverter.ReadJson to check for ref, and to return the referenced object:
This fix does work to prevent the migration methods from getting called on encountered "$ref" JTokens. However, the migrations DO NOT get called on the initial deserialization of those objects. Just to confirm that there isn't anything wonky with my test data or a fundamental misunderstanding of anything, I implemented a JsonConverter<> to perform the same migrations as I was attempting to do with this lib. For the very same dataset, all JTokens for my class are migrated correctly in order. So there is something about your particular implementation that breaks when using references, besides not detecting/resolving them in Update: |
@Awsmolak hey mate! I rewrote this plugin and made it from 5 to 10 times faster And also added the feature with It has been a while since your comment but I hope you will find the time to check this test case to be sure that I have wrote it correctly ;) Looking forward to getting feedback from you! |
I can't seem to figure out how to resolve object references in a migration method if PreserveReferencesHandling was turned on during serialization. In that case the migrating object's JObject data may have a reference to the object (ex.
"$ref": "123"
) instead of the actual JSON data. Is there a good solution for passing along all the object references from the top of the object graph?Update: I'm pretty sure this is due to a reference loop. I noticed that MigrationConverterSpec.ShouldMigrateTypesWithReferenceLoops() unit test is skipped because "Not a requirement by now".
Any chance you might have some hints to get me started with a PR to add that?
The text was updated successfully, but these errors were encountered: