Skip emitting [ApiContract] attribute for implementation assemblies#2436
Open
Sergio0694 wants to merge 1 commit into
Open
Skip emitting [ApiContract] attribute for implementation assemblies#2436Sergio0694 wants to merge 1 commit into
Sergio0694 wants to merge 1 commit into
Conversation
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>
manodasanW
approved these changes
Jun 12, 2026
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
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.Metadatanamespace 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: inwrite_custom_attributes, extend the metadata attribute filter so that[ApiContract]is treated like[ContractVersion]— emitted only whensettings.reference_projectionis set, and skipped otherwise.