diff --git a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
index 2317a8e12..94b722590 100644
--- a/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
+++ b/Xamarin.Forms.Build.Tasks/SetPropertiesVisitor.cs
@@ -879,8 +879,9 @@ namespace Xamarin.Forms.Build.Tasks
throw new XamlParseException($"Signature (number of arguments) of EventHandler \"{context.Body.Method.DeclaringType.FullName}.{value}\" doesn't match the event type", iXmlLineInfo);
if (!invoke.ContainsGenericParameter)
for (var i = 0; i < invoke.Parameters.Count;i++)
- if (!handler.Parameters[i].ParameterType.InheritsFromOrImplements(invoke.Parameters[i].ParameterType))
+ if (!invoke.Parameters[i].ParameterType.InheritsFromOrImplements(handler.Parameters[i].ParameterType))
throw new XamlParseException($"Signature (parameter {i}) of EventHandler \"{context.Body.Method.DeclaringType.FullName}.{value}\" doesn't match the event type", iXmlLineInfo);
+ //TODO check generic parameters if any
if (handler.IsVirtual) {
yield return Create(Ldarg_0);
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml
new file mode 100644
index 000000000..fb88133c5
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml.cs
new file mode 100644
index 000000000..7c6958bec
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4130.xaml.cs
@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Xamarin.Forms;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class Gh4130Control:ContentView
+ {
+ public delegate void TextChangedEventHandler(object sender, TextChangedEventArgs args);
+#pragma warning disable 067
+ public event TextChangedEventHandler TextChanged;
+#pragma warning restore 067
+ public void FireEvent()
+ {
+ TextChanged?.Invoke(this, new TextChangedEventArgs(null, null));
+ }
+ }
+
+ public partial class Gh4130 : ContentPage
+ {
+ public Gh4130()
+ {
+ InitializeComponent();
+ var c = new Gh4130Control();
+ }
+
+ public Gh4130(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ void OnTextChanged(object sender, EventArgs e)
+ {
+ Assert.Pass();
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
+ [TestCase(false),TestCase(true)]
+ public void NonGenericEventHanlders(bool useCompiledXaml)
+ {
+ var layout = new Gh4130(useCompiledXaml);
+ var control = layout.Content as Gh4130Control;
+ control.FireEvent();
+ Assert.Fail();
+ }
+ }
+ }
+}
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 406404e0c..bac02bef6 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -655,6 +655,9 @@
Gh4099.xaml
+
+ Gh4130.xaml
+
@@ -1207,6 +1210,10 @@
MSBuild:UpdateDesignTimeXaml
Designer
+
+ Designer
+ MSBuild:UpdateDesignTimeXaml
+