Use named arguments in ModelFactory backward-compat overloads#10404
Merged
jorgerangel-msft merged 3 commits intomainfrom Apr 17, 2026
Merged
Use named arguments in ModelFactory backward-compat overloads#10404jorgerangel-msft merged 3 commits intomainfrom
jorgerangel-msft merged 3 commits intomainfrom
Conversation
…vent order mismatch When building backward-compat ModelFactory overloads, arguments are now passed using named arguments (e.g., `paramName: paramName`) instead of positional arguments. This ensures correct mapping even when the parameter order differs between the previous and current method signatures, which occurs when @@hierarchyBuilding reorders constructor parameters. Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/bcea383b-5376-46e2-b544-6520fa9b9039 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix GetParameters to preserve public method parameter order
Use named arguments in ModelFactory backward-compat overloads
Apr 16, 2026
…move comment Agent-Logs-Url: https://github.com/microsoft/typespec/sessions/04db242b-b15a-4030-9398-7d5feadcdee4 Co-authored-by: jorgerangel-msft <102122018+jorgerangel-msft@users.noreply.github.com>
commit: |
jorgerangel-msft
approved these changes
Apr 17, 2026
JoshLove-msft
approved these changes
Apr 17, 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.
TryBuildMethodArgumentsForOverloademits positional arguments when calling the current ModelFactory method from a backward-compat overload. When@@hierarchyBuildingreorders constructor parameters, positional args map to wrong positions, causing CS1503.Changes
ModelFactoryProvider.cs: Wrap matched parameters inPositionalParameterReferenceExpressionso all arguments are named, not just the defaulted ones for new parameters.ModelFactoryProviderTests.cs: Update existing assertion to expect named args. AddBackCompatibility_NewPropertyAddedWithDifferentParamOrdertest covering the reordered-params-plus-new-property scenario.Before:
After: