Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add using for system namespace to event helpers file #1288

Merged
merged 2 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Tests/TestComponentCSharp/Class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,18 @@ namespace winrt::TestComponentCSharp::implementation
{
_collectionEvent(sender, arg0, arg1);
}
winrt::event_token Class::GuidEvent(TestComponentCSharp::EventWithGuid const& handler)
{
return _guidEvent.add(handler);
}
void Class::GuidEvent(winrt::event_token const& token) noexcept
{
_guidEvent.remove(token);
}
void Class::InvokeGuidEvent(winrt::guid const& correlationGuid)
{
_guidEvent(correlationGuid);
}
winrt::event_token Class::NestedEvent(EventHandler<IVector<int32_t>> const& handler)
{
return _nestedEvent.add(handler);
Expand Down Expand Up @@ -335,6 +347,10 @@ namespace winrt::TestComponentCSharp::implementation
_returnEvent(arg0);
return arg0;
}
winrt::guid Class::TestReturnGuid(winrt::guid const& arg)
{
return arg;
}
int32_t Class::IntProperty()
{
return _int;
Expand Down
5 changes: 5 additions & 0 deletions src/Tests/TestComponentCSharp/Class.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace winrt::TestComponentCSharp::implementation
winrt::event<EventHandler2> _event2;
winrt::event<EventHandler3> _event3;
winrt::event<EventHandlerCollection> _collectionEvent;
winrt::event<EventWithGuid> _guidEvent;
winrt::event<Windows::Foundation::EventHandler<Windows::Foundation::Collections::IVector<int32_t>>> _nestedEvent;
winrt::event<Windows::Foundation::TypedEventHandler<TestComponentCSharp::Class, Windows::Foundation::Collections::IVector<hstring>>> _nestedTypedEvent;
winrt::event<TestComponentCSharp::EventWithReturn> _returnEvent;
Expand Down Expand Up @@ -124,6 +125,9 @@ namespace winrt::TestComponentCSharp::implementation
winrt::event_token CollectionEvent(TestComponentCSharp::EventHandlerCollection const& handler);
void CollectionEvent(winrt::event_token const& token) noexcept;
void InvokeCollectionEvent(TestComponentCSharp::Class const& sender, Windows::Foundation::Collections::IVector<int32_t> const& arg0, Windows::Foundation::Collections::IMap<int32_t, hstring> const& arg1);
winrt::event_token GuidEvent(TestComponentCSharp::EventWithGuid const& handler);
void GuidEvent(winrt::event_token const& token) noexcept;
void InvokeGuidEvent(winrt::guid const& correlationGuid);
winrt::event_token NestedEvent(Windows::Foundation::EventHandler<Windows::Foundation::Collections::IVector<int32_t>> const& handler);
void NestedEvent(winrt::event_token const& token) noexcept;
void InvokeNestedEvent(TestComponentCSharp::Class const& sender, Windows::Foundation::Collections::IVector<int32_t> const& arg0);
Expand All @@ -133,6 +137,7 @@ namespace winrt::TestComponentCSharp::implementation
winrt::event_token ReturnEvent(TestComponentCSharp::EventWithReturn const& handler);
void ReturnEvent(winrt::event_token const& token) noexcept;
int32_t InvokeReturnEvent(int32_t const& arg0);
winrt::guid TestReturnGuid(winrt::guid const& arg);

int32_t IntProperty();
void IntProperty(int32_t value);
Expand Down
4 changes: 4 additions & 0 deletions src/Tests/TestComponentCSharp/TestComponentCSharp.idl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace TestComponentCSharp
delegate void EventHandler3(Class sender, Int32 arg0, String arg1);
delegate void EventHandlerCollection(Class sender, Windows.Foundation.Collections.IVector<Int32> arg0, Windows.Foundation.Collections.IMap<Int32, String> arg1);
delegate Int32 EventWithReturn(Int32 arg);
delegate void EventWithGuid(Guid correlationGuid);

[flags]
enum FlagValue
Expand Down Expand Up @@ -184,13 +185,16 @@ namespace TestComponentCSharp
event EventHandler3 Event3;
void InvokeEvent3(Class sender, Int32 arg0, String arg1);
event EventHandlerCollection CollectionEvent;
event EventWithGuid GuidEvent;
void InvokeCollectionEvent(Class sender, Windows.Foundation.Collections.IVector<Int32> arg0, Windows.Foundation.Collections.IMap<Int32, String> arg1);
void InvokeGuidEvent(Guid correlationGuid);
event Windows.Foundation.EventHandler<Windows.Foundation.Collections.IVector<Int32> > NestedEvent;
void InvokeNestedEvent(Class sender, Windows.Foundation.Collections.IVector<Int32> arg0);
event Windows.Foundation.TypedEventHandler<Class, Windows.Foundation.Collections.IVector<String> > NestedTypedEvent;
void InvokeNestedTypedEvent(Class sender, Windows.Foundation.Collections.IVector<String> arg0);
event EventWithReturn ReturnEvent;
Int32 InvokeReturnEvent(Int32 arg0);
Guid TestReturnGuid(Guid arg);

Int32 IntProperty;
event Windows.Foundation.EventHandler<Int32> IntPropertyChanged;
Expand Down
2 changes: 1 addition & 1 deletion src/cswinrt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ Where <spec> is one or more of:

writer eventHelperWriter("WinRT");
write_file_header(eventHelperWriter);
eventHelperWriter.write("namespace WinRT\n{\n%\n}", bind([&](writer& w) {
eventHelperWriter.write("using System;\nnamespace WinRT\n{\n%\n}", bind([&](writer& w) {
for (auto&& [key, value] : typeNameToEventDefinitionMap)
{
w.write("%", value);
Expand Down