-
Notifications
You must be signed in to change notification settings - Fork 337
Enable customizing model base type to non-generated external types #9375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
9
commits into
main
Choose a base branch
from
copilot/fix-custom-base-type-generation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Modified ModelProvider to support base types from external assemblies - Added BuildBaseTypeProvider method that creates NamedTypeSymbolProvider for external base types - BaseModelProvider remains ModelProvider? for generated models iteration - BaseTypeProvider now handles both generated and external base types - Added comprehensive test CanCustomizeBaseModelToExternalType - Test verifies external base type properties are accessible via BaseTypeProvider Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
- Added comment explaining .NET metadata format for generic types - Made test assertion more descriptive with explanation of expected properties - Verified caching is already handled by lazy initialization pattern Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix customization of base type for generated model
Enable customizing model base type to non-generated external types
Jan 14, 2026
live1206
reviewed
Jan 14, 2026
...ges/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/ModelProvider.cs
Show resolved
Hide resolved
…compilation - Created SystemObjectTypeProvider to represent types from referenced assemblies - Updated BuildBaseTypeProvider to fall back to SystemObjectTypeProvider when type symbol not found - This handles cases where base type is from a referenced assembly not in customization - Updated test to handle both NamedTypeSymbolProvider and SystemObjectTypeProvider scenarios Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
live1206
reviewed
Jan 14, 2026
...iders/TestData/ModelCustomizationTests/CanCustomizeBaseModelToExternalType/MockInputModel.cs
Show resolved
Hide resolved
- Created CanCustomizeBaseModelToSystemType test with System.Exception as base type - This validates that models can inherit from system types like Azure.ResourceManager.TrackedResourceData - Test demonstrates that system types from referenced assemblies are found via GetTypeByMetadataName - All 1191 tests pass Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
live1206
reviewed
Jan 19, 2026
...erator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs
Outdated
Show resolved
Hide resolved
...erator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelCustomizationTests.cs
Outdated
Show resolved
Hide resolved
- CanCustomizeBaseModelToExternalType now specifically asserts NamedTypeSymbolProvider since ExternalBaseModel is defined in the customization file - CanCustomizeBaseModelToSystemType currently uses NamedTypeSymbolProvider (awaiting clarification on how to test SystemObjectTypeProvider path) - Both tests validate that external base types work correctly Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
live1206
reviewed
Jan 19, 2026
...oviders/TestData/ModelCustomizationTests/CanCustomizeBaseModelToSystemType/MockInputModel.cs
Outdated
Show resolved
Hide resolved
- Changed CanCustomizeBaseModelToSystemType to inherit from System.Exception - This provides a more realistic test scenario for external assembly types - System.Exception is found via GetTypeByMetadataName and uses NamedTypeSymbolProvider - All 3 base model customization tests pass Co-authored-by: live1206 <5196139+live1206@users.noreply.github.com>
Contributor
|
No changes needing a change description found. |
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.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.