itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

docs: clarify getDerivedClasses behavior regarding unloaded referencing schemas (#8047)

Open ashmitKmishra opened this issue 1 month ago • 2 comments

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.

ashmitKmishra avatar Nov 21 '25 20:11 ashmitKmishra

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 21 '25 21:11 CLAassistant

I turned the suggestion from @rschili and @MichaelSwigerAtBentley into a suggested code change. I have approved pending the resolution of that suggestion.

We may leave the issue opened to track the problem for a future fix. But in the meantime this update will help many people avoid introducing a tricky bug into the code. So it's a valuable update to the codebase.

Thanks @ashmitKmishra!

ColinKerr avatar Dec 02 '25 22:12 ColinKerr