Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
35 changes: 35 additions & 0 deletions eng/common/knowledge/customizing-client-tsp.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,3 +473,38 @@ interface MyClient {
```

This reference provides the essential patterns and decorators for TypeSpec client customizations. Focus on the core decorators (`@client`, `@operationGroup`, `@@clientLocation`, `@@clientName`, `@@access`) for most scenarios, and use advanced features selectively.
---

## When TypeSpec Isn't Enough: Code Customizations

TypeSpec customizations (`client.tsp`) should be your **first choice** for SDK customization - they're clean, documented, and survive regeneration.

For scenarios that TypeSpec cannot express, each language has its own post-generation code customization approach. Refer to the language-specific documentation below.

### Language-Specific Code Customization Guides

When you need post-generation customizations, refer to the language-specific documentation:

| Language | Documentation | Pattern |
|----------|--------------|---------|
| **C#** | [C# Customization Guide](https://github.com/microsoft/typespec/blob/main/packages/http-client-csharp/.tspd/docs/customization.md) | Partial classes with `[CodeGenType]`, `[CodeGenMember]`, `[CodeGenSerialization]` attributes |
| **Python** | [Python Customization Guide](https://github.com/Azure/autorest.python/blob/main/docs/customizations.md) | `_patch.py` files at models, operations, and client levels |
| **Java** | [Java Customization Guide](https://github.com/Azure/autorest.java/blob/main/customization-base/README.md) | `Customization` class with `customizeAst()` method |
| **JavaScript** | [JS Customization Guide](https://github.com/Azure/azure-sdk-for-js/wiki/Modular-(DPG)-Customization-Guide) | Copy `src/` to `generated/`, add customizations in `src/` |
| **Go** | [Go Customization Guide](https://github.com/Azure/azure-sdk-for-go/blob/main/documentation/development/generate.md) | Prefer TypeSpec; use custom wrapper files for advanced cases |

### Decision Flow

```
Need to customize SDK?
Can it be done in TypeSpec?
┌────┴────┐
Yes No
│ │
▼ ▼
Use client.tsp Use code customization
decorators (see language guide above)
```
2 changes: 1 addition & 1 deletion eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function Set-ApiViewCommentForPR {
try {
$existingComment = Get-GitHubIssueComments -RepoOwner $RepoOwner -RepoName $RepoName -IssueNumber $PrNumber -AuthToken $AuthToken
$existingAPIViewComment = $existingComment | Where-Object {
$_.body.StartsWith("**API Change Check**", [StringComparison]::OrdinalIgnoreCase) -or $_.body.StartsWith("## API Change Check", [StringComparison]::OrdinalIgnoreCase) }
$_.body.StartsWith("**API Change Check**", [StringComparison]::OrdinalIgnoreCase) -or $_.body.StartsWith("## API Change Check", [StringComparison]::OrdinalIgnoreCase) } | Select-Object -Last 1
} catch {
LogWarning "Failed to get comments from Pull Request: $PrNumber in repo: $repoFullName"
}
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/Verify-Readme.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param (
[string]$SettingsPath
)
. (Join-Path $PSScriptRoot common.ps1)
$DefaultDocWardenVersion = "0.7.2"
$DefaultDocWardenVersion = "0.7.3"
$script:FoundError = $false

function Test-Readme-Files {
Expand Down
Loading