From 5018bc7774a69c94a044c9528525bf3e792cbaf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Laban?= Date: Thu, 17 Jan 2019 15:26:04 -0500 Subject: [PATCH] Fix invalid code generation for multiple event handlers --- .../XamlGenerator/XamlFileGenerator.cs | 4 ++-- src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml | 2 +- src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml.cs | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs index c4ed67d5ddff..8f2f95603b4c 100644 --- a/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs +++ b/src/SourceGenerators/Uno.UI.SourceGenerators/XamlGenerator/XamlFileGenerator.cs @@ -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 { diff --git a/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml b/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml index baf7969caff9..525587a42ee0 100644 --- a/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml +++ b/src/SourceGenerators/XamlGenerationTests/XamlEvents.xaml @@ -8,6 +8,6 @@ d:DesignHeight="300" d:DesignWidth="400"> -