[tcgc] add functions to help with override story#3995
[tcgc] add functions to help with override story#3995iscai-msft wants to merge 25 commits intoAzure:mainfrom
Conversation
…cgc/addReplaceDecorator
…arate file - Move replaceParameter from decorators.tsp to new lib/functions.tsp - Add replaceResponse function to replace operation return types - Add addParameter function to add parameters to operations - Add tests for all three functions (23 total tests) - Add documentation page for functions (experimental) - Update reference index to link to functions documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
commit: |
|
All changed packages have been documented.
Show changes
|
|
You can try these changes here
|
- Use createClientCustomizationInput and createSdkContextForTester pattern - Verify method parameters, optionality, types - Verify operation-to-method parameter mappings (correspondingMethodParams) - Test scoped overrides (Python vs C#) - Remove complex nested namespace tests that hit TCGC edge cases Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove functions.md from tcgc reference section - Add comprehensive @OverRide section to 04method.mdx - Document transformation functions (replaceParameter, addParameter, replaceResponse) - Add multi-language examples with ClientTabs Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…cgc/addReplaceDecorator
tadelesh
left a comment
There was a problem hiding this comment.
Several high level concerns:
- In what scenario we need to add a parameter in client level? How should the added parameter be used in the client code? There will be no mapping for it on wire.
- Shall we only allow to remove the optional parameter? Is there any other limitation we should add?
- Same concern for replace. I don't think any replacement could work here.
Here I'm relying on the validation from |
tadelesh
left a comment
There was a problem hiding this comment.
Generally LGTM. In ARM, we have a brown field frequent user scenario: adjust parameter order to prevent SDK breaking change. Is it possible to add a function to help with that requirement?
packages/typespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.ts
Outdated
Show resolved
Hide resolved
…cgc/addReplaceDecorator
…sft/typespec-azure into tcgc/addReplaceDecorator
There was a problem hiding this comment.
Pull request overview
Adds experimental TypeSpec extern functions to enable composable @@override-based method signature customization in generated client SDKs, along with docs and tests.
Changes:
- Introduces
replaceParameter,addParameter, andreorderParametersextern functions and exports them via$functions. - Adds diagnostics and Vitest coverage for the new transformation functions.
- Documents
@@overrideusage patterns and transformation chaining in the client library generation how-to.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| website/src/content/docs/docs/howtos/Generate client libraries/04method.mdx | Adds documentation for @@override and the new transformation functions. |
| packages/typespec-client-generator-core/tsconfig.build.json | Excludes additional test filename patterns from build compilation. |
| packages/typespec-client-generator-core/test/functions/replace-parameter.test.ts | Adds tests for replaceParameter behavior and scoped overrides. |
| packages/typespec-client-generator-core/test/functions/reorder-parameters.test.ts | Adds tests for reorderParameters, chaining, and diagnostics. |
| packages/typespec-client-generator-core/test/functions/add-parameter.test.ts | Adds tests for addParameter, chaining, and scoped overrides. |
| packages/typespec-client-generator-core/src/tsp-index.ts | Exports implementations via $functions for TypeSpec extern function binding. |
| packages/typespec-client-generator-core/src/lib.ts | Adds new diagnostics for replace/reorder parameter validation. |
| packages/typespec-client-generator-core/src/index.ts | Exports $functions in addition to $decorators. |
| packages/typespec-client-generator-core/src/functions.ts | Implements the three operation transformation functions. |
| packages/typespec-client-generator-core/lib/main.tsp | Imports the new functions.tsp into the library surface. |
| packages/typespec-client-generator-core/lib/functions.tsp | Declares the extern function signatures and docs in TypeSpec. |
| packages/typespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.ts-test.ts | Adds compile-time export/signature checks for $functions. |
| packages/typespec-client-generator-core/generated-defs/Azure.ClientGenerator.Core.ts | Extends generated defs with function implementation types. |
| .chronus/changes/tcgc-addReplaceDecorator-2026-2-2-16-3-32.md | Adds changelog entry for the new experimental extern functions. |
website/src/content/docs/docs/howtos/Generate client libraries/04method.mdx
Outdated
Show resolved
Hide resolved
website/src/content/docs/docs/howtos/Generate client libraries/04method.mdx
Show resolved
Hide resolved
…/04method.mdx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…sft/typespec-azure into tcgc/addReplaceDecorator
| * This function creates a new operation with the specified parameter replaced, | ||
| * enabling composable transformations without mutating the original operation. | ||
| * | ||
| * Note: Parameter removal (using `void` as replacement) is not supported when used with `@@override`. |
There was a problem hiding this comment.
If I recalled correctly, we do have a case to remove optional parameter for key vault? See playground.
…cgc/addReplaceDecorator
No description provided.