summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-02-02 15:19:03 +0100
committerKangho Hur <kangho.hur@samsung.com>2017-03-24 13:18:41 +0900
commitf001684556f104a7d847d7b276164e5f0246f06f (patch)
tree517119bf5a706214a057ba511b1c45becb4c93b4 /Xamarin.Forms.Xaml.UnitTests
parentfc482ef2eb128dae25342613a3e6d6d0f676419a (diff)
downloadxamarin-forms-f001684556f104a7d847d7b276164e5f0246f06f.tar.gz
xamarin-forms-f001684556f104a7d847d7b276164e5f0246f06f.tar.bz2
xamarin-forms-f001684556f104a7d847d7b276164e5f0246f06f.zip
[Xaml[C]] check for compatible types on op_implicit (#715)
* [Xaml[C]] check for compatible types on op_implicit * fix merge issue
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml17
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml.cs54
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/XamlC/TypeReferenceExtensionsTests.cs1
3 files changed, 72 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml
new file mode 100644
index 00000000..7a1adf67
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml
@@ -0,0 +1,17 @@
+<?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
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml.cs
new file mode 100644
index 00000000..4284dde7
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45891.xaml.cs
@@ -0,0 +1,54 @@
+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
diff --git a/Xamarin.Forms.Xaml.UnitTests/XamlC/TypeReferenceExtensionsTests.cs b/Xamarin.Forms.Xaml.UnitTests/XamlC/TypeReferenceExtensionsTests.cs
index 9aa03b9e..1064166f 100644
--- a/Xamarin.Forms.Xaml.UnitTests/XamlC/TypeReferenceExtensionsTests.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/XamlC/TypeReferenceExtensionsTests.cs
@@ -48,6 +48,7 @@ namespace Xamarin.Forms.Xaml.XamlcUnitTests
[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)]