Repository navigation
[Add] methods to build a ReqIF document in code; fixes #85 - #109
Merged
Merged
Conversation
- add ReqIF.Create, the Create... methods on ReqIFContent for every datatype, spec type and spec element, DatatypeDefinitionEnumeration.CreateEnumValue, SpecType.CreateAttributeDefinition and SpecElementWithAttributes.CreateAttributeValue (an overload per kind), and AddChild on Specification and SpecHierarchy; each sets a valid identifier, LastChange and the back-references - add Identifiable.CreateIdentifier and Identifiable.MarkAsChanged - validate the arguments: mandatory long names, elements of another document, an element without a type or a definition without a datatype, values outside their datatype, and XHTML that cannot be a value - read the XHTML TheValue and TheOriginalValue without trimming them - write infinite real values as INF and -INF instead of Infinity, which is not a valid xsd:double - add CreateElementsTestFixture and CreatedDocumentQueriesTestFixture Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- AttributeValueXHTML.EnsureValidValue -> ValidateXhtml - ReqIFContent.EnsureSameContent -> ValidateSameContent - SpecElementWithAttributes.EnsureValueCanBeCreated -> ValidateValueCanBeCreated 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.



Fixes #85.
What changes
_+ GUID) and aLastChangeof now.ReqIF.Create(title): a document with a header and a content.ReqIFContent.CreateDatatypeDefinition…for all seven datatypes,CreateSpecObjectType,CreateSpecificationType,CreateSpecRelationType,CreateRelationGroupType,CreateSpecObject,CreateSpecification,CreateSpecRelation,CreateRelationGroup.DatatypeDefinitionEnumeration.CreateEnumValue,SpecType.CreateAttributeDefinitionandSpecElementWithAttributes.CreateAttributeValue, with an overload per kind.Specification.AddChildandSpecHierarchy.AddChild.Identifiable.CreateIdentifier()returns a validxsd:ID;Identifiable.MarkAsChanged()setsLastChangeto now.CreateAttributeValuethrows when the element has no type (InvalidOperationException) or the definition has no datatype, is not an attribute of the element's type, already has a value, or the value does not fit its datatype (range, max length, enumeration literals, multi-valued);xhtml:divorxhtml:proot; an undeclaredxhtmlprefix gets itsxmlns:xhtml, andxhtml:objectelements get theirExternalObject.Infinity, which is not a validxsd:double; it is now written asINF/-INF, as the datatype limits already were.Notes for the reviewer
TheValueandTheOriginalValueare now read as they are in the document; before, whitespace at the start and end was trimmed, so a document read and written again could differ. Listed under Changed, not marked breaking; code that comparesTheValueor checksStartsWith("<xhtml:div")on an indented document will see the leading whitespace.VALUESonRELATION-GROUP, so such a document is not schema-valid. Documented in the XML docs and the changelog.CreateDatatypeDefinitionRealaccepts NaN limits, andReqIF.Create(null)writes an emptyTITLE.Review recommendations not addressed here
A pre-PR review (code reviewer and test-gap finder) made these recommendations; they are left out of this PR on purpose:
ReqIF.Create(null)being written with an emptyTITLEand valid against the schema, sync and async;CRLFline breaks before the root, not forLFor a loneCR;new Specification().AddChild(...)) is never tested, and the test for an element of no document only asserts that nothing throws;MaxLengthcounts UTF-16 code units.Tests
CreateElementsTestFixture(40 tests): every create method and overload, every error path, schema validity of built, empty and extended documents (sync and async), a full write/read round trip, and infinite real values.CreatedDocumentQueriesTestFixture: allReqIFSharp.ExtensionsQuery*methods on a document built only with the new methods (the issue's acceptance criterion).dotnet build ReqIFSharp.sln -c Release: 0 warnings.dotnet test ReqIFSharp.sln: 688 passed.🤖 Generated with Claude Code