Skip to content

Skip emitting [ContractVersion] and [GCPressure] attributes for implementation assemblies#2351

Open
Sergio0694 wants to merge 1 commit intostaging/3.0from
dev/skip-impl-attributes
Open

Skip emitting [ContractVersion] and [GCPressure] attributes for implementation assemblies#2351
Sergio0694 wants to merge 1 commit intostaging/3.0from
dev/skip-impl-attributes

Conversation

@Sergio0694
Copy link
Member

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):

  • Removed GCPressure from the unconditional early-skip list (which also covers Guid, Flags, ProjectionInternal), so it now flows into the metadata attribute filter instead of being silently dropped for all builds.
  • Added a dedicated branch for ContractVersion and GCPressure in the metadata attribute filter: both are now only emitted when settings.reference_projection is true. For implementation assemblies, they are skipped.

The logic is split into two clear, readable branches:

  1. If the attribute is ContractVersion or GCPressure → skip for implementation assemblies, emit for reference assemblies.
  2. For all other Windows.Foundation.Metadata attributes → only emit if they are one of the always-projected attributes (DefaultOverload, Overload, AttributeUsage, Experimental).

… 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>
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GCPressure so it can be handled by the metadata attribute filter logic.
  • Adds explicit filtering so ContractVersion and GCPressure are emitted only when settings.reference_projection is true.
  • Keeps the existing allowlist behavior for other Windows.Foundation.Metadata attributes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants