Skip to content

Linter: avoid single-word class names — must be descriptive #4457

@haiyuazhang

Description

@haiyuazhang

Parent: #4442

Convention

DO Avoid using single-word class names. Use more descriptive names after consulting with the service development team. DO NOT duplicate names across different RPs.

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

  • ControlRecommendationControlType (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • DurationAdvisorLowCpuEvaluationDuration (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • CategoryRecommendationCategory (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • ImpactRecommendationBusinessImpact (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • PriorityRecommendationPriority (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)
  • ReasonRecommendationStateChangeReason (advisor/resource-manager/Microsoft.Advisor/Advisor/client.tsp)

Proposed linter

Detection

Flag any exported model whose csharp name is a single PascalCase word matching one of a curated dictionary of generic terms (Resource, Connector, Control, Category, Duration, Impact, Priority, Status, Type, Settings, Properties, ...), OR which collides with a model from another RP (cross-spec check).

Auto-fix

Suggest a service-prefixed name via @@clientName(..., "csharp"). Cross-spec collision detection can run in a separate sweep.

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