Skip to content

Dal ToDto/FromDto share value lists (aliasIds, text) between POCO and DTO #428

Closed

Description

@samatstariongroup

Problem

The generated Dal conversions between POCO and DTO assign value lists by reference, so a POCO and the DTO converted from it share one List<string>. Changing the POCO afterwards silently changes every DTO converted from it before, and the other way round.

SysML2.NET.Dal/Core/AutoGenPocoExtension/PackageExtensions.cs:

poco.AliasIds = dto.AliasIds;   // line 61, FromDto
dto.AliasIds = poco.AliasIds;   // line 157, ToDto

The same pattern occurs in every conversion of aliasIds (167 metaclasses) and of the derived text (7). Reference lists are not affected: they are built fresh, e.g. poco.ownedMember.Select(x => x.Id).ToList().

Repro

var package = new Package { AliasIds = ["a"] };
var dto = (SysML2.NET.Core.DTO.Kernel.Packages.Package)package.ToDto(false);

package.AliasIds.Add("b");
// dto.AliasIds is now ["a", "b"]

Impact

A DTO is a snapshot for transport or comparison, but it does not stay one. In the Flexo integration scenario of #407 (step 5), adding an alias to the root package also changed the DTO kept as the expected model of the previous commit:

  • the history check, which re-reads the package at that commit, then reported a false difference on Element.AliasIds;
  • a delta computed against that DTO would miss the change.

Fix

Copy value lists in both directions in the generator, e.g. dto.AliasIds = [.. poco.AliasIds];, and regenerate.

Activity

  1. added
    bug
    on Nov 7, 2026
  2. added a commit that references this issue on Nov 9, 2026
    4893772
  3. linked a pull request that will close this issueFix #428: fix shared list issue #431on Nov 9, 2026
  4. added a commit that references this issue on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions