-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add DeepCopy capabilities for DynamicObj #35
Comments
Additionally, |
for reference, this blocks nfdi4plants/ARCtrl#478 |
This has been a gigantic rabbit hole, and the solution is not very satisfiying, but we at least have some Deep copy capabilities in #42 . It is i think impossible to return a completely copied result though, as we do not have enough knowledge about boxed dynamic props to deep copy any type/class (and there might be ones that cannot be deep copied anyways). I have settled on a "good enough" approach for now. |
So typed objects without a "Copy" method will result in a "DynamicObject" with the same fields? |
Yes but Note that this is a draft PR. I think there is a point to be made that static properties should be copied as well. That way, we can "recover" the derived class if needed. I think there is no other way for this method. This is the 'try maximum nested deep copy' method. I think as long as this is well documented everything is fine. |
Oh, so currently only the dynamic properties are copied? Shouldn't it be a simple addition to copy the static fields too? E.g. decided by an optional boolean parameter? Yes, there is no secure way to deep copy classes, even via Reflection. You can never be sure how the constructor is meant to be used. |
yes, but alas, this is a draft PR i'll let you know when it is ready to be reviewed ;) |
Note that this will not be closed via #42, combine still needs work afterwards |
CopyDynamicPropertiesTo
and DynObj.combine
Closed via #42 |
Update: renamed this issue so we can focus on the combine rework in another one: #43
Both should do the same (or there needs to be a
_.combine
instance method), and i think they should be adapted to not mutate any of the 2 objects but rather return a new object.The text was updated successfully, but these errors were encountered: