Skip to content

[http-client-csharp] Preserve ApiCompat acronym names after namespace updates - #11701

Merged
JoshLove-msft merged 3 commits into
microsoft:mainfrom
JoshLove-msft:fix/11696-apicompat-acronyms
Aug 17, 2026
Merged

[http-client-csharp] Preserve ApiCompat acronym names after namespace updates#11701
JoshLove-msft merged 3 commits into
microsoft:mainfrom
JoshLove-msft:fix/11696-apicompat-acronyms

Conversation

@JoshLove-msft

Copy link
Copy Markdown
Contributor

Summary

  • preserve last-contract model and enum spelling when namespace visitors relocate generated types
  • fall back from the normalized generated name to the original input name only when the names differ solely by supported acronym normalization
  • retain enum input metadata so the compatibility lookup can use that fallback
  • add regression coverage for model properties and enums after namespace updates

Validation

  • dotnet test packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Microsoft.TypeSpec.Generator.Tests.csproj --no-restore --verbosity minimal -p:NuGetAudit=false (1905 passed)

Fixes #11696

Restore last-contract model and enum names after namespace visitors move generated types, and retain input metadata for enum compatibility lookup.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 887e1959-8449-4a09-b284-47a81837f172
Copilot AI lite review requested due to automatic review settings August 17, 2026 17:48
@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 Aug 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Aug 17, 2026

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 5186bc6

@github-actions

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

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.

Pull request overview

This PR updates the http-client-csharp generator’s ApiCompat name preservation so that previously-shipped acronym casing (from ApiCompatVersion last-contract baselines) is still honored even after namespace relocation visitors move generated types.

Changes:

  • Extend TypeProvider last-contract lookup to fall back from the normalized generated name to the original input identifier name when the difference is only supported acronym normalization.
  • Ensure enum providers retain input metadata for the above fallback by flowing the input type into the TypeProvider base.
  • Add regression tests covering model property and enum name preservation after namespace updates.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelProviderTests.cs Adds a regression test for model/property back-compat name preservation after a namespace update.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/EnumProviders/EnumProviderTests.cs Adds a regression test for enum back-compat name preservation after a namespace update.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/TypeProvider.cs Implements acronym-aware fallback when resolving last-contract views and uses last-contract name to stabilize identity after updates.
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/EnumProvider.cs Passes enum input type into TypeProvider so last-contract fallback has access to original names.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Avoid redundant last-contract lookup when acronym normalization is unchanged and give namespace-update regressions dedicated baseline assets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 887e1959-8449-4a09-b284-47a81837f172
Copilot AI review requested due to automatic review settings August 17, 2026 17:58

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.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 887e1959-8449-4a09-b284-47a81837f172
@JoshLove-msft
JoshLove-msft disabled auto-merge August 17, 2026 19:05
@JoshLove-msft
JoshLove-msft added this pull request to the merge queue Aug 17, 2026
Merged via the queue into microsoft:main with commit 1a7f2f4 Aug 17, 2026
29 checks passed
@JoshLove-msft
JoshLove-msft deleted the fix/11696-apicompat-acronyms branch August 17, 2026 20:19
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.

C# acronym normalization ignores management SDK ApiCompat contracts

3 participants