Skip to content

Add manually-projected ApiContractAttribute to WinRT.Runtime#2387

Open
Sergio0694 wants to merge 3 commits intostaging/3.0from
dev/add-apicontractattribute
Open

Add manually-projected ApiContractAttribute to WinRT.Runtime#2387
Sergio0694 wants to merge 3 commits intostaging/3.0from
dev/add-apicontractattribute

Conversation

@Sergio0694
Copy link
Copy Markdown
Member

Summary

Add ApiContractAttribute as a manually-projected type in WinRT.Runtime, and update the code generator to skip it.

Motivation

The [ApiContract] attribute (Windows.Foundation.Metadata.ApiContractAttribute) marks enum types that represent API contracts (e.g. FoundationContract, UniversalApiContract). Since these contract enums are already manually projected in WinRT.Runtime, the attribute that decorates them should also be manually projected for consistency and correctness. This also allows the existing contract enums to be properly annotated with [ApiContract].

Changes

  • src/WinRT.Runtime2/Windows.Foundation/Metadata/ApiContractAttribute.cs: new manually-projected ApiContractAttribute type, following the same pattern as ContractVersionAttribute
  • src/WinRT.Runtime2/Windows.Foundation/FoundationContract.cs: add [ApiContract] attribute
  • src/WinRT.Runtime2/Windows.Foundation/UniversalApiContract.cs: add [ApiContract] attribute
  • src/WinRT.Runtime2/Windows.Foundation/Metadata/ContractVersionAttribute.cs: remove unnecessary marshalling remark (consistent with new attribute style)
  • src/cswinrt/helpers.h: add ApiContractAttribute to the mapped types table so the code generator skips generating a duplicate projection

Sergio0694 and others added 3 commits April 10, 2026 11:01
Add the ApiContractAttribute type as a manually-projected attribute in
WinRT.Runtime, following the same pattern as ContractVersionAttribute.
Also add the [ApiContract] attribute to the existing FoundationContract
and UniversalApiContract enum declarations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add ApiContractAttribute to the mapped types table in helpers.h so
the code generator recognizes it as a manually-projected type and
skips generating a duplicate projection for it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Delete redundant <remarks> blocks that stated these attributes are required for ABI projection and that marshalling is not supported from ApiContractAttribute.cs and ContractVersionAttribute.cs. This is a comment-only cleanup and does not change code behavior.
@Sergio0694 Sergio0694 requested a review from manodasanW April 10, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant