Skip to content

[Feature] implement EObject.EClass() (return the meta class); fixes #10#78

Merged
samatstariongroup merged 2 commits into
developmentfrom
GH10
Jun 22, 2026
Merged

[Feature] implement EObject.EClass() (return the meta class); fixes #10#78
samatstariongroup merged 2 commits into
developmentfrom
GH10

Conversation

@samatstariongroup

Copy link
Copy Markdown
Member

Implements EObject.EClass(), previously a NotImplementedException stub, per the EMF eClass() contract: it returns the meta class describing the element's own type (e.g. an EAttribute instance returns the EClass named EAttribute).

Approach

  • Added an internal Resource.GetMetaClass(string) helper that looks up the meta class already registered in eCoreTypes under //<TypeName> and returns it typed as EClass.
  • EObject.EClass() resolves via EResource.GetMetaClass(this.GetType().Name) (the CLR type names match the registered meta-class names), guarding an unregistered type with a descriptive InvalidOperationException. The meta class returned belongs to the same resource as the object. Purely additive - no change to GetEObject/registry keys.

Tests

New EObjectMetaClassTestFixture: meta-class name for EPackage/EClass/EAttribute/EReference/EEnum/EEnumLiteral; that the returned meta class is the resource-registered EClass instance; and consistency across instances of the same type. Full suite green (201 tests).

Note on the ticket

Issue #10's stated use-case (checking whether the EClass referenced by a StructuralFeature as its EType is abstract) is unrelated to eClass() per the Ecore spec - eClass() returns the metaclass, not the EType. That use-case is already supported via feature.EType as EClass + .Abstract. This PR implements the correct eClass() semantics; the issue text was left unchanged.

Fixes #10.

…fixes #10

Resolve the Ecore meta class for an EObject by looking up // + runtime type name in the
resource's registered eCoreTypes (new internal Resource.GetMetaClass helper), matching the
EMF eClass() contract. Guards unregistered types with a descriptive exception.
Add tests for the no-registered-meta-class throw path of EObject.EClass()
and the unknown-type-name null return of Resource.GetMetaClass(string),
bringing new-code coverage on #10 to 100% (>= 80% quality gate). Also
document the 80% new-code coverage requirement in CLAUDE.md.
@github-actions

Copy link
Copy Markdown
Contributor
Package Line Rate Branch Rate Complexity Health
ECoreNetto 87% 80% 429
ECoreNetto.Extensions 99% 93% 101
ECoreNetto.HandleBars 99% 98% 60
ECoreNetto.Reporting 83% 71% 181
ECoreNetto.Tools 95% 92% 58
Summary 89% (2195 / 2453) 82% (512 / 624) 829

@sonarqubecloud

Copy link
Copy Markdown

@samatstariongroup samatstariongroup merged commit 81bf334 into development Jun 22, 2026
14 checks passed
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.

[Implement] EObject.EClass() method

1 participant