Skip to content

Commit

Permalink
Merge pull request #502 from nventive/devjela/duplicate-xaml-events
Browse files Browse the repository at this point in the history
Fix invalid code generation for multiple event handlers
  • Loading branch information
jeromelaban authored Jan 17, 2019
2 parents 73a025d + 5018bc7 commit 11fa58e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1964,8 +1964,8 @@ void writeEvent(string ownerPrefix)
// use the WeakReferenceProvider to get a self reference to avoid adding the cost of the
// creation of a WeakReference.
//
writer.AppendLineInvariant($"var {member.Value}_That = ({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;");
writer.AppendLineInvariant($"{closureName}.{member.Member.Name} += ({parms}) => ({member.Value}_That.Target as {_className.className}).{member.Value}({parms});");
writer.AppendLineInvariant($"var {member.Member.Name}_{member.Value}_That = ({eventSource} as global::Uno.UI.DataBinding.IWeakReferenceProvider).WeakReference;");
writer.AppendLineInvariant($"{closureName}.{member.Member.Name} += ({parms}) => ({member.Member.Name}_{member.Value}_That.Target as {_className.className}).{member.Value}({parms});");
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
d:DesignHeight="300"
d:DesignWidth="400">
<Grid>
<Button Click="Button_Click" />
<Button Click="Button_Click" Loaded="OnLoadUnload" Unloaded="OnLoadUnload" />
</Grid>
</UserControl>
5 changes: 5 additions & 0 deletions src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ private void Button_Click(object sender, RoutedEventArgs e)
{

}

private void OnLoadUnload(object sender, object e)
{

}
}
}

0 comments on commit 11fa58e

Please sign in to comment.