Skip to content

Consider adding attributes to the list of supported backcompat scenarios #11232

Closed

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)

Activity

  1. github-actions commented on Jul 13, 2026

    @github-actions
    Contributor

    🎯 Issue Triage

    This is a refactoring/cleanup request to centralize type attribute back-compat merging logic into a shared TypeProvider-level API, rather than keeping it local to CanonicalTypeProvider.BuildAttributes().

    Category: Feature Request
    Area: emitter:client:csharp

    🔍 Analysis
    • Origin: Raised as a non-blocking follow-up from PR Use provider C# reference map with pre-write internalization #10976 review discussion.
    • Current behavior: CanonicalTypeProvider.BuildAttributes() locally handles merging of generated, last-contract, and custom-code type attributes.
    • Proposed improvement: Extract this logic into a TypeProvider.BuildAttributesForBackCompatibility() API to centralize responsibility and follow existing back-compat patterns.
    • Scope: Internal refactor — no user-facing behavior change expected. Improves code consistency and maintainability in the C# emitter.
    • Affected components: CanonicalTypeProvider, TypeProvider in http-client-csharp.
    📝 Suggested next steps
    • Implement BuildAttributesForBackCompatibility on TypeProvider handling restore, merge, filter, and deduplication
    • Update CanonicalTypeProvider.BuildAttributes() to delegate to the new shared API
    • Verify existing tests pass; add tests for the new API if needed

    Generated by Agentic Triage

  2. jorgerangel-msft commented on Jul 14, 2026

    @jorgerangel-msft
    Contributor

    Attributes can be part of the public surface, but we should consider if the generator should actually make the decision of re-adding them back if they are missing from the current version. Maybe we start with an allow list of known attributes that can be added back, and eventually let that be extensible for downstream plugins ?

  3. changed the title [-]Centralize type attribute back-compat merging in C# generator[/-] [+]Consider adding attributes to the list of supported backcompat scenarios[/+] on Jul 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions