Skip to content

TestComponent: add composable classes with collection and IClosable - #6

Merged
dlech merged 2 commits into
masterfrom
composable-protocols
Nov 29, 2026
Merged

dlech merged 2 commits into
masterfrom
composable-protocols

Conversation

@dlech

@dlech dlech commented Nov 29, 2026

Copy link
Copy Markdown
Member

Adds three unsealed classes with default constructors to TestComponent:

  • ComposableVector implements IVector<Int32> (and so IIterable<Int32>), backed by a std::vector<int32_t>.
  • ComposableMap implements IMap<String, Int32>, backed by a std::map<hstring, int32_t>.
  • ComposableClosable implements IClosable and has a read-only IsClosed property that tells whether Close() was called.

These are the shapes of XAML's ResourceDictionary, DependencyObjectCollection and DesktopWindowXamlSource, which a projection can't test without XAML. pywinrt needs them to test that a Python subclass of a composable class gets the collection and IClosable protocols of the class it derives from.

Nothing that already exists changes.

GetView() returns a snapshot, since C++/WinRT's vector_base and map_base return the class itself as the view, which works only for a class that also implements IVectorView/IMapView.

Checked by building Release x64, x86 and ARM64 and nuget pack, and with a throwaway C++/WinRT console test that used each class directly and composed a C++ subclass over ComposableVector and ComposableClosable.

ComposableVector, ComposableMap and ComposableClosable are unsealed
classes that implement IVector<Int32>, IMap<String, Int32> and
IClosable, as XAML's ResourceDictionary, DependencyObjectCollection and
DesktopWindowXamlSource do. ComposableClosable records whether Close()
was called.

This allows testing that a projection gives a class derived from a
composable class the collection and IClosable protocols of the class it
derives from, without XAML.
@dlech
dlech force-pushed the composable-protocols branch from a1da931 to c4e7910 Compare November 29, 2026 03:45
@dlech
dlech merged commit c4e7910 into master Nov 29, 2026
1 check passed
@dlech
dlech deleted the composable-protocols branch November 29, 2026 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant