Skip to content

[http-client-csharp] Normalize acronyms in operation parameter names - #12076

Draft
JoshLove-msft with Copilot wants to merge 16 commits into
mainfrom
copilot/http-client-csharp-normalize-acronyms
Draft

JoshLove-msft with Copilot wants to merge 16 commits into
mainfrom
copilot/http-client-csharp-normalize-acronyms

Conversation

Copilot AI commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Extend acronym normalization to ordinary operation parameters while preserving named-argument compatibility for exact, customized, and previously published signatures.

  • Naming: Reuse boundary-aware acronym rules for query/path/header/body parameters. Preserve leading camelCase (ipAddress, ipv4Address, ipv6Address) and leave serialized wire names unchanged.
  • Compatibility: Preserve names per signature across protocol/convenience and sync/async projections. Retain legacy iPv4/iPv6 spellings and existing property-derived and date/time parameter behavior.
  • References: Give each projection independent parameter instances. Keep forwarding, named arguments, spread/grouped mappings, validation, and XML documentation aligned with emitted signatures.
  • Regression coverage: Cover acronym boundaries, repeated and canonical spellings, exact/custom/published names, unmatched contracts, and reordered signatures.

For new, non-exact parameters without a matching published signature:

- Send(string sourceIpAddress, string targetDbName, string guestOsType)
+ Send(string sourceIPAddress, string targetDBName, string guestOSType)

@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.

@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 29, 2026
Copilot AI changed the title [WIP] Normalize acronyms in ordinary operation parameter names [http-client-csharp] Normalize acronyms in operation parameter names Sep 29, 2026
Copilot AI requested a review from JoshLove-msft September 29, 2026 22:27

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 pull the latest from main and address the merge conflicts

@pkg-pr-new

pkg-pr-new Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: d1b8024

Copilot AI and others added 5 commits October 7, 2026 12:50
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd
@jorgerangel-msft
Jorge Rangel (jorgerangel-msft) force-pushed the copilot/http-client-csharp-normalize-acronyms branch from a1a26ce to e6dd983 Compare October 7, 2026 19:23
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

No changes needing a change description found.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd
@jorgerangel-msft

Copy link
Copy Markdown
Contributor

Added AcronymSpreadParametersPreserveSignatures with normalized, exact, customized, and last-contract cases. It checks distinct sync/async names, an optional spread member, unchanged wire names, constructor argument order when method parameters are reordered, and forwarding of the reconstructed model through the protocol and CreateRequest methods.

🤖 Generated by Jorge's Copilot

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.

🟡 Changes recommended

Acronym normalization unintentionally renames client-scoped constructor and settings parameters without backward-compatibility restoration.

1 open finding
What changed in this PR

Normalizes acronyms in C# operation parameter names while preserving wire names, customized signatures, and published API compatibility.

Changes:

  • Adds boundary-aware camelCase acronym normalization.
  • Keeps method projections and forwarding references independent and synchronized.
  • Expands compatibility and regression coverage.
