Skip to content
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3e7122b
Add ARM use-update-for-patch lint rule
msyyc Oct 10, 2026
5d131d4
Move PATCH SDK naming guidance to TCGC common names
msyyc Oct 10, 2026
abeb615
feat(tcgc): add opt-in DELETE SDK naming rule
msyyc Oct 12, 2026
ef1e589
Address promotion review feedback
msyyc Oct 12, 2026
6475b75
Use ARM templates in DELETE naming rule documentation
msyyc Oct 13, 2026
e3785aa
Merge branch 'main' into promote-lintdiff-delete-in-operation-name
msyyc Oct 13, 2026
2af91d5
refactor(tcgc): share PATCH and PUT SDK verb-prefix checks
msyyc Oct 14, 2026
6f0eb98
refactor(tcgc): share DELETE and PUT SDK verb-prefix checks
msyyc Oct 14, 2026
5a9015b
test(tcgc): remove PATCH version and suppression-only fixtures
msyyc Oct 14, 2026
bdb8b3f
test(tcgc): remove DELETE suppression-only fixture
msyyc Oct 14, 2026
fee3ceb
Merge branch 'main' into promote-lintdiff-patch-in-operation-name
msyyc Oct 14, 2026
30ae8a4
Merge branch 'main' into promote-lintdiff-delete-in-operation-name
msyyc Oct 14, 2026
6fcf466
Share standalone ARM fixtures and isolate DELETE dependency proof
msyyc Oct 15, 2026
90e1e7d
Move native SDK linter emitter isolation to package integration tests
msyyc Oct 15, 2026
ed35661
Merge branch 'main' into promote-lintdiff-patch-in-operation-name
msyyc Oct 15, 2026
862100d
Merge branch 'main' into promote-lintdiff-delete-in-operation-name
msyyc Oct 15, 2026
380a163
Merge branch 'main' into promote-lintdiff-delete-in-operation-name
msyyc Oct 16, 2026
6b9be23
test(tcgc): simplify naming suites and package isolation
msyyc Oct 19, 2026
50c4b74
test(tcgc): simplify DELETE groups and package isolation
msyyc Oct 19, 2026
5fc361c
Merge branch 'main' into promote-lintdiff-delete-in-operation-name
msyyc Oct 19, 2026
8710828
Merge main and preserve rule inventory assertions for #5665
msyyc Oct 19, 2026
d121756
Consolidate PUT, PATCH, and DELETE SDK naming rules
msyyc Oct 20, 2026
e0ee4cd
Merge remote-tracking branch 'origin/main' into promote-lintdiff-dele…
Copilot Oct 20, 2026
a93d695
test(tcgc): remove redundant package isolation guard
msyyc Oct 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
Comment thread
msyyc marked this conversation as resolved.
Outdated
packages:
- "@azure-tools/typespec-client-generator-core"
---

Reuse unwrapped ARM test setup and retain emitter-isolation coverage in a dedicated integration test.
7 changes: 7 additions & 0 deletions .chronus/changes/register-use-delete-for-delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
packages:
- "@azure-tools/typespec-azure-rulesets"
---

Register the `@azure-tools/typespec-client-generator-core/use-delete-for-delete` lint rule as disabled in the `client-sdk` ruleset.
7 changes: 7 additions & 0 deletions .chronus/changes/review-delete-sdk-verb-prefix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: internal
Comment thread
msyyc marked this conversation as resolved.
Outdated
packages:
- "@azure-tools/typespec-client-generator-core"
---

Share package-private SDK verb-prefix traversal between DELETE and PUT naming rules.
7 changes: 7 additions & 0 deletions .chronus/changes/use-delete-for-delete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-client-generator-core"
---

