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

OrderedItemList is not properly cloned. Assembler preserves the state… #59

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

IevhenIkonnykov
Copy link
Contributor

… of OrderedItemList.

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the CDP4-SDK code style guidelines
  • I have provided test coverage for my change (where applicable)

Description

It looks like Assembler preserves keys of OrderedItemLists properly, but once an OrderedItemList is cloned then a clone gets absolutely new keys that are not synchronized with the original object. Two tests are added to prove this. An example of where OrderedItemList is cloned here. It is clear that it adds new items and for each new item a new key is generted. That is why keys are not synchronized.

@samatstariongroup
Copy link
Member

@IevhenIkonnykov do you propose we refactor the cloning of the OrderedItemList so that keys are preserved?

@samatstariongroup
Copy link
Member

I've done some looking at the code, and indeed, the clone method of for instance PossibleFiniteStateList. I noticed that the GenericClone method (on line 171) does the the following:

clone.PossibleState.AddRange(this.PossibleState.Select(x => x.Clone(true)));

the AddRangemethod indeed generates new keys. I think in this case we should not use AddRange as is. Perhaps we can add a Clone method to the OrderedItemList and use that one instead. Whatever the fix, it will involve code generation (not a problem of course).

@IevhenIkonnykov
Copy link
Contributor Author

I also think that adding a clone method to OrderedItemList and regeneration of existing code is a better solution.
I am curious how OrderedItemList is handled now in IME if clone produces new keys. There should be some workaround. Maybe it is elegant and I could use it in the sample app. Could you point me to the code where I could see it?

@samatstariongroup
Copy link
Member

I don't think we do any special handling in the IME. We just do a clone, add that to the Operation/Transation and that's it. It seems that what is happening now is that we are sending new keys to the server every single time we update a Thing that has a property of OrderedItemList<T>. Which is not correct as you have spotted and we need to fix.

@@ -0,0 +1,41 @@
using CDP4Common.EngineeringModelData;
Copy link
Member

Choose a reason for hiding this comment

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

missing header

@@ -0,0 +1,41 @@
using CDP4Common.EngineeringModelData;
using NUnit.Framework;
Copy link
Member

Choose a reason for hiding this comment

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

using statements go inside namespace

@alexatstariongroup alexatstariongroup added this to the sprint 0 milestone Oct 22, 2019
@alexatstariongroup alexatstariongroup merged commit e710a11 into development Oct 23, 2019
@samatstariongroup samatstariongroup deleted the OrderedItemListCloneProblem branch October 28, 2020 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants