Repository navigation
[Fix] read ReqIF documents without whitespace between elements; fixes #94 - #96
Merged
Merged
Conversation
…94 ReadElementContentAsString moves the reader past the end tag. Inside a while (reader.Read()) loop the next Read then skips the following sibling when no whitespace separates the elements, so minified documents lost every other header field and enumeration value, and the spec relations of a relation group were not read or caused an XmlException. - Add XmlReaderExtensions.ReadElementContentAsStringToEndElement(Async), which reads the text content and leaves the reader on the end tag. - Use it in ReqIFHeader, for ENUM-VALUE-REF in AttributeValueEnumeration and for SPEC-RELATION-REF in RelationGroup. - Read SPEC-RELATIONS through a subtree reader. A child other than SPEC-RELATION-REF is skipped with a warning; before, it caused an XmlException. - Add MinifiedDocumentTestFixture and XmlReaderExtensionsTestFixture, and move the shared test-document helpers into TestDocuments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Prerequisites
Description
Fixes #94.
A ReqIF document without whitespace between its elements (minified XML) lost data without an error.
ReadElementContentAsStringmoves the reader past the end tag, so in awhile (reader.Read())loop the nextRead()skipped the following sibling:ReqIFHeaderfield (such asCREATION-TIMEandREQ-IF-TOOL-ID) was empty;ENUM-VALUE-REFof an enumeration attribute value was missing;XmlExceptionwas thrown.Changes
XmlReaderExtensions.ReadElementContentAsStringToEndElement(and...Async): reads the text content of the element and leaves the reader on its end tag (or on the element when it is empty). It throws anXmlException, with line information when available, when the element contains child elements.ReqIFHeader,AttributeValueEnumeration(ENUM-VALUE-REF) andRelationGroup(SPEC-RELATION-REF) use it, sync and async.RelationGroupreadsSPEC-RELATIONSthrough a subtree reader instead ofReadStartElement/ReadEndElement. Only direct children are read. A child other thanSPEC-RELATION-REFis skipped with a warning and the references after it are read; before, it caused anXmlException. The schema allows onlySPEC-RELATION-REFthere.ReadElementContentAs*andReadInnerXmlcalls in the library were checked: each reads the only child of a wrapper element or reads through a subtree, and is not affected.Tests
MinifiedDocumentTestFixture:.reqifand.reqifz;SPEC-RELATIONSlast and beforeTYPE, an emptySPEC-RELATIONS, and an unsupported child (warning logged, nested reference not read), indented and minified.XmlReaderExtensionsTestFixture: text, CDATA and comments, empty elements, whitespace before the element, child elements, wrong position, and the line information in the exception.PrefixedNamespaceTestFixtureintoTestDocuments.dotnet build -c Release: 0 warnings;dotnet test: 436 passed.Found during the review, tracked separately: #95 (
THE-ORIGINAL-VALUEis not read).🤖 Generated with Claude Code