File Description
TestProjects/​Local/​Sample-TypeSpec/​tspCodeModel.json Adds acronym scenarios to generated input.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​SampleTypeSpecClient.RestClient.cs Updates generated request methods.
TestProjects/​Local/​Sample-TypeSpec/​src/​Generated/​SampleTypeSpecClient.cs Updates generated public methods.
TestProjects/​Local/​Sample-TypeSpec/​Sample-TypeSpec.tsp Defines integration scenarios.
Microsoft.TypeSpec.Generator/​test/​Providers/​TypeProviderTests.cs Tests type-aware contract lookup.
Microsoft.TypeSpec.Generator/​test/​Providers/​ParameterProviderTests.cs Tests normalization and metadata isolation.
Microsoft.TypeSpec.Generator/​test/​Expressions/​PositionalParameterReferenceExpressionTests.cs Tests renamed named arguments.
Microsoft.TypeSpec.Generator/​src/​Utilities/​BackCompatHelper.cs Restores published parameter names.
Microsoft.TypeSpec.Generator/​src/​Snippets/​Snippet.cs Retains parameter references in named arguments.
Microsoft.TypeSpec.Generator/​src/​Shared/​CSharpNameExtensions.cs Adds camelCase acronym normalization.
Microsoft.TypeSpec.Generator/​src/​Providers/​ParameterProvider.cs Applies normalization to input parameters.
Microsoft.TypeSpec.Generator/​src/​Expressions/​PositionalParameterReferenceExpression.cs Resolves argument names dynamically.
ScmMethodProviderCollectionTests/​AcronymSpreadParametersPreserveSignatures(LastContract)/​TestClient.cs Supplies published spread signatures.
ScmMethodProviderCollectionTests/​AcronymSpreadParametersPreserveSignatures(Custom)/​TestClient.cs Supplies customized spread signatures.
Microsoft.TypeSpec.Generator.ClientModel/​test/​Providers/​ScmMethodProviderCollectionTests.cs Covers projections, spreading, and grouping.
RestClientProviderTests/​AcronymNamedArgumentsFollowReorderedProtocolSignature(Sync).cs Baselines sync forwarding.
RestClientProviderTests/​AcronymNamedArgumentsFollowReorderedProtocolSignature(Published)/​TestClient.cs Supplies published reordered signatures.
RestClientProviderTests/​AcronymNamedArgumentsFollowReorderedProtocolSignature(Custom)/​TestClient.cs Supplies customized reordered signatures.
RestClientProviderTests/​AcronymNamedArgumentsFollowReorderedProtocolSignature(Async).cs Baselines async forwarding.
RestClientProviders/​RestClientProviderTests.cs Tests request ordering and wire names.
ClientProviderTests/​TestMultipartClient_UploadMethods_OptionalBody.cs Updates multipart projection baseline.
AcronymOperationParameterNamesPreserveSignatures(TypeMismatchLastContract)/​TestClient.cs Covers incompatible published types.
AcronymOperationParameterNamesPreserveSignatures(PrivateLastContract)/​TestClient.cs Covers private prior signatures.
AcronymOperationParameterNamesPreserveSignatures(Normalized).cs Baselines normalized forwarding.
AcronymOperationParameterNamesPreserveSignatures(LastContract)/​TestClient.cs Supplies legacy signatures.
AcronymOperationParameterNamesPreserveSignatures(LastContract).cs Baselines legacy forwarding.
AcronymOperationParameterNamesPreserveSignatures(DistinctLastContract)/​TestClient.cs Supplies projection-specific names.
AcronymOperationParameterNamesPreserveSignatures(DistinctLastContract).cs Baselines projection-specific forwarding.
AcronymOperationParameterNamesPreserveSignatures(Custom)/​TestClient.cs Supplies customized signatures.
AcronymOperationParameterNamesPreserveSignatures(Custom).cs Baselines customized forwarding.
AcronymOperationParameterNamesPreserveSignatures(CaseOnlyLastContract)/​TestClient.cs Supplies casing variants.
AcronymOperationParameterNamesPreserveSignatures(CaseOnlyLastContract).cs Baselines casing preservation.
AcronymNamedArgumentsUseProtocolSignature(LastContract)/​TestClient.cs Supplies published protocol names.
AcronymNamedArgumentsUseProtocolSignature(LastContract,Sync).cs Baselines published sync arguments.
AcronymNamedArgumentsUseProtocolSignature(LastContract,Async).cs Baselines published async arguments.
AcronymNamedArgumentsUseProtocolSignature(Custom)/​TestClient.cs Supplies custom protocol names.
AcronymNamedArgumentsUseProtocolSignature(Custom,Sync).cs Baselines custom sync arguments.
AcronymNamedArgumentsUseProtocolSignature(Custom,Async).cs Baselines custom async arguments.
ClientProviders/​ClientProviderTests.cs Tests signature compatibility.
ClientModel/​src/​Providers/​ScmMethodProviderCollection.cs Creates independent projection parameters.
ClientModel/​src/​Providers/​RestClientProvider.cs Creates independent request parameters.
ClientModel/​src/​Primitives/​ScmKnownParameters.cs Adds factories for signature-owned parameters.

🧠 Review effort: Balanced


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

…sharp-normalize-acronyms

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Copilot pull the latest from main and address the merge conflicts

Merged the latest main into this branch cleanly; merge commit $(git rev-parse --short HEAD) includes the current main tip.

Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
…t mapping

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd

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.

🟡 Changes recommended

Unmatched overloads can restore unrelated names, and optional multipart reordering can break existing custom partial signatures.

2 open findings
1 resolved since last review

🧠 Review effort: Balanced

Copilot AI commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Copilot overall, we should avoid having to mutate the parameters after they have already been constructed. Ideally, the renaming happens during construction time to avoid the additional complexity

Acronym normalization now happens in ParameterProvider(InputParameter) during construction; it does not mutate parameter names afterward. This was implemented in c843255b (with the client-scope exclusion added in 42385749).

…ility

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd

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.

🟡 Changes recommended

Published reordered acronym signatures and mixed acronym/date-time compatibility still have source-breaking restoration gaps.

2 open findings
2 resolved since last review

🧠 Review effort: Balanced

Comment on lines +213 to +216
if (matchingPrevious != null)
{
preservedName = matchingPrevious.Signature.Parameters.FirstOrDefault(p =>
string.Equals(p.Name, inputParameter.OriginalName, StringComparison.OrdinalIgnoreCase))?.Name;

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.

Signature comparison and reordering now use one unambiguous raw/declared/normalized identity mapping, preserving the original parameter instances and published defaults. Forwarding is updated for positional and named arguments even when optional arguments are omitted; compilation-backed same/mixed-type cases verify sync/async signatures, CreateRequest calls, convenience calls, and XML docs.

🤖 Generated by Jorge's Copilot

Comment on lines +220 to +226
// Acronym restoration requires a matching signature; legacy date/time renames keep their name-only fallback.
var hasAcronymRename = inputParameter.Name != inputParameter.Name.NormalizeCSharpAcronyms(useCamelCase: true);
if (!hasAcronymRename)
{
preservedName = FindPreviousParameterName(
lastContractView, inputParameter.OriginalName, method.Signature.Name);
}

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.

Date/time inputs now retain the legacy name-only fallback even when acronym normalization also applies. Added a type-changed sourceIpCreationTime regression; ordinary acronym parameters still require a matching enclosing signature.

🤖 Generated by Jorge's Copilot

…forwarding

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 114125be-5763-45ae-ba45-d8901f6455fd

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] Normalize acronyms in ordinary operation parameter names

4 participants