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
{{ message }}
Repository navigation
LastContractView - Consider Supporting Back Compat Model Ctors #11460
There's a recent case where a model previously shipped with a property that was required, and a ctor that had a corresponding param that was also required:
The new version of this library relaxed this req by making the property optional which led to the generator dropping the previous param from the model's ctor. Custom code was required to handle this break:
We should investigate if we can support this case through back compat. We would only be able to restore this ctor if the property name + type didn't change, or a codegentype attribute exists on the new property with a different name but same type.
This is a feature request to support back-compat model constructors in the C# client emitter (LastContractView), specifically for cases where a previously required property becomes optional, causing the generated constructor signature to change and break existing user code.
Scenario: When a model property transitions from required → optional, the generator drops the corresponding constructor parameter, which is a breaking change for consumers who used the old constructor signature
Proposed mitigation: Restore the old constructor as an overload when the property name + type haven't changed, or when a CodeGenType attribute maps to the same type
User impact: Library authors who ship generated clients face downstream breaking changes even for non-breaking API changes; workarounds require custom code
📝 Suggested next steps
Confirm whether LastContractView already captures the previous constructor signatures
Define the exact conditions under which the back-compat ctor should be restored (same name + type, or codegentype attribute match)
Implement and test the generated back-compat ctor pattern shown in the issue
Activity
github-actions commentedon Jul 29, 2026
🎯 Issue Triage
This is a feature request to support back-compat model constructors in the C# client emitter (
LastContractView), specifically for cases where a previously required property becomes optional, causing the generated constructor signature to change and break existing user code.Category: Feature Request
Area:
emitter:client:csharp🔍 Analysis
@typespec/http-client-csharp),LastContractView/ constructor generationCodeGenTypeattribute maps to the same type📝 Suggested next steps
LastContractViewalready captures the previous constructor signaturescodegentypeattribute match)Support back-compat model constructors in the C# generator (#11503)