Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
8d2c8c5
Promote latest common types lint rule
msyyc Aug 20, 2026
440a51d
Disable latest common types rule by default
msyyc Aug 20, 2026
841b6f3
Address common types rule review
msyyc Aug 21, 2026
d8b8176
Apply TypeSpec rule naming conventions
msyyc Aug 21, 2026
09df69b
Update generated linter docs
msyyc Aug 21, 2026
5abd4bf
Address common types rule review feedback
msyyc Aug 25, 2026
f15a77b
Avoid global mutation in common types rule
msyyc Aug 31, 2026
9661c68
Update resource-manager.ts
msyyc Aug 31, 2026
ea6fd2e
Update use-latest-version-of-common-types.md
msyyc Aug 31, 2026
2e4edd8
Revise title for common types version rule
msyyc Aug 31, 2026
dfba9ba
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Sep 1, 2026
2ad5611
Fix promotion changelog classification
msyyc Sep 8, 2026
aeb0eab
Merge main into promote-latest-version-common-types-to-arm
msyyc Sep 8, 2026
3e13a32
Use native ARM common type records in latest-version rule
msyyc Sep 14, 2026
473a14a
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Sep 14, 2026
da46ae1
Add common types rule to ARM inventory
msyyc Sep 14, 2026
ec664c4
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Sep 15, 2026
7c1764c
Report common type resolution failures through linter context
msyyc Sep 18, 2026
84bfa97
Merge main and preserve both ARM linter additions
msyyc Sep 18, 2026
1722f99
Consolidate latest common-types guidance into existing ARM rule
msyyc Sep 20, 2026
fe18bdd
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Sep 20, 2026
db29d80
Fix ARM sample CI for latest common-types guidance
msyyc Sep 20, 2026
f4fc394
Add v6 common-type fixtures for ARM sample references
msyyc Sep 20, 2026
cf74184
Keep common-types release note focused on native behavior
msyyc Sep 24, 2026
225feb8
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Sep 24, 2026
e1dc441
test(arm): focus lint coverage on rule-owned behavior
msyyc Sep 28, 2026
e65ad34
Merge main and resolve ARM rule inventory conflict
msyyc Oct 13, 2026
d22e03b
Remove private common-types fixture and restore merged compiler cohort
msyyc Oct 19, 2026
6bbbaca
Merge main and preserve rule inventory assertions for #5271
msyyc Oct 19, 2026
94ec559
docs(arm): focus common-types version selection guidance
msyyc Oct 21, 2026
f1959f4
Merge main and preserve common-types and opt-in rule assertions
msyyc Oct 21, 2026
6f682ca
test(azure-resource-manager): assert common-types diagnostic locations
msyyc Oct 21, 2026
b49afec
chore: simplify common-types migration after #5787
msyyc Oct 30, 2026
ea7ecc6
Merge branch 'main' into promote-latest-version-common-types-to-arm
msyyc Oct 30, 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,11 @@
---
changeKind: feature
packages:
- "@azure-tools/typespec-azure-resource-manager"
---

Extend `arm-common-types-version` to warn when an ARM service or API version selects an older common-types version, while preserving the existing warning for missing explicit version configuration.

Latest-version warnings are now active wherever this existing rule is enabled, including the resource-manager ruleset. Update `@armCommonTypesVersion` to the latest version in `Azure.ResourceManager.CommonTypes.Versions`, or suppress `@azure-tools/typespec-azure-resource-manager/arm-common-types-version` when an older version is required for compatibility.

The rule checks effective version selections only.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2021-10-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@Azure.Core.previewVersion
`2021-10-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Microsoft.UpdateTests;
/** UpdateTests API versions */
enum Versions {
/** 2023-03-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "This sample intentionally mixes v3 common types with the legacy v4 managed identity."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3)
@previewVersion
`2023-03-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2021-10-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@Azure.Core.previewVersion
`2021-10-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2025-11-19-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@previewVersion
`2025-11-19-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace Microsoft.OptionalBody;
interface Operations extends Azure.ResourceManager.Operations {}

