Skip to content

Linter: avoid Microsoft/Azure prefix on model / class names #4456

@haiyuazhang

Description

@haiyuazhang

Parent: #4442

Convention

Avoid using Microsoft, Azure prefixes for any models or classes.

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 164 decorators currently encoding this rule by hand. Examples:

  • AzureFunctionDefinitionInternalAzureFunctionDefinition (ai/Azure.AI.Agents/client.tsp)
  • AzureBlobContentSourceBlobContentSource (ai/DocumentIntelligence/client.tsp)
  • AzureBlobFileListContentSourceBlobFileListContentSource (ai/DocumentIntelligence/client.tsp)
  • AzureApiManagementSourceApiCenterApiManagementSource (apicenter/ApiCenter.Management/client.tsp)
  • AzureMonitorExporterApplicationInsightsRestClient (applicationinsights/data-plane/Exporters/client.tsp)
  • AzureLargeStorageInstanceLargeStorageInstance (azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/AzureLargeInstance/client.tsp)

Proposed linter

Detection

Flag any model whose name starts with Microsoft or Azure (case-sensitive). Allow well-known service identity types via a known-prefixed-types allowlist.

Auto-fix

Suggest dropping the prefix via @@clientName(..., "csharp").

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