You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AssignOwnership duplicates the member when an owning membership is re-assigned; no public way to reorder or remove owned relationships #427
ElementExtensions.AssignOwnership(source, bridgeRelationship, target) adds target to the relationship's ownedRelatedElement a second time when the relationship already owns it. This happens on any re-assignment of an existing owning membership, whether to its current owner or to another one.
When target.OwningRelationship == bridgeRelationship, the removal is skipped but the Add still runs. The membership then owns its member twice, so every derivation through it throws. For example, OwningMembershipExtensions.ComputeOwnedMemberElement throws MultiplicityViolationException: "owningMembershipSubject contains more than one element of type IElement". That in turn breaks Namespace::member and everything derived from it.
Repro
varpackage=newPackage();varother=newPackage();varmember=newPackage();varmembership=newOwningMembership();package.AssignOwnership(membership,member);other.AssignOwnership(membership,member);// move the membership to another owner// membership.OwnedRelatedElement.Count == 2, and other.member throws
Related: no public way to reorder or shrink an ownership list
ContainerList, IContainedElement and IContainedRelationship are internal, and OwnedRelationship / OwnedRelatedElement are exposed as IReadOnlyList. So a caller cannot:
remove an owned relationship;
reorder the owned relationships of an element (re-assigning to the same owner keeps the position);
let a relationship other than an OwningMembership or an Annotation own a related element. AssignOwnership(source, relationship, target) rejects it, although KerML allows it: for example the feature chain owned by a CrossSubsetting or a Specialization (KEBNF GeneralType).
How it was found
Step 5 of the Flexo integration scenario of #407 updates the KerML model. Plan §6.1 U4 needs "an ordered collection reordered, extended and shrunk (ownedRelationship of a Namespace)". Only "extended" can be done through the public API today, so the scenario covers that and defers reordering and shrinking to this issue.
Activity
Fix #427: improvmenet on assignOwnership mechanisms
Fix #427: improvmenet on assignOwnership mechanisms
Fix #427: address review on ownership cycle check and sync cost, cap …