diff --git a/TestComponent/ComposableClosable.cpp b/TestComponent/ComposableClosable.cpp new file mode 100644 index 0000000..f270692 --- /dev/null +++ b/TestComponent/ComposableClosable.cpp @@ -0,0 +1,16 @@ +#include "pch.h" +#include "ComposableClosable.h" +#include "ComposableClosable.g.cpp" + +namespace winrt::TestComponent::implementation +{ + void ComposableClosable::Close() + { + m_closed = true; + } + + bool ComposableClosable::IsClosed() + { + return m_closed; + } +} diff --git a/TestComponent/ComposableClosable.h b/TestComponent/ComposableClosable.h new file mode 100644 index 0000000..0b6b322 --- /dev/null +++ b/TestComponent/ComposableClosable.h @@ -0,0 +1,24 @@ +#pragma once +#include "ComposableClosable.g.h" + +namespace winrt::TestComponent::implementation +{ + struct ComposableClosable : ComposableClosableT + { + private: + bool m_closed{}; + + public: + ComposableClosable() = default; + + void Close(); + bool IsClosed(); + }; +} + +namespace winrt::TestComponent::factory_implementation +{ + struct ComposableClosable : ComposableClosableT + { + }; +} diff --git a/TestComponent/ComposableMap.cpp b/TestComponent/ComposableMap.cpp new file mode 100644 index 0000000..b89af4b --- /dev/null +++ b/TestComponent/ComposableMap.cpp @@ -0,0 +1,21 @@ +#include "pch.h" +#include "ComposableMap.h" +#include "ComposableMap.g.cpp" + +namespace winrt::TestComponent::implementation +{ + std::map& ComposableMap::get_container() noexcept + { + return m_values; + } + + std::map const& ComposableMap::get_container() const noexcept + { + return m_values; + } + + Windows::Foundation::Collections::IMapView ComposableMap::GetView() const + { + return single_threaded_map(std::map(m_values)).GetView(); + } +} diff --git a/TestComponent/ComposableMap.h b/TestComponent/ComposableMap.h new file mode 100644 index 0000000..972ca11 --- /dev/null +++ b/TestComponent/ComposableMap.h @@ -0,0 +1,28 @@ +#pragma once +#include "ComposableMap.g.h" + +namespace winrt::TestComponent::implementation +{ + struct ComposableMap : ComposableMapT, map_base + { + private: + std::map m_values; + + public: + ComposableMap() = default; + + std::map& get_container() noexcept; + std::map const& get_container() const noexcept; + + // map_base's own GetView() returns the class itself, as a class that + // also implements IMapView does, which this class does not. + Windows::Foundation::Collections::IMapView GetView() const; + }; +} + +namespace winrt::TestComponent::factory_implementation +{ + struct ComposableMap : ComposableMapT + { + }; +} diff --git a/TestComponent/ComposableVector.cpp b/TestComponent/ComposableVector.cpp new file mode 100644 index 0000000..5f89991 --- /dev/null +++ b/TestComponent/ComposableVector.cpp @@ -0,0 +1,21 @@ +#include "pch.h" +#include "ComposableVector.h" +#include "ComposableVector.g.cpp" + +namespace winrt::TestComponent::implementation +{ + std::vector& ComposableVector::get_container() noexcept + { + return m_values; + } + + std::vector const& ComposableVector::get_container() const noexcept + { + return m_values; + } + + Windows::Foundation::Collections::IVectorView ComposableVector::GetView() const + { + return single_threaded_vector(std::vector(m_values)).GetView(); + } +} diff --git a/TestComponent/ComposableVector.h b/TestComponent/ComposableVector.h new file mode 100644 index 0000000..221783a --- /dev/null +++ b/TestComponent/ComposableVector.h @@ -0,0 +1,28 @@ +#pragma once +#include "ComposableVector.g.h" + +namespace winrt::TestComponent::implementation +{ + struct ComposableVector : ComposableVectorT, vector_base + { + private: + std::vector m_values; + + public: + ComposableVector() = default; + + std::vector& get_container() noexcept; + std::vector const& get_container() const noexcept; + + // vector_base's own GetView() returns the class itself, as a class + // that also implements IVectorView does, which this class does not. + Windows::Foundation::Collections::IVectorView GetView() const; + }; +} + +namespace winrt::TestComponent::factory_implementation +{ + struct ComposableVector : ComposableVectorT + { + }; +} diff --git a/TestComponent/TestComponent.idl b/TestComponent/TestComponent.idl index 16232ec..34509db 100644 --- a/TestComponent/TestComponent.idl +++ b/TestComponent/TestComponent.idl @@ -393,6 +393,28 @@ namespace TestComponent Int32 ReadOverridableValue(); } + // Composable classes that implement a collection or IClosable, as XAML's + // ResourceDictionary, DependencyObjectCollection and + // DesktopWindowXamlSource do, for testing that a projection gives a + // derived class the protocols of the class it derives from. + unsealed runtimeclass ComposableVector : Windows.Foundation.Collections.IVector + { + ComposableVector(); + } + + unsealed runtimeclass ComposableMap : Windows.Foundation.Collections.IMap + { + ComposableMap(); + } + + unsealed runtimeclass ComposableClosable : Windows.Foundation.IClosable + { + ComposableClosable(); + + // Whether Close() has been called. + Boolean IsClosed{ get; }; + } + // An async action whose every step the caller drives, for testing how a // projection waits for an operation, cancels it and lets go of it. // diff --git a/TestComponent/TestComponent.nuspec b/TestComponent/TestComponent.nuspec index 128ce60..df410ed 100644 --- a/TestComponent/TestComponent.nuspec +++ b/TestComponent/TestComponent.nuspec @@ -2,7 +2,7 @@ PyWinRT.TestWinRT - 1.7.0 + 1.8.0 TestWinRT Microsoft MIT diff --git a/TestComponent/TestComponent.vcxproj b/TestComponent/TestComponent.vcxproj index 1df9352..593188a 100644 --- a/TestComponent/TestComponent.vcxproj +++ b/TestComponent/TestComponent.vcxproj @@ -152,6 +152,9 @@ + + + @@ -167,6 +170,9 @@ + + + diff --git a/TestComponent/TestComponent.vcxproj.filters b/TestComponent/TestComponent.vcxproj.filters index 10599f8..fb58f83 100644 --- a/TestComponent/TestComponent.vcxproj.filters +++ b/TestComponent/TestComponent.vcxproj.filters @@ -24,6 +24,9 @@ + + + @@ -40,6 +43,9 @@ + + +