Skip to content

[http-client-csharp] Preserve error response names and isolate generic keep registrations - #12049

Draft
Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 3 commits into
mainfrom
copilot/preserve-error-response-model-names
Draft

Jorge Rangel (jorgerangel-msft) with Copilot wants to merge 3 commits into
mainfrom
copilot/preserve-error-response-model-names

Conversation

Copilot AI commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Automatic Response → Result normalization renamed error contracts and exposed a keep-key collision: preserving the internal ErrorResult<T> helper also retained unrelated non-generic ErrorResult models, introducing unintended public API.

  • Error-model naming: Exempt models marked with error usage from suffix normalization. Preserve ordinary response normalization and explicit naming customizations.
  • Keep-set identity: Reuse the reference map’s arity-aware identity when materializing provider registrations, keeping ErrorResult and ErrorResult1` distinct while preserving lazy registration.
  • Regression coverage: Cover referenced and pruned error models, generic/non-generic isolation for root and non-root registrations, helper visibility, and model-factory/context cleanup.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

…neric keep keys

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@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 Sep 25, 2026
@pkg-pr-new

pkg-pr-new Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 7beb863

Copilot AI changed the title [WIP] Fix error response model names and resolve keep-key collision [http-client-csharp] Preserve error response names and isolate generic keep registrations Sep 25, 2026
Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation addresses both linked root causes with comprehensive regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Fixes error-model renaming and generic keep-key collisions in the C# client generator.

Changes:

  • Preserves Response suffixes for error models.
  • Uses generic-arity-aware keep identities.
  • Adds naming, pruning, visibility, factory, context, and arity regression tests.
File Description
ModelProvider.cs Exempts error models from suffix normalization.
CodeModelGenerator.cs Materializes arity-aware keep keys.
ProviderReferenceMapAnalyzer.BodyReferences.cs Shares provider identity generation.
ModelProviderTests.cs Tests error naming and customization.
ProviderReferenceMapAnalyzerTests.cs Tests generic arity isolation.
ClientBodyDependencyReferenceMapTests.cs Tests end-to-end pruning and helper isolation.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

This branch has not been deployed

No deployments
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.

[http-client-csharp] Preserve error response model names and fix the ErrorResult helper keep-key collision

3 participants