Add warning for unused client initialization parameters#3763
Add warning for unused client initialization parameters#3763
Conversation
…parameters Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
|
@copilot fix build failures |
Co-authored-by: iscai-msft <43154838+iscai-msft@users.noreply.github.com>
Fixed in commit 3a28190. The build failures were caused by:
Changes made:
All 1098 tests now pass including the 8 new tests for unused client initialization parameter warnings. |
…opilot/fix-unused-client-params-warning
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
tadelesh
left a comment
There was a problem hiding this comment.
The validation should not apply to all clients since the parameter gathering iteration will cause perf issue. We should check it only when there is customized client initialization parameter. Another problem for this PR is it does not take @paramAlias into account.
| >(context: TCGCContext, client: SdkClientType<TServiceOperation>): void { | ||
| // Only validate when there's a customized @clientInitialization decorator with parameters | ||
| // Skip validation for default/auto-generated client initialization | ||
| if (!client.clientInitialization.__raw) { |
There was a problem hiding this comment.
Oh, I just found a problem for this skip. This will also skip the check for nested clients with client initialization customization.
tadelesh
left a comment
There was a problem hiding this comment.
@iscai-msft I missed some comments when approval. I could not fine the dismiss button. So, please check my new comments before merge. Thanks.
| for (const path of param.methodParameterSegments) { | ||
| for (const methodParam of path) { | ||
| if (methodParam.kind === "method" && methodParam.onClient) { | ||
| parameterNames.add(methodParam.name); |
There was a problem hiding this comment.
You should not add name, but just add instance.
| // Check each custom client initialization parameter | ||
| for (const param of customParams) { | ||
| // Check if this parameter is used in any operation | ||
| if (!allOperationParameterNames.has(param.name)) { |
There was a problem hiding this comment.
You could use instance check directly since the methodParameterSegments stores the direct reference, which could resolve potential naming and alias issue.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.