Repository navigation
Description
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
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,ReadOuterXmlorSkipdoes not get an extraRead(), 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,
.reqifand.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
CreationTimeis0001-01-01T00:00:00instead of2017-03-13T10:15:09.017+01:00, andReqIFToolIdis empty.
System Configuration
- reqifsharp version: ReqIFSharp 10.1.2, and
developmentat c5dc6b2 (after [Fix] read ReqIF documents whose elements use a namespace prefix (#87) #93) - Environment (Operating system, version and so on): Windows 11
- .NET Framework version: .NET 10
- Additional information: Found while writing the tests for [Bug]: A ReqIF document with a prefixed root element (reqif:REQ-IF) is read as zero documents #87.
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…