Add the opt-in `use-delete-for-delete` lint rule requiring common SDK method names of concrete HTTP DELETE endpoints to start with `delete`, honoring unscoped client names and the supported friendly-name fallback.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default {
"@azure-tools/typespec-client-generator-core/csharp-model-suffix": true,
"@azure-tools/typespec-client-generator-core/use-union-hierarchy": true,
"@azure-tools/typespec-client-generator-core/get-operation-name": false,
"@azure-tools/typespec-client-generator-core/use-delete-for-delete": false,
Comment thread
msyyc marked this conversation as resolved.
Outdated
},
disable: {
"@azure-tools/typespec-client-generator-core/use-create-for-put":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ describe("expect all rules to be defined", () => {
ruleset.enable?.["@azure-tools/typespec-client-generator-core/get-operation-name"],
false,
);
strictEqual(
ruleset.enable?.["@azure-tools/typespec-client-generator-core/use-delete-for-delete"],
false,
);
ok(
ruleset.disable?.["@azure-tools/typespec-client-generator-core/csharp-use-standard-acronyms"],
);
Expand Down
1 change: 1 addition & 0 deletions packages/typespec-client-generator-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Available ruleSets:
| Name | Description |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`@azure-tools/typespec-client-generator-core/use-create-for-put`](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/use-create-for-put) | ARM PUT SDK method names should use 'create' as the verb prefix. |
| [`@azure-tools/typespec-client-generator-core/use-delete-for-delete`](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/use-delete-for-delete) | DELETE SDK method names should use 'delete' as the verb prefix. |
| [`@azure-tools/typespec-client-generator-core/require-client-suffix`](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/require-client-suffix) | Client names should end with 'Client'. |
| [`@azure-tools/typespec-client-generator-core/property-name-conflict`](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/property-name-conflict) | Avoid naming conflicts between a property and a model of the same name. |
| [`@azure-tools/typespec-client-generator-core/csharp-no-url-suffix`](https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/csharp-no-url-suffix) | Properties ending with 'Url' should use 'Uri' suffix instead to follow .NET naming conventions. |
Expand Down
2 changes: 2 additions & 0 deletions packages/typespec-client-generator-core/src/linter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ import { getOperationNameRule } from "./rules/get-operation-name.rule.js";
import { propertyNameConflictRule } from "./rules/property-name-conflict.rule.js";
import { requireClientSuffixRule } from "./rules/require-client-suffix.rule.js";
import { useCreateForPutRule } from "./rules/use-create-for-put.js";
import { useDeleteForDeleteRule } from "./rules/use-delete-for-delete.js";
import { useUnionHierarchyRule } from "./rules/use-union-hierarchy.js";

const rules = [
useCreateForPutRule,
useDeleteForDeleteRule,
requireClientSuffixRule,
propertyNameConflictRule,
csharpNoUrlSuffixRule,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { createRule, fileRef, paramMessage } from "@typespec/compiler";
import { getAllHttpServices } from "@typespec/http";
import { createTCGCContext } from "../context.js";
import { AllScopes } from "../internal-utils.js";
import { getLibraryName } from "../public-utils.js";
import { getOperationsWithIncorrectVerbPrefix } from "./verb-prefix.js";

export const useCreateForPutRule = createRule({
name: "use-create-for-put",
Expand All @@ -22,24 +20,15 @@ export const useCreateForPutRule = createRule({

return {
root: () => {
const [services] = getAllHttpServices(context.program);
for (const service of services) {
for (const { operation, verb } of service.operations) {
if (verb !== "put") {
continue;
}

// Check the common SDK name, leaving emitter-specific overrides to emitter rules.
const operationName = getLibraryName(tcgcContext, operation, AllScopes);
if (operationName.toLowerCase().startsWith("create")) {
continue;
}

context.reportDiagnostic({
target: operation,
format: { operationName },
});
}
for (const { operation, operationName } of getOperationsWithIncorrectVerbPrefix(
Comment thread
msyyc marked this conversation as resolved.
Outdated
tcgcContext,
"put",
"create",
)) {
context.reportDiagnostic({
target: operation,
format: { operationName },
});
}
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
Use an SDK method name beginning with `delete` for HTTP DELETE operations, such as
`delete` or `deleteWidget`. Consistent names make deletion methods easier to
discover in generated clients.

The rule checks the common TCGC SDK method name case-insensitively on concrete
HTTP service endpoints. It applies to ARM and data-plane services without requiring
`@armProviderNamespace`, and is disabled by default in the `client-sdk` ruleset.
Client-only declarations that are not service endpoints are not checked.

Name resolution uses TCGC's `getLibraryName` with `AllScopes`, including an
unscoped `@clientName`, exact names, and the supported `@friendlyName` fallback.
Overrides applying only to a particular language, such as
`@clientName("remove", "csharp")`, do not replace the common name.

The source program is checked without selecting an emitter or an API-version
projection. Historical names supplied through `@renamedFrom` are not reconstructed.

The following ARM examples use the standard
[resource delete operation template](https://azure.github.io/typespec-azure/docs/howtos/ARM/resource-operations#resource-delete-operations-delete).
The template supplies the DELETE route and response; the operation alias supplies
the SDK method name. The same naming requirement applies to data-plane services.

Use this shared setup before each example:

```typespec
import "@typespec/http";
import "@typespec/rest";
import "@azure-tools/typespec-azure-resource-manager";
import "@azure-tools/typespec-client-generator-core";

using TypeSpec.Http;
using TypeSpec.Rest;
using Azure.ResourceManager;
using Azure.ClientGenerator.Core;

@armProviderNamespace
@service
@armCommonTypesVersion(CommonTypes.Versions.v5)
namespace Example;

model Widget is ProxyResource<WidgetProperties> {
@key("widgetName") @segment("widgets") name: string;
}

model WidgetProperties {}
```

#### ❌ Incorrect

```typespec
@armResourceOperations
interface Widgets {
remove is ArmResourceDeleteSync<Widget>;
}
```

#### ✅ Correct

```typespec
@armResourceOperations
interface Widgets {
delete is ArmResourceDeleteSync<Widget>;
}
```

## Impact

- **Area:** SDK

Renaming a method in an already-shipped SDK may introduce a breaking change.
Review compatibility before changing existing names.

An unscoped `@clientName` can provide the correct SDK name without renaming the
TypeSpec operation:

```typespec
@armResourceOperations
interface Widgets {
@clientName("deleteWidget")
remove is ArmResourceDeleteSync<Widget>;
}
```

The shared setup imports `@azure-tools/typespec-client-generator-core` and uses
`Azure.ClientGenerator.Core` to make `@clientName` available.

## Suppression

Suppression is appropriate when preserving an already-shipped SDK method name
requires an exception approved by the API reviewer. For new methods, fix the
name instead, either by renaming the operation or using an unscoped `@clientName`.
Use `#suppress` on the operation with a justification for the compatibility
exception:

```typespec
@armResourceOperations
interface Widgets {
#suppress "@azure-tools/typespec-client-generator-core/use-delete-for-delete" "Preserve the already-shipped SDK method name."
remove is ArmResourceDeleteSync<Widget>;
}
```

## LintDiff Equivalent

This rule enforces the SDK naming intent of
[`DeleteInOperationName`](https://github.com/Azure/azure-openapi-validator/blob/main/docs/delete-in-operation-name.md).
It does not reproduce serialized `operationId` underscore or group-prefix
exemptions. Explicit OpenAPI operation IDs do not change the common SDK method
name checked by this rule. The lintdiff source checks authored operation names;
the promoted rule intentionally checks common SDK names, including unscoped
SDK name overrides.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { createRule, fileRef, paramMessage } from "@typespec/compiler";
import { createTCGCContext } from "../context.js";
import { getOperationsWithIncorrectVerbPrefix } from "./verb-prefix.js";

export const useDeleteForDeleteRule = createRule({
name: "use-delete-for-delete",
description: "DELETE SDK method names should use 'delete' as the verb prefix.",
severity: "warning",
url: "https://azure.github.io/typespec-azure/docs/libraries/typespec-client-generator-core/rules/use-delete-for-delete",
docs: fileRef.fromPackageRoot("src/rules/use-delete-for-delete.md"),
messages: {
default: paramMessage`DELETE SDK method name '${"operationName"}' should start with 'delete'.`,
},
create(context) {
const tcgcContext = createTCGCContext(
context.program,
"@azure-tools/typespec-client-generator-core",
{ mutateNamespace: false },
);

return {
root: () => {
for (const { operation, operationName } of getOperationsWithIncorrectVerbPrefix(
tcgcContext,
"delete",
"delete",
)) {
context.reportDiagnostic({
target: operation,
format: { operationName },
});
}
},
};
},
});
22 changes: 22 additions & 0 deletions packages/typespec-client-generator-core/src/rules/verb-prefix.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Operation } from "@typespec/compiler";
import { getAllHttpServices, type HttpVerb } from "@typespec/http";
import type { TCGCContext } from "../interfaces.js";
import { AllScopes } from "../internal-utils.js";
import { getLibraryName } from "../public-utils.js";

export function* getOperationsWithIncorrectVerbPrefix(
context: TCGCContext,
verb: HttpVerb,
prefix: string,
): Iterable<{ operation: Operation; operationName: string }> {
const [services] = getAllHttpServices(context.program);
for (const service of services) {
for (const endpoint of service.operations) {
if (endpoint.verb !== verb) continue;
const operationName = getLibraryName(context, endpoint.operation, AllScopes);
if (!operationName.toLowerCase().startsWith(prefix)) {
yield { operation: endpoint.operation, operationName };
}
}
}
}
Loading
Loading