Add Support for More Back Compat Model Ctor Scenarios - #11614
Draft
Jorge Rangel (jorgerangel-msft) wants to merge 1 commit into
Draft
Add Support for More Back Compat Model Ctor Scenarios#11614Jorge Rangel (jorgerangel-msft) wants to merge 1 commit into
Jorge Rangel (jorgerangel-msft) wants to merge 1 commit into
Conversation
commit: |
Jorge Rangel (jorgerangel-msft)
force-pushed
the
fix-backcompat-ctors
branch
from
August 10, 2026 19:51
490a36d to
bb9d8b8
Compare
Contributor
|
No changes needing a change description found. |
Jorge Rangel (jorgerangel-msft)
force-pushed
the
fix-backcompat-ctors
branch
from
August 10, 2026 22:28
bb9d8b8 to
a534499
Compare
Copilot started reviewing on behalf of
Jorge Rangel (jorgerangel-msft)
August 10, 2026 22:32
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR expands the C# generator’s back-compat handling for model constructors (and a related synthesized-parameter method scenario) so that previously-published parameter names can be restored when matching last-contract signatures by parameter types, including swap/rotation cases and certain constructor-restore paths.
Changes:
- Adds constructor-parameter name restoration by last-contract signature matching (including swap/rotation and casing scenarios).
- Allows restoring certain previously-published constructors as standalone constructors when no chaining target exists (or when a required property can’t be assigned).
- Adds/updates unit tests and last-contract/expected-output fixtures to cover the added scenarios.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Utilities/BackCompatHelper.cs | Enables positional fallback for synthesized parameters even when ParameterProvider.Name differs from InputParameter.Name. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/Providers/ModelProvider.cs | Implements ctor parameter-name restoration by signature and extends constructor restoration to standalone scenarios. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/TypeProviderTests.cs | Adds a regression test for synthesized parameter name restoration via signature match. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/TestData/TypeProviderTests/BuildMethodsForBackCompatibilityRestoresSynthesizedParameterNameBySignatureMatch/TestClient.cs | Adds last-contract input fixture for the synthesized-parameter test. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/TestData/TypeProviderTests/BuildMethodsForBackCompatibilityRestoresSynthesizedParameterNameBySignatureMatch.cs | Adds expected generated output fixture for the synthesized-parameter test. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/ModelProviderTests.cs | Adds ctor back-compat tests for rename/swap/rotation/casing and standalone constructor restore scenarios. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterSwapRestoredBySignatureMatch/MockInputModel.cs | Adds last-contract input fixture for swapped ctor parameter names. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterSwapRestoredBySignatureMatch.cs | Adds expected output fixture for swapped ctor parameter names. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterRenameRestoredBySignatureMatch/MockInputModel.cs | Adds last-contract input fixture for renamed ctor parameter names. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterRenameRestoredBySignatureMatch.cs | Adds expected output fixture for renamed ctor parameter names. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterCasingAndRotationRestoredBySignatureMatch/Models.cs | Adds last-contract input fixtures for casing-only rename and 3-param rotation. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterCasingAndRotationRestoredBySignatureMatch(Casing).cs | Adds expected output fixture for casing-only ctor parameter restore. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_ConstructorParameterCasingAndRotationRestoredBySignatureMatch(Rotation).cs | Adds expected output fixture for rotated ctor parameter restore. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_StandaloneConstructorRestoredWhenNoChainTarget/MockInputModel.cs | Adds last-contract input fixture for standalone ctor restoration when no chaining target exists. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_StandaloneConstructorRestoredWhenNoChainTarget.cs | Adds expected output fixture for standalone ctor restoration when no chaining target exists. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_StandaloneConstructorRestoredWhenRequiredPropertyUnassigned/MockInputModel.cs | Adds last-contract input fixture for restoring a ctor that can’t assign a newly-required property. |
| packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/test/Providers/ModelProviders/TestData/ModelProviderTests/BackCompat_StandaloneConstructorRestoredWhenRequiredPropertyUnassigned.cs | Adds expected output fixture for restoring a ctor that can’t assign a newly-required property. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Jorge Rangel (jorgerangel-msft)
force-pushed
the
fix-backcompat-ctors
branch
from
August 10, 2026 22:56
a534499 to
4c79dd2
Compare
Jorge Rangel (jorgerangel-msft)
force-pushed
the
fix-backcompat-ctors
branch
from
August 10, 2026 22:58
4c79dd2 to
bb866c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces more covered scenarios for the back compat support for model ctors.
fixes: #11588