Repository navigation
fix #424 - #437
Conversation
samatstariongroup
left a comment
There was a problem hiding this comment.
The build is clean and all tests pass locally. The JSON side of the #424 fix holds up. Please address the following before merge.
1. ToDto(includeDerivedProperties: false) now computes derived properties and throws on incomplete POCOs
SysML2.NET.CodeGenerator/HandleBarHelpers/PropertyHelper.cs:1517 (WriteRedefinedToDto) and SysML2.NET.CodeGenerator/Templates/Uml/core-dal-poco-uml-extensions.hbs:249. Example output: SysML2.NET.Dal/Core/AutoGenPocoExtension/OwningMembershipExtensions.cs:196-205.
The new lines that copy the redefined members are emitted outside the if (includeDerivedProperties) block, for example:
((IMembership)dto).MemberElement = ((POCO.IMembership)poco).MemberElement.Id;On the POCO these getters resolve to derived Compute* methods:
IMembership.MemberElement→ownedMemberElement→ComputeOwnedMemberElement→OwnedRelatedElement.SingleStrict<IElement>IRelationship.Source→membershipOwningNamespace→ComputeMembershipOwningNamespace, which throwsIncompleteModelExceptionwhen there is no owningINamespaceMemberName→ownedMemberElement.nameReferenceSubsetting.SubsettingFeature→referencingFeature, which throwsIncompleteModelExceptionIsVariable→mayTimeVary(47 classes)
Failure: new OwningMembership { Id = … }.ToDto() did not throw before this PR and now throws IncompleteModelException. The same applies to any Membership subclass or ReferenceSubsetting that is not attached yet. Converting a partly assembled graph, or exporting a subset, therefore fails in the mode that is meant to skip derivation. It also adds derivation cost to every ToDto(false) call.
Fix: in WriteRedefinedToDto, check property.QueryRedefinitionChainEnd(class). When the chain end is derived, emit the line inside the includeDerivedProperties block (where the same storage may already be set), or emit a guarded read.
Test: nothing covers the Dal side today; the only Dal ToDto test uses AnnotatingElement, which this change does not affect. Add VerifyToDto in a new SysML2.NET.Dal.Tests/OwningMembershipExtensionsTestFixture.cs:
- an incomplete
OwningMembershipmust convert as intended (not throw withincludeDerivedProperties: false); - a complete one (Namespace → OwningMembership → named element) must carry
MemberElement,MemberName,SourceandTarget; - a
PartUsagecase showingIsVariableis copied frommayTimeVary.
2. The [Ignore] disables the only Core MessagePack round-trip test
SysML2.NET.Serializer.MessagePack.Tests/SerializerTestFixture.cs:41
Verify_that_iData_from_sysml2_core_json_can_be_deserialized is the only Core MessagePack round-trip check (PsmSerializerTestFixture covers PSM only). Ignoring all of it means a MessagePack regression in any member, not only the members tracked in #436, goes unnoticed until #436 is fixed.
Fix (either):
|
@samatstariongroup I decided to follow, for now, the evidence provided by this sentence, written in the SysML 2 specificaiton : "The property mayTimeVary redefines the KerML property Feature::isVariable, making it derived." |
| @@ -404,12 +404,15 @@ public partial class AcceptActionUsage : IAcceptActionUsage | |||
| /// different value for each snapshot of an owningType that is an Occurrence. | |||
| /// </summary> | |||
| [Property(xmiId: "_2022x_2_12e503d9_1725998273002_23711_212", aggregation: AggregationKind.None, lowerValue: 1, upperValue: 1, isOrdered: false, isReadOnly: false, isDerived: false, isDerivedUnion: false, isUnique: true, defaultValue: "false", isOwnerEnd: false)] | |||
| [RedefinedByProperty("IUsage.MayTimeVary")] | |||
| [RedefinedByProperty("IUsage.MayTimeVary", IsDerivedByRedefinition = true)] | |||
There was a problem hiding this comment.
these annotations serve a purpose to make the DTO and POCO self-documenting. Please add
[RedefinedByProperty("IUsage.MayTimeVary", IsDerivedByRedefinition = false)]
so we make it explicit for all when it is true or false, even if in C# false is the default value (new readerse will not see the IsDerivedByRedefinition = false and might not realize what the full intent of the property is in the abstract syntax
|



Prerequisites
Description
Fix #424
It causes test failure on Messagepack/JSON roundtripping since MessagePack have similar issue (#436)