[http-client-csharp] Preserve previously-published parameter names across back-compat#10464
Merged
JoshLove-msft merged 10 commits intomicrosoft:mainfrom Apr 24, 2026
Conversation
…y methods when only param names change Integrates parameter-name preservation into the existing back-compat feature. When the only difference between a previous and current factory method is one or more parameter names (same method name, same parameter types in the same order, same count), the previous names are mutated in place on the current ParameterProvider so that the body and XML docs serialize with the preserved names. This avoids source-breaking changes for callers using named arguments when properties are renamed. Fixes microsoft#10463 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Contributor
|
No changes needing a change description found. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
JoshLove-msft
commented
Apr 23, 2026
The backcompat lookup against LastContractView previously only ran for the paging-specific 'top -> maxCount' rename and the page-size casing normalization. Extend it so every parameter participates: when a service method's parameter has been renamed by the generator and the previous contract published a parameter with the original spec name, restore that name. Scope the search to methods whose name matches the current service method (allowing for the sync/async pair) so that a common parameter name shared across multiple methods can't false-match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jorgerangel-msft
approved these changes
Apr 23, 2026
…ity.md Co-authored-by: Jorge Rangel <102122018+jorgerangel-msft@users.noreply.github.com>
When GetMethodCollectionByOperation switched _backCompatProvider it called the full Reset() on the ClientProvider, which discarded all properties, fields, constructors, and views. That wiped state previously injected by visitors (e.g. Azure DistributedTracingVisitor's ClientDiagnostics property) and caused downstream visitors such as LroVisitor to throw 'Sequence contains no matching element' when looking up the missing property. Introduce TypeProvider.ResetMethods() that only invalidates the cached methods and use it (plus RestClient.ResetMethods()) so the convenience/protocol methods rebuild with the new backcompat provider while leaving visitor-applied state intact. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…el-factory-param-names
…logger Address PR feedback: emit a Debug entry through the new BackCompatibilityChangeCategory.ParameterNamePreserved logging pipeline whenever the model factory rename-only fast path replaces a current parameter name with the previously-published name. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jorgerangel-msft
approved these changes
Apr 23, 2026
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.
Generalizes parameter-name preservation across the back-compat feature so that renamed parameters in both model factory methods and service method signatures continue to use their previously-published names.
Combines and supersedes #10465.
Fixes #10463
Model factory methods (
ModelFactoryProvider)When the only difference between a previous and current factory method is one or more parameter names (same method name, same parameter types in the same order, same count), the previous names are mutated in place on the current
ParameterProviderso that the body and XML docs serialize with the preserved names. This avoids source-breaking changes for callers using named arguments when properties are renamed.When a new property is added at the same time as a rename (parameter counts differ), the standard
[EditorBrowsable(EditorBrowsableState.Never)]overload is generated using the previously-published parameter names; renamed parameters that no longer match a current property are passed asdefaultto the constructor.Service method signatures (
RestClientProvider)The back-compat lookup against
LastContractViewpreviously only ran for the paging-specifictop -> maxCountrename and the page-size casing normalization. This PR extends it so every parameter participates: when a service method's parameter has been renamed by the generator and the previous contract published a parameter with the original spec name, restore that name. The search is scoped to methods whose name matches the current service method (allowing for the sync/async pair) so that a common parameter name shared across multiple methods can't false-match.Tests
ModelFactoryProviderTests.BackCompatibility_OnlyParamNameChanged(partial rename)ModelFactoryProviderTests.BackCompatibility_MultipleParamNamesChanged(all params renamed)ModelFactoryProviderTests.BackCompatibility_NewPropertyAddedWithRenamedParam(new property + rename)RestClientProviderTests.ParameterNamePreservedFromLastContractView(non-paging service method rename)Docs
Updated
backward-compatibility.mdwith two new scenarios: