Skip to content

[Feature]: Helpers to create and change elements with valid identifiers, LastChange and ReqIFContent references  #85

Closed

Description

@samatstariongroup

What type of issue is this?

  • Bug report
  • Feature request

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of the reqifsharp
  • I have searched open and closed issues to ensure it has not already been reported

Description

Building or editing a document in code is error-prone today:

  • Adding an element to a list such as ReqIFContent.SpecObjects or ReqIFContent.SpecTypes does not set the element's ReqIFContent back-reference. The ReqIFSharp.Extensions query methods then throw, for example InvalidOperationException: The owning ReqIFContent of the SpecObjectType is not set from QueryReferencingSpecObjects.
  • IDENTIFIER is an xsd:ID: it must start with a letter or underscore. A bare Guid.NewGuid().ToString() often starts with a digit and makes the written file schema-invalid.
  • LAST-CHANGE is required by the schema, but nothing sets or updates it when an element is created or a value changes.

Proposal

  • Factory or extension methods (for example content.CreateSpecObject(type), specification.AddChild(specObject), content.CreateSpecRelation(source, target, type)) that set a valid identifier ("_" + Guid), LastChange and all back-references.
  • A way to mark an element as changed, which updates its LastChange, so an editor can update only what changed.
  • Update the wiki page "Writing ReqIF" to use them.

Acceptance criteria

  • A document built only with these helpers is valid against the ReqIF schema, and every ReqIFSharp.Extensions query works on it without setting references by hand.

Steps to Reproduce

var content = new ReqIFContent();
var type = new SpecObjectType { Identifier = "sot-1", LastChange = DateTime.UtcNow };
content.SpecTypes.Add(type);
content.SpecObjects.Add(new SpecObject { Identifier = "so-1", Type = type, LastChange = DateTime.UtcNow });

type.QueryReferencingSpecObjects(); // InvalidOperationException: The owning ReqIFContent of the SpecObjectType is not set

System Configuration

  • reqifsharp version: ReqIFSharp 10.1.2, ReqIFSharp.Extensions 5.2.2
  • Environment (Operating system, version and so on): Windows 11
  • .NET Framework version: .NET 10
  • Additional information: Found while planning editing and export in the ReqIF Viewer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions