[csharp] Make ModelProvider.BuildBaseModelProvider virtual to keep BaseType and BaseModelProvider consistent#10600
Draft
[csharp] Make ModelProvider.BuildBaseModelProvider virtual to keep BaseType and BaseModelProvider consistent#10600
Conversation
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/96294dad-fa6c-4b21-a8c7-8fcfb0107c92 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix mismatched values returned by ModelProvider.BaseType and BaseModelProvider
[csharp] Make ModelProvider base resolution methods virtual to keep BaseType and BaseModelProvider consistent
May 5, 2026
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/60279f78-9af0-440e-97b7-7026b39783c9 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/5b6fcac7-58a2-4f8e-be3e-2b2870fbeed0 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[csharp] Make ModelProvider base resolution methods virtual to keep BaseType and BaseModelProvider consistent
[csharp] Make ModelProvider.BuildBaseModelProvider virtual to keep BaseType and BaseModelProvider consistent
May 5, 2026
Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/cab911a0-953a-4889-b96d-18aaccf1af83 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Contributor
|
No changes needing a change description found. |
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.
ModelProvider.BuildBaseTypeisvirtualand emitters override it to redirect the C# base class (e.g., to a framework type they own), butBuildBaseModelProviderwasprivate, soBaseModelProviderkept walkingInputModelType.BaseModeland diverged from the generated class hierarchy. Visitors traversingBaseModelProviderwould see "inherited" properties from a parent that is no longer the actual C# base.Changes
ModelProvider.BuildBaseModelProvider:private→protected virtual.BuildBaseTypeto redirect the generated C# base class, also overrideBuildBaseModelProviderso thatBaseTypeandBaseModelProviderstay consistent.ModelProviderTestscovering the override pattern.Example: emitter redirecting to a framework base
BaseTypeandBaseModelProvidernow stay in lock-step —BaseModelProviderisnull(since the framework base isn't aModelProvider) instead of leaking the original input-model parent.