enum Versions {
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@Azure.Core.previewVersion
`2025-01-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2021-10-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@Azure.Core.previewVersion
`2025-10-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2021-10-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@previewVersion
`2021-10-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.ContosoProviderHub;
/** Contoso API versions */
enum Versions {
/** 2021-10-01-preview version */
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@previewVersion
`2021-10-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace Microsoft.RenamedOperations;
interface Operations extends Azure.ResourceManager.Operations {}

enum Versions {
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@Azure.Core.previewVersion
`2025-01-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.ContosoProviderHub;
interface Operations extends Azure.ResourceManager.Operations {}

enum Versions {
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Preserve older common-types schemas for this grandfathered API sample."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@previewVersion
`2025-06-01-preview`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ namespace Microsoft.PrivateLinkTest;

@doc("The PrivateLinkTest service versions.")
enum Versions {
#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "This sample demonstrates private-link schema compatibility across older common-types versions."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4)
@doc("The 2023-08-01 version.")
`2023-08-01`,

#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "This sample demonstrates private-link schema compatibility across older common-types versions."
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@doc("The 2023-11-01-preview version.")
@Azure.Core.previewVersion
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-azure-resource-manager/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Available ruleSets:
| [`@azure-tools/typespec-azure-resource-manager/arm-no-path-casing-conflicts`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-no-path-casing-conflicts) | Operation paths must be unique when compared case-insensitively. |
| [`@azure-tools/typespec-azure-resource-manager/scope-path-segment-casing`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/scope-path-segment-casing) | ARM paths must use the canonical subscriptions and resourceGroups segment casing. |
| [`@azure-tools/typespec-azure-resource-manager/no-override-props`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/no-override-props) | Disallow redefining properties already defined in a base type. |
| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-common-types-version) | Specify the ARM common-types version using @armCommonTypesVersion. |
| [`@azure-tools/typespec-azure-resource-manager/arm-common-types-version`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-common-types-version) | Specify the latest ARM common-types version using @armCommonTypesVersion. |
| [`@azure-tools/typespec-azure-resource-manager/arm-delete-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-delete-operation-response-codes) | Ensure delete operations have the appropriate status codes. |
| [`@azure-tools/typespec-azure-resource-manager/arm-put-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-put-operation-response-codes) | Ensure put operations have the appropriate status codes. |
| [`@azure-tools/typespec-azure-resource-manager/arm-post-operation-response-codes`](https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-post-operation-response-codes) | Ensure post operations have the appropriate status codes. |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
If the same common types version is used across all service versions, this decorator should be applied either on the service namespace or on each version enum member. If the common types version is updated in later versions, the decorator should appear on each version enum member.
ARM services should explicitly select the latest version in
`Azure.ResourceManager.CommonTypes.Versions` using `@armCommonTypesVersion`.
Apply the decorator to the service namespace when all API versions use the same
common-types version. A decorator on an API version enum member overrides the
namespace selection for that API version.

The rule warns when explicit version configuration is missing or when an
effective selection is older than the latest available version. It checks
version selections, not individual legacy type usages.

## Impact

- **Area:** API, SDK

Indicates common-types are not being used, which normally surfaces as other violations too.
Missing or outdated common-types selections can leave an API and its generated
SDKs using older shared schemas and parameters. Latest-version warnings are
enabled wherever this rule is enabled, including the resource-manager ruleset.

## ❌ Incorrect

Expand All @@ -13,33 +23,47 @@ Indicates common-types are not being used, which normally surfaces as other viol
namespace Microsoft.Contoso;
```

## ✅ Correct

Apply `@armCommonTypesVersion` on the namespace:
An explicit older selection also produces a warning:

```tsp
@armProviderNamespace
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v3)
namespace Microsoft.Contoso;
```

## ✅ Correct (per version)
## ✅ Correct

Apply `@armCommonTypesVersion` on each version enum member:
Select the latest version on the service namespace:

```tsp
@armProviderNamespace
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v6)
namespace Microsoft.Contoso;
```

enum Versions {
@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v4)
v1,
Alternatively, apply `@armCommonTypesVersion` to every API version enum member
instead of the namespace. Every effective selection must use the latest version
to satisfy this rule.

@armCommonTypesVersion(Azure.ResourceManager.CommonTypes.Versions.v5)
v2,
}
```
As of August 2026, `v6` was the latest ARM common-types version.
Newer versions may exist; check `Azure.ResourceManager.CommonTypes.Versions`
before updating a service.

## LintDiff Equivalent

This rule covers the version-selection guidance of
[`LatestVersionOfCommonTypesMustBeUsed`](https://github.com/Azure/azure-openapi-validator/blob/main/docs/latest-version-of-common-types-must-be-used.md).
Unlike the OpenAPI rule, it does not inspect emitted common-type references.

## Suppression

Suppress only if no common-types are ever used and that is valid; otherwise associate a common-types version with each version in the Versions enum.
Prefer updating `@armCommonTypesVersion` to the latest version. Suppress only
when an older version is required for compatibility and the API and SDK impact
has been accepted, or when no common-types are used and omitting the selection
is intentional.

Place `#suppress "@azure-tools/typespec-azure-resource-manager/arm-common-types-version" "Compatibility justification"`
above the service namespace for missing configuration or an unversioned
selection, or above the affected API version enum member for a versioned
selection. Suppressing the rule also suppresses its missing-configuration check
within that scope.
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
import { type Program, type SemanticNodeListener, createRule, fileRef } from "@typespec/compiler";
import { getAllHttpServices } from "@typespec/http";
import {
type Program,
type SemanticNodeListener,
createRule,
fileRef,
listServices,
paramMessage,
} from "@typespec/compiler";
import { getVersion } from "@typespec/versioning";
import { getArmCommonTypesVersion, getArmCommonTypesVersions } from "../common-types.js";
import { getArmProviderNamespace } from "../namespace.js";

/**
* The @armCommonTypesVersion decorator should be used to set the ARM
* common-types version used by the service.
* The @armCommonTypesVersion decorator should select the latest ARM common-types version.
*/
export const armCommonTypesVersionRule = createRule({
name: "arm-common-types-version",
docs: fileRef.fromPackageRoot("src/rules/arm-common-types-version.md"),
severity: "warning",
description: "Specify the ARM common-types version using @armCommonTypesVersion.",
description: "Specify the latest ARM common-types version using @armCommonTypesVersion.",
url: "https://azure.github.io/typespec-azure/docs/libraries/azure-resource-manager/rules/arm-common-types-version",
messages: {
default:
"Specify the ARM common-types version using the @armCommonTypesVersion decorator on the service namespace or on each version of the service version enum.",
outdated: paramMessage`Use the latest ARM common-types version '${"latestVersion"}' instead of '${"currentVersion"}'.`,
},
create(context): SemanticNodeListener {
return {
root: (program: Program) => {
const [services, _] = getAllHttpServices(program);
for (const service of services) {
if (!getArmProviderNamespace(program, service.namespace)) {
// The common-types registry stores versions newest first.
const latestVersion = getArmCommonTypesVersions(program)?.allVersions[0]?.name;
Comment thread
msyyc marked this conversation as resolved.
Resolved
for (const { type: namespace } of listServices(program)) {
if (!getArmProviderNamespace(program, namespace)) {
continue;
}

const versionMap = getVersion(program, service.namespace);
const versionMap = getVersion(program, namespace);
// If the namespace is versioned and not all versions have the
// common-types version and if the service namespace doesn't have a
// common-types version, raise a diagnostic.
Expand All @@ -42,13 +50,32 @@ export const armCommonTypesVersionRule = createRule({
),
)
) &&
!service.namespace.decorators.find(
(x) => x.definition?.name === "@armCommonTypesVersion",
)
!namespace.decorators.find((x) => x.definition?.name === "@armCommonTypesVersion")
) {
context.reportDiagnostic({
target: service.namespace,
messageId: "default",
target: namespace,
});
continue;
}

if (latestVersion === undefined) {
continue;
}

const namespaceVersion = getArmCommonTypesVersion(program, namespace);
const targets = versionMap
? versionMap.getVersions().map((version) => version.enumMember)
: [namespace];
for (const target of targets) {
const currentVersion = getArmCommonTypesVersion(program, target) ?? namespaceVersion;
if (currentVersion !== undefined && currentVersion !== latestVersion) {
context.reportDiagnostic({
messageId: "outdated",
target,
format: { latestVersion, currentVersion },
});
}
}
}
},
Expand Down
Loading
Loading