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
[Feature]: Helpers to create and change elements with valid identifiers, LastChange and ReqIFContent references
#85
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
varcontent=newReqIFContent();vartype=newSpecObjectType{Identifier="sot-1",LastChange=DateTime.UtcNow};content.SpecTypes.Add(type);content.SpecObjects.Add(newSpecObject{Identifier="so-1",Type=type,LastChange=DateTime.UtcNow});type.QueryReferencingSpecObjects();// InvalidOperationException: The owning ReqIFContent of the SpecObjectType is not set
Activity