[Add] uml-like metadata decorators on the model; fixes #27#78
Merged
Conversation
Adds ClassAttribute and PropertyAttribute decorators (plus an AggregationKind enum) under ReqIFSharp/Decorators, modelled on uml4net's Decorators, and applies them to all 54 model classes so the ReqIF metamodel (abstractness, multiplicity, containment vs reference) is self-documenting. Multiplicity and aggregation values are sourced from the embedded reqif.xsd. A reflection-driven ModelMetadataTestFixture guards completeness: it fails if any model class or metamodel property is left undecorated, with a documented exclusion list for container back-references and convenience accessors. The decorators are inert metadata, so serialization behaviour is unchanged.
…id NUnit collision ReqIFSharp.PropertyAttribute collided with NUnit.Framework.PropertyAttribute in the test assembly, requiring a using-alias. Renaming the decorator to ReqIfPropertyAttribute (used as [ReqIfProperty(...)]) removes the collision entirely; the test-side alias is no longer needed. ClassAttribute is unchanged as it has no such collision.
Mirrors the ReqIfPropertyAttribute rename so both model decorators share the ReqIf prefix. Applied to all 48 model classes as [ReqIfClass(...)] and the test fixtures updated accordingly.
Every [ReqIfClass] and [ReqIfProperty] usage now passes all constructor arguments explicitly, including the optional ones that previously fell back to defaults (isOrdered/isReadOnly/isDerived/isDerivedUnion/isUnique/defaultValue on properties; isAbstract on concrete classes). Values are unchanged - this is a readability change so the metadata is self-documenting at the use-site.
|
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.



Summary
Implements #27 — add UML-like metadata to the model classes and properties (as done in the COMET-SDK / uml4net) so that ReqIF metamodel relationships are self-documenting.
Two decorators are introduced under
ReqIFSharp/Decorators, modelled on uml4net'sDecoratorsbut reduced to what ReqIF actually models and prefixed withReqIfto avoid collisions (e.g. withNUnit.Framework.PropertyAttribute):ReqIfClassAttribute(used as[ReqIfClass(...)]) —name(the ReqIF metaclass / XML element name) andisAbstract.ReqIfPropertyAttribute(used as[ReqIfProperty(...)]) —aggregation(containment vs reference),lowerValue/upperValuemultiplicity,isOrdered,isReadOnly,isDerived,isDerivedUnion,isUnique,defaultValue.AggregationKindenum (None/Shared/Composite).[ReqIfClass]is applied to all 54 model classes and[ReqIfProperty]to every metamodel property, with multiplicity and aggregation values sourced from the embeddedreqif.xsd. The decorators live in theReqIFSharpnamespace, so no extrausingis needed on the model classes.Per the issue scope, uml4net's
Implements/Subsetted/RedefinedBy/RedefinedPropertydecorators were not ported — ReqIFSharp has no interfaces or UML generalization-sets to attach them to. AnxmiIdfield was also omitted (ReqIFSharp does not round-trip XMI).Explicit arguments at every use-site
Every decorator usage passes all constructor arguments explicitly — including the optional ones that would otherwise fall back to defaults — so the metadata is fully self-documenting where it is applied:
Concrete classes carry
isAbstract: falseand abstract basesisAbstract: true; all 87[ReqIfProperty]usages list the full nine-argument set.Completeness guard
ModelMetadataTestFixtureis a reflection-driven test that fails if any model class or metamodel property is left undecorated, or if multiplicity is inconsistent (Upper >= Lower,Upper >= 1). Container back-references (e.g.DocumentRoot,ReqIFContent,Owner) and polymorphic convenience accessors (ObjectValue, the baseType/Definitionaliases) are in a documented exclusion list. This keeps future model additions honest.(Note: explicitness itself cannot be asserted by reflection — explicitly-passed default arguments and omitted ones compile to identical attribute metadata — so it is maintained as a source convention.)
Verification
dotnet build ReqIFSharp.sln -c Release— 0 warnings / 0 errors onnetstandard2.0.dotnet test ReqIFSharp.sln— 376 tests pass (292 core incl. 10 new decorator tests, 84 extensions).Notes
ReqIfClassAttribute,ReqIfPropertyAttribute,AggregationKind); 3 new test fixtures..csproj/version changes.ReqIfprefix on both decorators avoids theNUnit.Framework.PropertyAttributecollision entirely, so no test-sideusingalias is required.