Skip to content

Commit

Permalink
Change return type only for MUX.Input.ICommand (#1092)
Browse files Browse the repository at this point in the history
Co-authored-by: Alexander Sklar <asklar@microsoft.com>
  • Loading branch information
mcooley and asklar authored Mar 8, 2022
1 parent 89ec0bd commit 1f274aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cswinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1319,11 +1319,15 @@ private % Make_%()
{
auto event_type = w.write_temp("%", bind<write_type_name>(get_type_semantics(event.EventType()), typedef_name_type::Projected, false));

// ICommand has a lower-fidelity type mapping where the type of the event handler doesn't project one-to-one
// Microsoft.UI.Xaml.Input.ICommand has a lower-fidelity type mapping where the type of the event handler doesn't project one-to-one
// so we need to hard-code mapping the event handler from the mapped WinRT type to the correct .NET type.
if (event.Name() == "CanExecuteChanged" && event_type == "global::System.EventHandler<object>")
{
event_type = "global::System.EventHandler";
auto parent_type = w.write_temp("%", bind<write_type_name>(event.Parent(), typedef_name_type::NonProjected, true));
if (parent_type == "Microsoft.UI.Xaml.Input.ICommand")
{
event_type = "global::System.EventHandler";
}
}
w.write(R"(
%%%event % %
Expand Down

0 comments on commit 1f274aa

Please sign in to comment.