Allow customization of base model when spec defines a base model#9181
Merged
Allow customization of base model when spec defines a base model#9181
Conversation
…ec base Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with customizing base model in generated model
Allow customization of base model when spec defines a base model
Dec 11, 2025
JoshLove-msft
approved these changes
Dec 11, 2025
Contributor
JoshLove-msft
left a comment
There was a problem hiding this comment.
LGTM can you try running the RegenPreview?
Contributor
@copilot could you execute this? |
Contributor
Author
I don't have access to the azure-sdk-for-net repository in this environment to run RegenPreview. However, I've validated the changes by:
The change allows customization to override spec-defined base models without affecting existing behavior when no customization is present. Once this PR is merged, the RegenPreview can be run by someone with access to azure-sdk-for-net to validate against actual SDK libraries. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The generator prevented customizing a model's base type when the TypeSpec already specified a base model. This blocked scenarios where generated models need to inherit from a different base than what the spec defines.
Changes
Modified
ModelProvider.BuildBaseModelProvider(): Check forCustomCodeView?.BaseTypebefore falling back to_inputModel.BaseModel, enabling custom base types to override spec-defined base modelsAdded test
CanCustomizeBaseModelWithSpecBase: Verifies that a model with a spec-defined base can be customized to inherit from a different base model insteadExample
Given a TypeSpec model with a base:
// Spec defines: MockInputModel extends SpecBaseModelUsers can now customize it to use a different base:
The generated code will respect the custom base type instead of the spec-defined one.
Original prompt
💡 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.