Skip to content

Skip emitting [ApiContract] attribute for implementation assemblies#2436

Open
Sergio0694 wants to merge 1 commit into
staging/3.0from
user/sergiopedri/skip-apicontract-impl-assemblies
Open

Skip emitting [ApiContract] attribute for implementation assemblies#2436
Sergio0694 wants to merge 1 commit into
staging/3.0from
user/sergiopedri/skip-apicontract-impl-assemblies

Conversation

@Sergio0694

Copy link
Copy Markdown
Member

Summary

Skip emitting the [ApiContract] attribute when generating implementation (projection) assemblies, emitting it only for reference projections. This mirrors the existing behavior for the [ContractVersion] attribute.

Motivation

In the CsWinRT 3.0 reference/implementation assembly split, metadata-only attributes from the Windows.Foundation.Metadata namespace should only appear in reference projections, not in the implementation assemblies that contain the actual projection code. [ContractVersion] was already filtered out for implementation assemblies, but [ApiContract] was still being emitted, leaking metadata-only information into the implementation assembly. This change makes [ApiContract] consistent with [ContractVersion].

Changes

  • src/cswinrt/code_writers.h: in write_custom_attributes, extend the metadata attribute filter so that [ApiContract] is treated like [ContractVersion] — emitted only when settings.reference_projection is set, and skipped otherwise.

Treat [ApiContract] like [ContractVersion] in the metadata attribute filter: only emit it for reference projections and skip it when generating implementation assemblies.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Sergio0694 Sergio0694 requested a review from manodasanW June 12, 2026 19:56
@Sergio0694 Sergio0694 enabled auto-merge (squash) June 12, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants