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
[Bug]: JSON round trip of DTOs loses non-derived members redefined by a derived property (memberElement, memberName, source, target) #424
The JSON round trip of the Core DTOs loses the values of non-derived properties that a subclass redefines with a derived property. A client that reads a model back through SysML2.NET.REST gets the empty GUID (or null) for them.
KerML declares Membership::memberElement, memberName, memberShortName and Relationship::source / target as non-derived. Subclasses redefine them with derived properties, for example OwningMembership::ownedMemberElement redefines memberElement. In the generated DTOs these members are explicit interface implementations whose setter does nothing; they read a derived field with an internal setter. For example, in SysML2.NET/Core/AutoGenDto/OwningMembership.cs:
Guid IMembership.MemberElement
{
get =>this.ownedMemberElement;set{}}
There are 173 such no-op setters across 90 DTO classes: IRelationship.Source 48, IFeature.IsVariable 47, IRelationship.Target 19, IMembership.MemberElement 19, IMembership.MemberName 19, IMembership.MemberShortName 19, ISubsetting.SubsettingFeature 2.
Consequences:
Write: a DTO built by hand cannot carry these values, so the serializer sends "memberElement": {"@id": "00000000-0000-0000-0000-000000000000"}. The values are correct only when the DTO comes from a POCO through the Dal ToDto(includeDerivedProperties: true).
Read: the JSON deserializer does not read these keys back. For example, SysML2.NET.Serializer.Json/Core/AutoGenDeSerializer/OwningMembershipDeSerializer.cs ignores memberElement, memberName, source and target, and the DTO could not store them anyway. After a round trip they hold Guid.Empty, null or an empty list.
Compare: the generated comparers, for example SysML2.NET.Extensions/Core/AutoGenDtoComparers/OwningMembershipComparer.cs, do not compare these members, so no existing test notices the loss.
Steps to Reproduce
Run the Flexo integration scenario of #407 (SySML2.NET.REST.Tests/Integration/FlexoModelScenarioTestFixture.cs, category Integration). Step 2 commits OwningMembership, Membership, NamespaceImport, MembershipImport and Annotation elements whose payloads carry the correct references; the recorded requests contain no empty GUID. Reading them back gives, for every membership:
OwningMembership af81e848-… lost its memberElement Expected: 77ea1ae5-… But was: 00000000-0000-0000-0000-000000000000
OwningMembership af81e848-… lost its memberName Expected: "Nested" But was: null
NamespaceImport 8f61e128-… holds empty references: Relationship.Source
Activity
fix #424