Skip to content

Fix C# generator base model recursion#11008

Draft
live1206 wants to merge 2 commits into
mainfrom
live1206/fix-mtg-model-base-cycles
Draft

Fix C# generator base model recursion#11008
live1206 wants to merge 2 commits into
mainfrom
live1206/fix-mtg-model-base-cycles

Conversation

@live1206

Copy link
Copy Markdown
Contributor

Fixes C# generator recursion when a customized/base model provider chain cycles through an inheritable system model.

Changes:

  • Make MTG model base-provider traversal cycle-safe for properties, constructor initialization, fields, raw data fields, and full constructor discovery.
  • Make ClientModel MRW serialization base traversal cycle-safe.
  • Make ModelReaderWriter context collection avoid revisiting base model providers.
  • Emit new on explicit response conversion operators from ClientModel when a base model already exposes the same conversion.

Validation:

  • dotnet build packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Microsoft.TypeSpec.Generator.ClientModel.csproj -v:minimal
  • Consumed locally from azure-sdk-for-net mgmt generator; StorageCache regen completes in ~48s.

Make base model provider traversal cycle-safe across model construction, MRW serialization, and ModelReaderWriter context collection. Also emit explicit response conversion hiding at the ClientModel layer when a base model already exposes the same conversion.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Jun 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@11008

commit: f575139

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

@live1206

Copy link
Copy Markdown
Contributor Author

No regen diff in Azure/azure-sdk-for-net#59998

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant