diff options
4 files changed, 74 insertions, 2 deletions
diff --git a/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs b/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs index 97b48a40..35016694 100644 --- a/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs +++ b/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs @@ -220,7 +220,10 @@ namespace Xamarin.Forms.Build.Tasks return true; } - var getters = bpRef.DeclaringType.GetMethods(md => md.Name == "Get" + pName && md.IsStatic, module).SingleOrDefault(); + var getters = bpRef.DeclaringType.GetMethods(md => md.Name == "Get" + pName && + md.IsStatic && + md.Parameters.Count() == 1 && + md.Parameters[0].ParameterType.FullName == "Xamarin.Forms.BindableObject", module).SingleOrDefault(); if (getters != null) { if (getters.Item1.HasCustomAttributes) @@ -263,7 +266,10 @@ namespace Xamarin.Forms.Build.Tasks //Then check for getter or setter (attached BPs) var getters = - bpRef.DeclaringType.GetMethods(md => md.Name == "Get" + name && md.IsStatic, context.Body.Method.Module) + bpRef.DeclaringType.GetMethods(md => md.Name == "Get" + name && + md.IsStatic && + md.Parameters.Count() == 1 && + md.Parameters [0].ParameterType.FullName == "Xamarin.Forms.BindableObject", context.Body.Method.Module) .SingleOrDefault(); if (getters != null) return getters.Item1.ReturnType; diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml new file mode 100644 index 00000000..7ed94589 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" + xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" + xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests" + x:Class="Xamarin.Forms.Xaml.UnitTests.Unreported004"> + <Label x:Name="label" local:Unreported004.SomeProperty="foo" /> +</ContentPage> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml.cs new file mode 100644 index 00000000..ff2dac08 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported004.xaml.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using NUnit.Framework; +using Xamarin.Forms; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + public partial class Unreported004 : ContentPage + { + public Unreported004() + { + InitializeComponent(); + } + + public Unreported004(bool useCompiledXaml) + { + //this stub will be replaced at compile time + } + + public static readonly BindableProperty SomePropertyProperty = + BindableProperty.Create("SomeProperty", typeof(string), + typeof(Unreported004), null); + + public static string GetSomeProperty(BindableObject bindable) + { + return bindable.GetValue(SomePropertyProperty) as string; + } + + public static string GetSomeProperty(BindableObject bindable, object foo) + { + return null; + } + + public static void SetSomeProperty(BindableObject bindable, string value) + { + bindable.SetValue(SomePropertyProperty, value); + } + + + [TestFixture] + class Tests + { + [TestCase(true), TestCase(false)] + public void MultipleGetMethodsAllowed(bool useCompiledXaml) + { + var page = new Unreported004(); + Assert.NotNull(page.label); + Assert.AreEqual("foo", GetSomeProperty(page.label)); + } + } + } +} + diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index cd22258c..cf473ff8 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -350,6 +350,9 @@ <Compile Include="XamlLoaderGetXamlForTypeTests.xaml.cs"> <DependentUpon>XamlLoaderGetXamlForTypeTests.xaml</DependentUpon> </Compile> + <Compile Include="Issues\Unreported004.xaml.cs"> + <DependentUpon>Unreported004.xaml</DependentUpon> + </Compile> </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" /> @@ -623,6 +626,9 @@ <EmbeddedResource Include="XamlLoaderGetXamlForTypeTests.xaml"> <Generator>MSBuild:UpdateDesignTimeXaml</Generator> </EmbeddedResource> + <EmbeddedResource Include="Issues\Unreported004.xaml"> + <Generator>MSBuild:UpdateDesignTimeXaml</Generator> + </EmbeddedResource> </ItemGroup> <ItemGroup> <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" /> |