Skip to content

Conversation

@ashmitKmishra
Copy link

Fixes #8047.

Analysis:
getDerivedClasses relies on the current SchemaContext to identify subclasses. Since SchemaContext does not maintain a reverse-index of all possible external schemas that might reference a base class, it is architecturally impossible for this method to return classes from unloaded schemas without a global pre-scan.

Changes:

  1. Added a reproduction test case in core/backend demonstrating that getDerivedClasses returns empty until the referencing schema is explicitly loaded.
  2. Updated the JSDoc for getDerivedClasses in core/ecschema-metadata to explicitly warn users that referencing schemas must be loaded into the context to be discovered.

This resolves the ambiguity noted by the reporter.

@CLAassistant
Copy link

CLAassistant commented Nov 21, 2025

CLA assistant check
All committers have signed the CLA.

@@ -0,0 +1,90 @@
import { assert } from "chai";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing!
This test seems alright, but we usually don't follow the pattern of putting tests for one issue into a separate file.
Putting this into the ecdb tests is also not the best fit for this.
We do have a very similar existing SchemaContext embedded in IModelDb.
So either this should be a high level test using IModelDb, in which case core/backend/src/test/schema/IModelSchemaContext.test.ts is a good location.
Or if we just want to confirm the ecschema-metadata package behavior, which is more of a unit test, core/ecschema-metadata/src/test/Context/SchemaContext.test.ts is the place to put it.

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.

ECClass.getDerivedClasses() doesn't include classes from referenced schemas

3 participants