Track CCW info for '[ReadOnly]Dictionary[Key|Value]Collection<TKey, TValue>' typs in 'cswinrtgen'#2159
Merged
Sergio0694 merged 5 commits intostaging/3.0from Jan 15, 2026
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the WinRT interop generator to track CCW (COM Callable Wrapper) information for dictionary collection types (DictionaryKeyCollection, DictionaryValueCollection, ReadOnlyDictionaryKeyCollection, and ReadOnlyDictionaryValueCollection). The changes ensure these collection types are properly instantiated in WinRT.Interop.dll when their parent dictionary types are discovered, enabling correct marshalling to native code.
Key changes:
- Refactored generic interface type tracking from extension methods to a dedicated method in
InteropTypeDiscovery.Generics.cs - Added automatic tracking of dictionary key/value collection types when discovering
IDictionary<TKey, TValue>andIReadOnlyDictionary<TKey, TValue>instantiations - Enhanced documentation in dictionary collection classes to clarify the concrete types returned by
KeysandValuesproperties
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
WindowsRuntimeReadOnlyDictionary{TKey, TValue}.cs |
Added XML documentation remarks clarifying the concrete types returned by Keys and Values properties |
WindowsRuntimeObservableMap{TKey, TValue}.cs |
Added XML documentation remarks for dictionary collection properties with inherited documentation for interface implementations |
WindowsRuntimeDictionary{TKey, TValue}.cs |
Added XML documentation remarks for dictionary collection properties with inherited documentation for interface implementations |
InteropGenerator.Discover.cs |
Added module parameter to TryTrackExposedUserDefinedType call to support enhanced type discovery |
InteropGeneratorDiscoveryStateExtensions.cs |
Deleted file - functionality moved to InteropTypeDiscovery.Generics.cs |
InteropTypeDiscovery.cs |
Added module parameter to TryTrackExposedUserDefinedType method signature |
InteropTypeDiscovery.Generics.cs |
Refactored generic interface tracking into dedicated method with automatic tracking of dictionary collection types when parent dictionary types are discovered |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/WinRT.Runtime2/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs
Show resolved
Hide resolved
src/WinRT.Runtime2/Collections/WindowsRuntimeObservableMap{TKey, TValue}.cs
Show resolved
Hide resolved
src/WinRT.Runtime2/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs
Show resolved
Hide resolved
src/WinRT.Runtime2/Collections/WindowsRuntimeDictionary{TKey, TValue}.cs
Show resolved
Hide resolved
manodasanW
approved these changes
Dec 18, 2025
4147e26 to
10baca1
Compare
Added XML documentation remarks to the Keys and Values properties in WindowsRuntimeDictionary, WindowsRuntimeObservableMap, and WindowsRuntimeReadOnlyDictionary classes to clarify the concrete collection types returned. This improves API documentation and developer understanding of the property return types.
Replaces direct calls to TrackGenericInterfaceType with a new TryTrackWindowsRuntimeGenericInterfaceTypeInstance method. This centralizes and extends the logic for tracking constructed generic Windows Runtime interface types, ensuring all necessary related types and delegates are also tracked for code generation.
Deleted the InteropGeneratorDiscoveryStateExtensions.cs file, which contained extension methods for tracking generic interface and delegate types in the interop generator discovery process. This may be part of a refactor or cleanup to simplify or relocate this logic.
Updated generic type discovery logic to explicitly track constructed DictionaryKeyCollection, DictionaryValueCollection, ReadOnlyDictionaryKeyCollection, and ReadOnlyDictionaryValueCollection types when discovering IDictionary<TKey, TValue> and IReadOnlyDictionary<TKey, TValue> instantiations. This ensures correct marshaling of these types, which may not be present in input assemblies but are generated during emit. Also refactored method signatures to consistently pass the current module and args where needed.
ff013e4 to
c083109
Compare
Switched from a thread-static TypeSignatureEquatableSet.Builder to a ConcurrentBag-based pool to handle recursive calls during interface discovery. This avoids conflicts and improves resource reuse when analyzing types that may trigger nested discovery logic.
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.
Title. This results in the following additional instantiations in
WinRT.Interop.dll(there's more):