Skip to content

[Feature] implement Resource.GetURIFragment(EObject); fixes #76#77

Merged
samatstariongroup merged 1 commit into
developmentfrom
GH76
Jun 21, 2026
Merged

[Feature] implement Resource.GetURIFragment(EObject); fixes #76#77
samatstariongroup merged 1 commit into
developmentfrom
GH76

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Implements Resource.GetURIFragment(EObject), previously a NotImplementedException stub, as the inverse of GetEObject(string).

Approach

  • During load every ENamedElement is registered in Resource.Cache keyed by its EObject.Identifier, and GetEObject resolves a reference by that same key. GetURIFragment therefore returns the object's Identifier (the name-based Ecore reference, e.g. recipe.ecore#//Recipe for a class, EStructuralFeature::recipe.ecore#//Recipe/ingredients for a feature), which guarantees the round-trip GetEObject(GetURIFragment(x)) == x with no change to GetEObject.
  • Guards: null -> ArgumentNullException; an object not contained in this resource -> a descriptive InvalidOperationException (consistent with the guarded patterns from [Bug]: Guard unsafe casts on GetEObject(...) results #32/[Bug]: Validate attribute values before parsing #37).

Design note / deviation from the ticket
The ticket listed a possible acceptance bullet that the fragment contain no leading #. The existing architecture keys the cache by the composed identifier (which includes the <resource>.ecore# prefix), so returning that composed form is what round-trips with the current GetEObject. Returning a pure intra-resource fragment (//Recipe) would require re-architecting GetEObject/BuildIdentifier and was deliberately left out of scope; the round-trip is satisfied as the primary contract. Happy to follow up with the pure-fragment form if desired.

Tests (new GetUriFragmentTestFixture): round-trip for the root package, a class, a structural feature and an enum literal, plus null and not-contained guard cases. Full suite green (198 tests).

Fixes #76.

…ect; fixes #76

Return the EObject.Identifier under which the object is cached during load (the name-based
Ecore reference that GetEObject resolves), guaranteeing the GetEObject(GetURIFragment(x))==x
round-trip. Guards null and objects not contained in the resource with descriptive exceptions.
@github-actions

Copy link
Copy Markdown
Contributor
Package Line Rate Branch Rate Complexity Health
ECoreNetto 87% 79% 424
ECoreNetto.Extensions 99% 93% 101
ECoreNetto.HandleBars 99% 98% 60
ECoreNetto.Reporting 83% 71% 181
ECoreNetto.Tools 95% 92% 58
Summary 89% (2181 / 2441) 82% (506 / 618) 824

@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup samatstariongroup merged commit 40ecf89 into development Jun 21, 2026
14 checks passed
@samatstariongroup samatstariongroup deleted the GH76 branch June 21, 2026 21:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Implement Resource.GetURIFragment(EObject)

1 participant