Skip to content

Restore previous GA parameter names on generated constructors #11588

Closed

Description

@live1206

Description

Existing generated constructors do not restore parameter names from the previous GA contract.

Constructor back-compatibility preserves or adds constructor signatures, but parameter names on a current constructor can still differ from the matching previous-contract constructor. This is source-breaking for callers that use named arguments and is reported by ApiCompat as CP0017.

Evidence

Azure SDK regeneration PR Azure/azure-sdk-for-net#61813 exposed 17 constructor parameter-name mismatches across six services.

Examples:

  • ContainerAppWorkloadProfile(string, int, int): name, minimumCount, and maximumCount no longer align with their GA positions.
  • InitialAgentPoolConfiguration(long, ..., string, string): name and vmSkuName are swapped.
  • InMageRcmFabricCreationContent(...): vmwareSiteId became vMwareSiteId.
  • VMwareCbtEnableMigrationContent(...): vmwareMachineId became vMwareMachineId.
  • FhirServiceAccessPolicyEntry(...): serializedAdditionalRawData became additionalBinaryDataProperties.

Pipeline: https://dev.azure.com/azure-sdk/public/_build/results?buildId=6672631

Expected behavior

When a current constructor matches a previous-contract constructor by parameter types:

  1. Restore parameter names positionally from the previous contract.
  2. Apply swaps or rotations atomically after validating that the final names are unique.
  3. Update XML documentation and constructor-body references consistently.

Suggested tests

  • A simple constructor parameter rename.
  • A casing-only rename.
  • Two same-typed parameters whose names are swapped.
  • Three same-typed parameters whose names are rotated.

Activity

  1. github-actions commented on Aug 7, 2026

    @github-actions
    Contributor

    🎯 Issue Triage

    The C# client emitter's constructor back-compatibility logic preserves constructor signatures but fails to restore parameter names from the previous GA contract, causing source-breaking changes for callers using named arguments (ApiCompat CP0017).

    Category: Bug
    Area: emitter:client:csharp

    ⚠️ No reproduction provided. A minimal repro would help diagnose this issue.

    🔍 Analysis
    • Affected component: Constructor back-compat code generation in @typespec/http-client-csharp
    • Observed in: Azure SDK regeneration PR (Update azure-typespec/http-client-csharp-mgmt version to prerelease 1.0.0-alpha.20260807.3 Azure/azure-sdk-for-net#61813), 17 mismatches across 6 services
    • Root cause: When generating constructors that match a previous-contract signature by parameter types, parameter names are not positionally restored from the GA contract. This includes simple renames, casing changes, and parameter swaps/rotations.
    • Impact: Source-breaking for consumers using C# named arguments; reported by ApiCompat as CP0017.
    📝 Suggested next steps
    • In the constructor back-compat generation logic, after matching current constructor to previous-contract constructor by parameter types, positionally restore parameter names from the previous contract
    • Handle swaps and rotations atomically, validating final names are unique
    • Update XML doc comments and constructor-body references consistently
    • Add suggested tests: simple rename, casing-only rename, two same-typed params swapped, three same-typed params rotated

    Generated by Agentic Triage

  2. jorgerangel-msft commented on Aug 10, 2026

    @jorgerangel-msft
    Contributor

    FhirServiceAccessPolicyEntry is a model that no longer is defined in the latest version of the service, so the generator omits it. We don't have the functionality in place to correctly restore this entire model from back compat. This one should just be handled via client.tsp or custom code. We can explore how to handle this via back compat if it becomes a recurring pattern.

  3. jorgerangel-msft commented on Aug 10, 2026

    @jorgerangel-msft
    Contributor

    Working on a fix in #11614, pending a regen test

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

Metadata

Metadata

Labels

bugSomething isn't workingemitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharp

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions