Skip to content

[Fix] keep an explicit IS-EDITABLE="false" when a document is read and written again; fixes #86 - #106

Merged
samatstariongroup merged 2 commits into
developmentfrom
GH86
Oct 22, 2026
Merged

samatstariongroup merged 2 commits into
developmentfrom
GH86

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Fixes #86.

What changes

  • IS-EDITABLE="false" survives a round trip. AccessControlledElement gets a public IsEditableSpecified. It is true when IS-EDITABLE was present in the document that was read, or when IsEditable was set. IS-EDITABLE is written when IsEditableSpecified or IsEditable is true, in the sync and async writers. An element without the attribute is still written without it. IsEditable stays a plain bool.
  • Writing no longer throws with an ALTERNATIVE-ID. IS-EDITABLE (and IS-TABLE-INTERNAL on a spec hierarchy) were written after base.WriteXml, which had already written the ALTERNATIVE-ID child element. An editable or table-internal element with an alternative id therefore threw an InvalidOperationException; this already happened for IS-EDITABLE="true" before this change. Identifiable now has an internal WriteXmlAttributes / WriteXmlAttributesAsync that runs after its own attributes and before ALTERNATIVE-ID; AccessControlledElement and SpecHierarchy write their attributes there. The other subclasses already write their attributes before base.WriteXml and are unchanged.

Notes for the reviewer

  • The issue's example uses the wrong element. The ReqIF schema has no IS-EDITABLE on SPEC-OBJECT; it is only on SPEC-HIERARCHY and the ATTRIBUTE-DEFINITION-* elements, the two AccessControlledElement subclasses. The fix and the tests cover those, and the acceptance criterion holds for them.
  • Behaviour change for code that builds documents. Setting IsEditable = false (for example target.IsEditable = source.IsEditable) now writes IS-EDITABLE="false" where it used to write nothing. Both mean read-only. Set IsEditableSpecified = false to leave the attribute out. Listed under Changed in the changelog.
  • IS-EDITABLE="0" / "1" are read as booleans and written back as "false" / "true"; an empty or whitespace value is treated as absent.
  • Found during review, not part of this change: [Bug]: a spec hierarchy takes the IS-TABLE-INTERNAL of its child #105 (a spec hierarchy takes the IS-TABLE-INTERNAL of its child).

Tests

New IsEditableTestFixture:

  • round trips from .reqif and .reqifz, sync and async, of false, true and absent on spec hierarchies and an attribute definition;
  • every combination of IsEditableSpecified and IsEditable, including values set in code;
  • ALTERNATIVE-ID together with IS-EDITABLE, IS-TABLE-INTERNAL and MULTI-VALUED;
  • empty and numeric IS-EDITABLE values;
  • the MIN, MAX, ACCURACY, MAX-LENGTH and MULTI-VALUED of datatypes and attribute definitions next to an ALTERNATIVE-ID.

dotnet build ReqIFSharp.sln -c Release: 0 warnings. dotnet test ReqIFSharp.sln: 642 passed.

🤖 Generated with Claude Code

samatstarion and others added 2 commits October 22, 2026 08:30
…d written again; fixes #86

- add AccessControlledElement.IsEditableSpecified, set when IS-EDITABLE is read or IsEditable is set; IS-EDITABLE is written when it is specified or true
- write the attributes of AccessControlledElement and SpecHierarchy before the ALTERNATIVE-ID element, through a new Identifiable.WriteXmlAttributes(Async); an element with an ALTERNATIVE-ID that was editable or table-internal threw an InvalidOperationException
- add IsEditableTestFixture

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- rename the local in AccessControlledElement.ReadXml that hid the new isEditable field (S1117)
- let AssertRoundTrip take a MemoryStream (CA1859)
- keep the expected element names in a static readonly field (CA1861)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup
samatstariongroup merged commit 5b67a60 into development Oct 22, 2026
8 checks passed
@samatstariongroup
samatstariongroup deleted the GH86 branch October 22, 2026 06:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: IS-EDITABLE="false" is lost when a document is read and written again

1 participant