Skip to content

Linter: enforce two-letter acronym casing (DbDB, IpIP, OsOS, …) with Vm/Id exceptions #4458

@haiyuazhang

Description

@haiyuazhang

Parent: #4442

Convention

Two-letter acronyms should be all-uppercase when not part of longer compound identifiers, with exceptions like Vm, Id.

Source: Azure SDK for .NET Mgmt Naming Conventions

Observed today

A scan of Azure/azure-rest-api-specs (334 client.tsp files, 10,754 csharp-scoped @@clientName decorators) shows 221 decorators currently encoding this rule by hand. Examples:

  • VirtualMachineScaleSetIpTagComputeFleetVmssIPTag (azurefleet/resource-manager/Microsoft.AzureFleet/AzureFleet/client.tsp)
  • IpAddressLargeInstanceIPAddress (azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/AzureLargeInstance/client.tsp)
  • cosmosDbResourceIdcosmosDBResourceId (agricultureplatform/AgriculturePlatform.Management/client.tsp)
  • CosmosDbCosmosDB (billingbenefits/BillingBenefits.Management/client.tsp)
  • OsProfileLargeInstanceOSProfile (azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/AzureLargeInstance/client.tsp)
  • HciOsProfileHciOSProfile (azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/client.tsp)

Proposed linter

Detection

Walk all model / property / parameter / enum names. Flag any segment matching the acronym dictionary (Db, Ip, Os, Sql, Url, Uri, Tls, Ssl, Cpu, Gpu, Dns, Tcp, Udp, Sas, Aks, Acl, Api, Http, Https, Xml, Json, ...) where the canonical .NET casing is fully upper. Honor exceptions: Vm, Id.

Auto-fix

Insert @@clientName(..., "csharp") with the corrected acronym casing.

Scope

The rule should be csharp-scoped — it only flags violations of the .NET convention, not the underlying TypeSpec name. It should suggest inserting a @@clientName(..., "csharp") override when the underlying TypeSpec name is intentional, or renaming the TypeSpec model when the convention applies cross-language.

Acceptance criteria

  • New lint rule registered in the appropriate ruleset (@azure-tools/typespec-client-generator-core or @azure-tools/typespec-azure-resource-manager).
  • Doc page under website/src/content/docs/docs/libraries/.../rules/.
  • Unit tests covering positive / negative cases and the auto-fix.
  • A .chronus/changes/ entry.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or requestlib:tcgcIssues for @azure-tools/typespec-client-generator-core library

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions