Skip to content

Deterministic/static name translation improvements in the .NET management generator #61941

Description

@weikanglim

Move naming changes that can be derived mechanically from the identifier, type,
or operation structure into Azure.Generator.Management. Align TypeSpec
linters with the generator, then remove redundant C# clientName decorators
after proving generated APIs are unchanged.

Tasks

# Task Main files Impact Effort
1 Implement IP/DB/OS and IPv4/IPv6 normalization NameVisitor.cs, NameVisitorTests.cs 945 decorators / 3,181 lines Medium
2 Extend acronym normalization to remaining symbol surfaces Generator visitor/provider files and tests At least 42 decorators / 90 lines Medium
3 Extend Url -> Uri to operations and enum/union values Generator visitor/provider files and tests 14 decorators / 22 lines Small/medium
4 Complete deterministic date/time naming NameVisitor.cs, method-parameter providers, tests 45 decorators / 165 lines Medium
5 Align and enable TypeSpec linters typespec-azure C# rules, tests, and client-sdk.ts Prevents new overrides Small per rule
6 Remove redundant decorators in project batches azure-rest-api-specs client.tsp files Realizes the reductions above Mechanical/high

Line-count note: "Lines" counts the physical lines occupied by matching
@@clientName statements in the current client.tsp files. A multi-line
decorator counts every line from its start through its end; surrounding blank
lines, comments, and imports are excluded. These are removable specification
lines, not generated SDK lines, and upper-bound categories may overlap.

1. Implement acronym normalization

Add one boundary-aware final-name normalizer for:

  • Ip -> IP
  • Db -> DB
  • Os -> OS
  • Ipv4 -> IPv4
  • Ipv6 -> IPv6

Apply it to model, extensible-enum/union type, enum type, and model-property
providers. Support repeated occurrences and preserve longer words such as
Oslo, Ipsum, Osmosis, and dbz.

Keep IPV4/IPV6 unchanged because an existing explicit IPV4Address name is a
public compatibility case.

Status: Implemented in draft PR
Azure/azure-sdk-for-net#61947;
42 focused tests pass.

2. Cover remaining acronym surfaces

Add the provider/visitor hooks needed for:

  • Enum and union members.
  • Client names.
  • Operation names.
  • Method parameters.

Keep this separate from Task 1 because these surfaces require different
generator plumbing.

3. Complete Url -> Uri

Reuse the existing suffix transformation for:

  • Operation names: 9 decorators / 13 lines.
  • Enum and union values: 5 decorators / 9 lines.

Only transform a complete Url suffix.

4. Complete date/time naming

Deliver as small changes:

  1. Typed Timestamp/TimeStamp -> On: 37 decorators / 149 lines.
  2. Exact typed Date -> On: 6 decorators / 6 lines.
  3. Date-time method parameters: 2 decorators / 10 lines.

Require a resolved date/time type. Do not rename date-looking strings.

5. Align TypeSpec linters

For each shipped generator rule:

  1. Make the TypeSpec linter suggest the same output.
  2. Add matching positive and negative test vectors.
  3. Keep the rule disabled until the generator version is available in spec CI.
  4. Re-enable the rule in the client-sdk ruleset.

The acronym linter must support Ipv4/Ipv6 -> IPv4/IPv6 without auto-fixing
IPV4/IPV6.

6. Remove redundant specification decorators

After each generator change ships:

  1. Remove only decorators reproduced by the production generator.
  2. Batch changes by TypeSpec project.
  3. Format, compile, and run repository-native tsv.
  4. Regenerate parent and candidate SDKs using the exact LocalSpecRepo.
  5. Require byte-identical generated source and public APIs.
  6. Restore any decorator that changes generated output.

Not included

These are not deterministic enough for automatic generator behavior:

  • Choosing boolean prefixes such as Is, Has, Can, or Should.
  • Blanket Response -> Result.
  • Choosing service/product prefixes such as Grafana, FrontDoor,
    NotificationHub, or CosmosDBBase.
  • Request-body names such as Content, Patch, or a resource/action-specific
    stem beyond the structural resource PUT/PATCH behavior already implemented.
  • Judgment-based Resource, Options, Collection, or Operation renames.

These belong in a separate non-deterministic naming issue for LLM/reviewer-
assisted API design.

Completion

  • Tasks 1-5 are implemented and released.
  • Matching TypeSpec linters are enabled.
  • Task 6 removes all proven-redundant decorators.
  • Paired generation confirms the cleanup does not change generated .NET APIs.

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.CodeGenIssues that relate to code generation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions