Skip to content

Centralize type attribute back-compat merging in C# generator #11232

Description

@live1206

Background

PR #10976 currently merges generated, last-contract, and custom-code type attributes locally in CanonicalTypeProvider.BuildAttributes(). This keeps the provider reference-map/pre-write internalization work scoped, but the back-compat behavior would be clearer and more consistent if it followed the existing centralized TypeProvider back-compat pattern.

Proposed cleanup

Add a TypeProvider-level API, such as BuildAttributesForBackCompatibility, that handles:

  • restoring compatible attributes from the last contract,
  • merging generated and custom-code attributes,
  • filtering CodeGen-specific attributes that should not be preserved,
  • deduplicating attributes consistently.

Then update CanonicalTypeProvider to use that shared API instead of owning this local merge/deduplication logic.

Notes

This was raised as a non-blocking review follow-up in PR #10976: #10976 (comment)

Metadata

Metadata

Labels

emitter:client:csharpIssue for the C# client emitter: @typespec/http-client-csharpfeatureNew feature or request

Type

No type

Fields

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