Skip to content

Comments

Add exclusion list for types in 'cswinrtgen#2157

Merged
Sergio0694 merged 6 commits intostaging/3.0from
user/sergiopedri/hide-special-types
Jan 15, 2026
Merged

Add exclusion list for types in 'cswinrtgen#2157
Sergio0694 merged 6 commits intostaging/3.0from
user/sergiopedri/hide-special-types

Conversation

@Sergio0694
Copy link
Member

This PR adds an extensible way to special-case types to exclude in 'cswinrtgen', such as Task<T> instantiations.

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

This PR introduces an exclusion list mechanism for the 'cswinrtgen' tool to filter out specific types from the interop API surface, with the initial exclusion being Task<T> instantiations.

Key Changes:

  • Created a new TypeExclusions helper class with extensible exclusion logic
  • Added Task<T> reference to InteropReferences for use in exclusion checks
  • Integrated exclusion checks into three type discovery methods to prevent tracking of excluded types

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/WinRT.Runtime2/InteropServices/ObjectReference/WindowsRuntimeObjectReference.cs Added [WindowsRuntimeManagedOnlyType] attribute to mark the class as managed-only
src/WinRT.Interop.Generator/References/InteropReferences.cs Added Task1 property to provide reference to Task<TResult> generic type definition
src/WinRT.Interop.Generator/Helpers/TypeExclusions.cs Created new helper class containing exclusion logic for types that should be filtered from interop API surface
src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.cs Added exclusion check in TryTrackExposedUserDefinedType to filter excluded types
src/WinRT.Interop.Generator/Discovery/InteropTypeDiscovery.Generics.cs Added exclusion checks in TryTrackGenericTypeInstance and TryTrackSzArrayType to filter excluded types

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

@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/generic-ccw2 branch from ecc4d6d to 54cf730 Compare December 16, 2025 17:34
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/generic-ccw2 branch from 4147e26 to 10baca1 Compare January 14, 2026 05:07
Sergio0694 and others added 6 commits January 15, 2026 09:43
Applied the [WindowsRuntimeManagedOnlyType] attribute to the WindowsRuntimeObjectReference class to indicate it is intended for managed use only.
Introduces a TypeExclusions helper class to centralize logic for excluding specific types, such as Task<T>, from the interop API surface. Also adds a Task1 reference to InteropReferences to support this exclusion logic.
Introduced checks in InteropTypeDiscovery to skip types explicitly excluded via TypeExclusions, including support for SZ arrays. This prevents processing of types that should not be considered for interop marshalling, improving filtering and correctness.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Applied the [WindowsRuntimeManagedOnlyType] attribute to various Windows Runtime collection and async types in the WinRT.Runtime2 project. This change clarifies that these types are managed-only implementations, improving code clarity and maintainability.
Replaces manual iteration over excluded types with a stack-allocated ReadOnlySpan and uses Contains for cleaner and more efficient exclusion checks. This improves readability and performance by leveraging modern C# features.
@Sergio0694 Sergio0694 force-pushed the user/sergiopedri/hide-special-types branch from 80784bf to 63ed713 Compare January 15, 2026 17:44
@Sergio0694 Sergio0694 changed the base branch from user/sergiopedri/generic-ccw2 to staging/3.0 January 15, 2026 17:44
@Sergio0694 Sergio0694 merged commit c215473 into staging/3.0 Jan 15, 2026
10 checks passed
@Sergio0694 Sergio0694 deleted the user/sergiopedri/hide-special-types branch January 15, 2026 18:32
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.

3 participants