Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

The @hierarchyBuilding decorator was failing validation when skipping multiple inheritance layers. It only checked direct properties on the target model, not inherited properties.

@Azure.ClientGenerator.Core.Legacy.hierarchyBuilding(C)
model A extends B { a?: string; }
model B extends C { b?: string; }
model C { c?: string; }

Previously this would report a warning that A is missing property c and the decorator would not apply.

Changes

  • decorators.ts: Added getAllPropertiesInChain() to collect all properties from a model's inheritance chain. Updated isPropertySuperset() to validate against inherited properties, not just direct properties.

  • types.ts: When legacy hierarchy building skips intermediate models, properties from those skipped models are now "collapsed" into the target SDK type.

Result

Model A now correctly:

  • Has base type C
  • Contains properties a (own) and b (from skipped model B)
  • Model C has property c

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • telemetry.astro.build
    • Triggering command: /usr/local/bin/node node /home/REDACTED/work/typespec-azure/typespec-azure/website/node_modules/.bin/../astro/astro.js build node ical/node_modules/.bin/../@typespec/tspd/cmd/tspd.js tput-dir ../../website/src/content/docs/docs/emitters/protobuf/reference . .0_tmp_3782/node_modules/pnpm/dist/node-gyp-bin/sh ern-signature &&sh ce n/sh sh c-az�� tput-dir ../../website/src/conte--llmstxt node n/sh perimental gen-esh gen-extern-signa-c ager/reference node (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[TCGC] improve the hierarchyBuilding decorator to support multiple layer inheritance replacement</issue_title>
<issue_description>Now the decorator implementation of this hierarchyBuilding decorator is checking properties very strictly.

For instance, in the following case, the decorator will report warning and would not apply.

@Azure.ClientGenerator.Core.Legacy.hierarchyBuilding(C)
model A extends B {
a?: string;
}
model B extends C {
b?: string;
}
model C {
c?: string;
}

We need to implement this so that in the output of TCGC, we have model A with base type of C, and A should have property a (defined on its own) and b (from model B) on it, model C has property c.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits January 19, 2026 08:07
Updated isPropertySuperset to collect all inherited properties from target's
chain, enabling decorator to validate when skipping multiple inheritance layers.

Also updated types.ts to add properties from intermediate skipped models to
the SDK type, ensuring properties are correctly "collapsed" into the target.

Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Co-authored-by: ArcturusZhang <10554446+ArcturusZhang@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve hierarchyBuilding decorator for multiple layer inheritance fix: support multi-layer inheritance in hierarchyBuilding decorator Jan 19, 2026
Copilot AI requested a review from ArcturusZhang January 19, 2026 08:22
@ArcturusZhang ArcturusZhang deleted the copilot/improve-hierarchy-building-decorator branch January 19, 2026 10:05
@microsoft-github-policy-service microsoft-github-policy-service bot added the lib:tcgc Issues for @azure-tools/typespec-client-generator-core library label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lib:tcgc Issues for @azure-tools/typespec-client-generator-core library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants