Add exclusion list for types in 'cswinrtgen#2157
Merged
Sergio0694 merged 6 commits intostaging/3.0from Jan 15, 2026
Merged
Conversation
There was a problem hiding this comment.
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
TypeExclusionshelper class with extensible exclusion logic - Added
Task<T>reference toInteropReferencesfor 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.
kythant
approved these changes
Dec 16, 2025
ecc4d6d to
54cf730
Compare
manodasanW
reviewed
Dec 18, 2025
manodasanW
approved these changes
Dec 18, 2025
4147e26 to
10baca1
Compare
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.
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.
80784bf to
63ed713
Compare
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.
This PR adds an extensible way to special-case types to exclude in 'cswinrtgen', such as
Task<T>instantiations.