[Bug] resolve bare same-document href references; fixes #192#193
Merged
Conversation
The XMI reader dropped cross-reference children whose href is a bare
same-document fragment (href=#id), while the cross-document form
(href=file#id) resolved correctly. A bare #id contains #, so the
Assembler used it verbatim as the cache lookup key, but the cache is
keyed by {DocumentName}#{XmiId} - the lookup therefore never matched
and the reference was silently dropped.
Assembler.TryGetReferencedElement now inspects the position of #:
a document part (hashIndex > 0, e.g. file#id) is used as-is, while a
bare id or a bare same-document fragment is normalized to the current
document. This is the single, generic resolution point every
href-based reference flows through (subsettedProperty,
redefinedProperty, type, general, ...), so the fix is uniform.
Tests:
- AssemblerTestFixture: unit tests for the bare-fragment single- and
multi-value paths.
- SysML2.XmiReaderTestFixture: end-to-end regression test against the
real SysML2 model (SysML_only_xmi.uml + KerML_only_xmi.uml) asserting
directedUsage.SubsettedProperty resolves both the cross-document
(directedFeature) and bare same-document (usage) references.
…s pathmap Commit resources/SySML2/PrimitiveTypes.xmi and point the SysML2 reader test's UMLPrimitiveTypes pathmap at it (instead of borrowing the UML copy), so the SysML2 fixtures resolve every reference on their own. Assert that the pathmap-typed 'isReference' attribute resolves to the Boolean primitive, proving the model is fully assembled.
|
antoineatstariongroup
approved these changes
Jul 1, 2026
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
The XMI reader dropped cross-reference children whose
hrefis a bare same-document fragment (href="#id"), while the cross-document form (href="file#id") resolved correctly. Observed for<subsettedProperty>/<redefinedProperty>but the cause was generichrefresolution, so it affected every href-based reference element.Fixes #192. Downstream: STARIONGROUP/SysML2.NET#315.
Root cause
The element cache is keyed by
{DocumentName}#{XmiId}(XmiElement.FullyQualifiedIdentifier). InAssembler.TryGetReferencedElementthe lookup key was built withreferenceIdKey.Contains("#"): a bare#idcontains#, so it was used verbatim as the key and never matcheddocumentName#id— the reference was silently dropped (only a warning logged).Change
Assembler.TryGetReferencedElementnow inspects the position of#:hashIndex > 0→ a document part is present (file#id) → used as-isid, fromxmi:idref) or a bare same-document fragment (#id) → normalized to{documentName}#{id}This is the single, generic resolution point every href-based reference flows through (
subsettedProperty,redefinedProperty,type,general, …), so the fix is uniform.ExternalReferenceResolveralready correctly treated bare fragments as same-document, so no change was needed there.Tests
AssemblerTestFixture— unit tests for the bare-fragment single-value and multi-value resolution paths (each fails without the fix, passes with it).SysML2.XmiReaderTestFixture— end-to-end regression test against the real SysML2 model. ReadsSysML_only_xmi.uml(plus cross-documentKerML_only_xmi.uml) and assertsdirectedUsage.SubsettedPropertyresolves both the cross-document reference (directedFeature) and the bare same-document reference (usage). Without the fix this model dropped the bare#idreference (count 1 instead of 2, plus ~38 "not found in cache" warnings across the model).Verification
Assemblerand passes after.uml4net.xmi.Testssuite green (54/54).UML.xmimetamodel contains zero barehref="#"references, and regenerating through the patched Assembler produces byte-for-byte identicalAutoGenClasses/AutoGenInterfaces(CorePocoGenerator exact-match tests pass).Notes
resources/SySML2/SysML_only_xmi.umlandKerML_only_xmi.umlas test fixtures (wired intoTestDatavia the test csproj).