Add manually-projected ApiContractAttribute to WinRT.Runtime#2387
Open
Sergio0694 wants to merge 3 commits intostaging/3.0from
Open
Add manually-projected ApiContractAttribute to WinRT.Runtime#2387Sergio0694 wants to merge 3 commits intostaging/3.0from
Sergio0694 wants to merge 3 commits intostaging/3.0from
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add
ApiContractAttributeas a manually-projected type inWinRT.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 inWinRT.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-projectedApiContractAttributetype, following the same pattern asContractVersionAttributesrc/WinRT.Runtime2/Windows.Foundation/FoundationContract.cs: add[ApiContract]attributesrc/WinRT.Runtime2/Windows.Foundation/UniversalApiContract.cs: add[ApiContract]attributesrc/WinRT.Runtime2/Windows.Foundation/Metadata/ContractVersionAttribute.cs: remove unnecessary marshalling remark (consistent with new attribute style)src/cswinrt/helpers.h: addApiContractAttributeto the mapped types table so the code generator skips generating a duplicate projection