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
[Bug]: Elements are skipped when a ReqIF document has no whitespace between elements #94
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
When a ReqIF document has no whitespace between its elements (minified XML, as some tools write it), the deserializer silently skips elements. There is no error and no log message; the values are simply missing from the object graph.
Seen in ReqIFHeader: with the header written on one line, CREATION-TIME and REQ-IF-TOOL-ID come back empty, while COMMENT and REPOSITORY-ID are read.
Cause
ReqIFHeader.ReadXml (and ReadXmlAsync) loops with while (reader.Read()) and reads each child with ReadElementContentAsString(). ReadElementContentAsString() already moves the reader past the end tag, onto the next node. In an indented document that node is whitespace, so the following Read() lands on the next element. Without whitespace the reader is already on the next element, and Read() moves past it: every other element is lost.
Scope
The same while (reader.Read()) loop is used in about 26 files (header, content, spec types, attribute definitions, attribute values, datatypes, hierarchies, tool extensions, alternative IDs). Which of them read their children in a way that skips the next sibling still has to be confirmed; a test as below will show it.
Proposal
Rewrite the affected loops so that an element read with ReadElementContentAs*, ReadInnerXml, ReadOuterXml or Skip does not get an extra Read(), in the sync and async paths.
Acceptance criteria
A copy of each test document with the whitespace between ReqIF elements removed (whitespace inside XHTML content kept) deserializes to the same object graph as the original, sync and async, .reqif and .reqifz.
Steps to Reproduce
Take a test document such as ReqIFSharp.Tests/TestData/Datatype-Demo.reqif.
Make a copy with the whitespace-only text nodes between ReqIF elements removed, e.g. XDocument.Parse(text).ToString(SaveOptions.DisableFormatting).
Deserialize both and compare the header: in the copy CreationTime is 0001-01-01T00:00:00 instead of 2017-03-13T10:15:09.017+01:00, and ReqIFToolId is empty.
Activity
[Fix] read THE-ORIGINAL-VALUE of XHTML attribute values; fixes #95 (#99)
[Fix] skip elements in a foreign namespace instead of reading them as…
[Update] remove references to GitHub issues from code comments
[Add] AttributeValueXHTML.ExtractNormalizedTextFromValue for plain te…