Open
Conversation
Contributor
|
No changes needing a change description found. |
Contributor
|
Can we add an E2E example in the sample tsp? |
…ameter bug Add an E2E example demonstrating @paramAlias with @clientInitialization in the Sample-TypeSpec project. The Notebooks interface shows a client parameter 'notebook' aliased to the operation's 'notebookName' path parameter. Fix a bug in GetAllClientParameters() where operation parameters superseded by a client parameter via @paramAlias/@clientInitialization were not being deduplicated, causing duplicate constructor parameters in generated code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
commit: |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
...ypeSpec.Generator.ClientModel/test/Providers/ClientProviders/ClientProviderSubClientTests.cs
Show resolved
Hide resolved
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
Add three tests in ClientProviderTests.cs for paramAlias on regular (non-subclient) clients: - Aliased parameter deduplicates correctly (1 field, not 2) - Without alias, both distinct parameters are kept - Same-name parameters deduplicate by name even without alias Also fix GetAllClientParameters() to include paramAlias values when building the client parameter name set for deduplication. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test verifying that generated operation methods do not include parameters that match an aliased client parameter, since those are sourced from the client field instead. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Previously, alias names were added to the parent parameter name set, which could accidentally match unrelated parameters that happen to share the same name. Now we use IsParameterAliasedByParent() to only match when a parent parameter's ParamAlias directly references the parameter in question. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
Contributor
|
I think you may need to sync from main and regen |
- Remove IsParameterAliasedByParent, inline alias handling into name sets - Reuse IsSupersededByClientParameter in HasAccessorOnlyParameters and subclient constructor arg logic - Add alias to clientParamNames in GetAllClientParameters so the IsParameterAliasedByParent call is no longer needed Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Outdated
Show resolved
Hide resolved
...nt-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/ClientProvider.cs
Show resolved
Hide resolved
JoshLove-msft
approved these changes
Mar 18, 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.
This pull request introduces support for the
@paramAliasdecorator in the C# HTTP client generator, enabling client parameters to be referenced by an alias when specified. The changes ensure that aliasing is respected throughout code generation, parameter matching, and testing, improving consistency and correctness when using parameter aliases in client models and operations.Support for
@paramAliasdecorator:paramAliasproperty to theInputMethodParametertype and ensured it is serialized/deserialized correctly in the generator input and output.Parameter matching and code generation improvements:
Modified logic in
ClientProviderandRestClientProviderto consider both parameter names and aliases when determining shared parameters between parent and subclient, and when mapping client parameters to operation parameters.Testing enhancements:
Added unit tests to verify correct handling of
paramAliasin client initialization and parameter matching, including scenarios where aliases are present or absent.Test infrastructure updates:
Extended
InputFactory.MethodParameterto accept aparamAliasargument for easier test setup and validation.