var typeDef = typeRef.Resolve();
if (TypeRefComparer.Default.Equals(typeDef, baseClass.Resolve()))
return true;
- if (typeDef.Interfaces.Any(ir => TypeRefComparer.Default.Equals(ir.InterfaceType, baseClass)))
+ if (typeDef.Interfaces.Any(ir => TypeRefComparer.Default.Equals(ir.InterfaceType.ResolveGenericParameters(typeRef), baseClass)))
return true;
if (typeDef.BaseType == null)
return false;
var returnType = castDef.ReturnType;
if (returnType.IsGenericParameter)
returnType = ((GenericInstanceType)opDeclTypeRef).GenericArguments [((GenericParameter)returnType).Position];
- if (returnType.FullName == toType.FullName &&
- cast.Parameters [0].ParameterType.Name == fromType.Name) {
+ if (returnType.InheritsFromOrImplements(toType))
return castDef;
- }
}
}
return null;
--- /dev/null
+<?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:sys="clr-namespace:System;assembly=mscorlib"
+ xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
+ xmlns:local="clr-namespace:Xamarin.Forms.Xaml.UnitTests"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Bz45891">
+ <local:Bz45891.List>
+ <OnPlatform x:TypeArguments="scg:List(sys:String)">
+ <OnPlatform.iOS>
+ <scg:List x:TypeArguments="sys:String">
+ <x:String>Foo</x:String>
+ </scg:List>
+ </OnPlatform.iOS>
+ </OnPlatform>
+ </local:Bz45891.List>
+</ContentPage>
\ No newline at end of file
--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using Xamarin.Forms;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class Bz45891 : ContentPage
+ {
+ public Bz45891()
+ {
+ InitializeComponent();
+ }
+
+ public Bz45891(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ public static readonly BindableProperty ListProperty =
+ BindableProperty.Create("List", typeof(IEnumerable<string>), typeof(Bz45891), default(IEnumerable<string>));
+
+ public IEnumerable<string> List {
+ get { return (IEnumerable<string>)GetValue(ListProperty); }
+ set { SetValue(ListProperty, value); }
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void LookForInheritanceOnOpImplicit(bool useCompiledXaml)
+ {
+ var p = new Bz45891(useCompiledXaml);
+ Assert.AreEqual("Foo", p.List.First());
+ }
+ }
+ }
+}
\ No newline at end of file
<Compile Include="Issues\Bz43694.xaml.cs">
<DependentUpon>Bz43694.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Bz45891.xaml.cs">
+ <DependentUpon>Bz45891.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
<EmbeddedResource Include="Issues\Bz43694.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz45891.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
[TestCase(typeof(bool), typeof(BindableObject), ExpectedResult = false)]
[TestCase(typeof(Dictionary<string, string>), typeof(BindableObject), ExpectedResult = false)]
[TestCase(typeof(List<string>), typeof(BindableObject), ExpectedResult = false)]
+ [TestCase(typeof(List<string>), typeof(IEnumerable<string>), ExpectedResult = true)]
[TestCase(typeof(List<Button>), typeof(BindableObject), ExpectedResult = false)]
[TestCase(typeof(Queue<KeyValuePair<string, string>>), typeof(BindableObject), ExpectedResult = false)]
[TestCase(typeof(double), typeof(double), ExpectedResult = true)]
if (!mi.IsSpecialName) continue;
if (mi.Name != "op_Implicit") continue;
if (!mi.IsPublic) continue;
- if (mi.ReturnType != toType) continue;
+ if (!toType.IsAssignableFrom(mi.ReturnType)) continue;
var parameters = mi.GetParameters();
if (parameters.Length != 1) continue;
if (parameters[0].ParameterType != value.GetType()) continue;
if (!mi.IsSpecialName) continue;
if (mi.Name != "op_Implicit") continue;
if (!mi.IsPublic) continue;
- if (mi.ReturnType != toType) continue;
+ if (!toType.IsAssignableFrom(mi.ReturnType)) continue;
var parameters = mi.GetParameters();
if (parameters.Length != 1) continue;
if (parameters[0].ParameterType != value.GetType()) continue;