Skip emitting [ContractVersion] and [GCPressure] attributes for implementation assemblies#2351
Open
Sergio0694 wants to merge 1 commit intostaging/3.0from
Open
Skip emitting [ContractVersion] and [GCPressure] attributes for implementation assemblies#2351Sergio0694 wants to merge 1 commit intostaging/3.0from
Sergio0694 wants to merge 1 commit intostaging/3.0from
Conversation
… assemblies When generating an implementation assembly (not a reference one), the projection generator now skips emitting [ContractVersion] and [GCPressure] attributes on types. These metadata-only attributes are only relevant for reference assemblies and are unnecessary in the implementation output. - Remove GCPressure from the unconditional early-skip list so it flows through the metadata attribute filter like ContractVersion - Make both ContractVersion and GCPressure conditional on settings.reference_projection in the metadata attribute filter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Updates the C#/WinRT projection generator to avoid emitting metadata-only [ContractVersion] and [GCPressure] attributes in implementation assemblies, while preserving them for reference projections.
Changes:
- Stops unconditionally skipping
GCPressureso it can be handled by the metadata attribute filter logic. - Adds explicit filtering so
ContractVersionandGCPressureare emitted only whensettings.reference_projectionis true. - Keeps the existing allowlist behavior for other
Windows.Foundation.Metadataattributes.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
When generating an implementation assembly (i.e. not a reference one), the projection generator now skips emitting
[ContractVersion]and[GCPressure]attributes on types. These metadata-only attributes are only relevant for reference assemblies and are unnecessary in the implementation output.Changes
In
write_custom_attributes(src/cswinrt/code_writers.h):GCPressurefrom the unconditional early-skip list (which also coversGuid,Flags,ProjectionInternal), so it now flows into the metadata attribute filter instead of being silently dropped for all builds.ContractVersionandGCPressurein the metadata attribute filter: both are now only emitted whensettings.reference_projectionis true. For implementation assemblies, they are skipped.The logic is split into two clear, readable branches:
ContractVersionorGCPressure→ skip for implementation assemblies, emit for reference assemblies.Windows.Foundation.Metadataattributes → only emit if they are one of the always-projected attributes (DefaultOverload,Overload,AttributeUsage,Experimental).