You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Model-factory back-compat generation does not consistently preserve or safely adapt the previous contract's required/optional parameter boundary when reordered overloads coexist.
A reordered factory method can retain the current generated method's all-optional defaults instead of selecting the minimum required prefix needed to keep the overload set unambiguous.
The first behavior can break existing calls that omitted trailing optional arguments. The second can leave reordered, fully optional overloads ambiguous. SDK customization must currently choose a safe middle ground manually: require enough leading parameters to disambiguate while retaining optional trailing parameters.
For example, SiteContainerData has reordered factory overloads. The compatibility wrapper requires the identifying leading parameters but preserves the trailing optional parameters:
Making every parameter required breaks calls that provide the leading arguments but omit optional trailing arguments. Keeping every parameter optional can make calls ambiguous with the current reordered overload.
CsmPublishingCredentialsPoliciesEntityData demonstrates the fully optional case: removing its custom wrapper regenerates two reordered, fully optional overloads. Calls that omit arguments can be ambiguous, so the SDK currently suppresses one generated overload and supplies a required forwarding overload.
Expected behavior
When generating model-factory compatibility methods, determine the minimum required parameter prefix needed for unambiguous overload resolution while preserving the previous optional trailing parameters wherever possible.
Please add tests covering:
Reordered model-factory overloads with required leading and optional trailing parameters.
Reordered fully optional overloads that would otherwise be ambiguous.
A compatibility overload where only the minimum parameters, rather than every parameter, need to become required.
Description
Model-factory back-compat generation does not consistently preserve or safely adapt the previous contract's required/optional parameter boundary when reordered overloads coexist.
The generator currently has two coarse behaviors:
BuildBackCompatMethodSignature(..., hideMethod: true)has everyDefaultValueremoved, making all parameters required (LastContractView - Make Model Factory Method Parameters Required #8650 / Avoid ambiguous backcompat methods #8674).The first behavior can break existing calls that omitted trailing optional arguments. The second can leave reordered, fully optional overloads ambiguous. SDK customization must currently choose a safe middle ground manually: require enough leading parameters to disambiguate while retaining optional trailing parameters.
AppService example
Azure SDK for .NET PR Azure/azure-sdk-for-net#62039 retains custom wrappers in:
sdk/websites/Azure.ResourceManager.AppService/src/Customization/AppService/Models/ArmAppServiceModelFactory.ParameterCompatibility.csFor example,
SiteContainerDatahas reordered factory overloads. The compatibility wrapper requires the identifying leading parameters but preserves the trailing optional parameters:Making every parameter required breaks calls that provide the leading arguments but omit optional trailing arguments. Keeping every parameter optional can make calls ambiguous with the current reordered overload.
CsmPublishingCredentialsPoliciesEntityDatademonstrates the fully optional case: removing its custom wrapper regenerates two reordered, fully optional overloads. Calls that omit arguments can be ambiguous, so the SDK currently suppresses one generated overload and supplies a required forwarding overload.Expected behavior
When generating model-factory compatibility methods, determine the minimum required parameter prefix needed for unambiguous overload resolution while preserving the previous optional trailing parameters wherever possible.
Please add tests covering:
Related:
- by copilot