summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-01 22:14:22 +0100
committerGitHub <noreply@github.com>2016-12-01 22:14:22 +0100
commit3d85653f270854b4aab82e45e6e58afb760feb85 (patch)
tree7ca0bc75cdc5f6e7a0ca48e6f443c136083ad014
parent70d29b9e924b3185f4b1de188ba799b26a14b108 (diff)
downloadxamarin-forms-3d85653f270854b4aab82e45e6e58afb760feb85.tar.gz
xamarin-forms-3d85653f270854b4aab82e45e6e58afb760feb85.tar.bz2
xamarin-forms-3d85653f270854b4aab82e45e6e58afb760feb85.zip
[XamlC] assigned derived type to generic BP (#566)
* [XamlC] assigned derived type to generic BP * [XamlC] fix 48554 * f
-rw-r--r--Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs3
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml9
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml.cs68
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml12
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml.cs37
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj12
6 files changed, 141 insertions, 0 deletions
diff --git a/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs b/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
index 60e52c80..f0a6cef7 100644
--- a/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
+++ b/Xamarin.Forms.Build.Tasks/TypeReferenceExtensions.cs
@@ -84,6 +84,9 @@ namespace Xamarin.Forms.Build.Tasks
public static bool InheritsFromOrImplements(this TypeReference typeRef, TypeReference baseClass)
{
+ if (typeRef.FullName == baseClass.FullName)
+ return true;
+
var arrayInterfaces = new[]
{
"System.IEnumerable",
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml
new file mode 100644
index 00000000..805d1bb1
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml
@@ -0,0 +1,9 @@
+<?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.Bz48554">
+ <local:Bz48554Slider
+ x:Name="SliderGrades"
+ Values="{x:Static local:Bz48554View.All}" />
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml.cs
new file mode 100644
index 00000000..e5b814b0
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz48554.xaml.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Windows.Input;
+using NUnit.Framework;
+using Xamarin.Forms;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class Bz48554View
+ {
+ static List<string> all;
+
+ public static List<string> All {
+ get {
+ if (all == null) {
+ all = new List<string>();
+ all.Add("6b+");
+ all.Add("6c");
+ all.Add("6c+");
+ all.Add("7a");
+ all.Add("7a+");
+ }
+ return all;
+ }
+ set {
+ all = value;
+ }
+ }
+ }
+
+ public class Bz48554Slider : View
+ {
+ public static readonly BindableProperty ValuesProperty =
+ BindableProperty.Create(nameof(Values), typeof(List<string>), typeof(Bz48554Slider), null);
+
+ public List<string> Values {
+ get { return (List<string>)GetValue(ValuesProperty); }
+ set { SetValue(ValuesProperty, value); }
+ }
+ }
+
+ public partial class Bz48554 : ContentPage
+ {
+ public Bz48554()
+ {
+ InitializeComponent();
+ }
+
+ public Bz48554(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [TestCase(true)]
+ [TestCase(false)]
+ public void XStaticWithXamlC(bool useCompiledXaml)
+ {
+ Bz48554 page = null;
+ Assert.DoesNotThrow(()=> page = new Bz48554(useCompiledXaml));
+ Assert.NotNull(page.SliderGrades);
+ Assert.AreEqual(5, page.SliderGrades.Values.Count);
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml
new file mode 100644
index 00000000..a1afaf48
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml
@@ -0,0 +1,12 @@
+<?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.Unreported006">
+ <local:Unreported006.GenericProperty>
+ <StackLayout/>
+ </local:Unreported006.GenericProperty>
+ <ContentPage.Content>
+ </ContentPage.Content>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml.cs
new file mode 100644
index 00000000..657c6ffe
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Unreported006.xaml.cs
@@ -0,0 +1,37 @@
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class Unreported006 : ContentPage
+ {
+ public Unreported006()
+ {
+ InitializeComponent();
+ }
+
+ public Unreported006(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ public Layout<View> GenericProperty {
+ get { return (Layout<View>)GetValue(GenericPropertyProperty); }
+ set { SetValue(GenericPropertyProperty, value); }
+ }
+
+ public static readonly BindableProperty GenericPropertyProperty =
+ BindableProperty.Create(nameof(GenericProperty), typeof(Layout<View>), typeof(Unreported006));
+
+ [TestFixture]
+ class Tests
+ {
+ [TestCase(true), TestCase(false)]
+ public void CanAssignGenericBP(bool useCompiledXaml)
+ {
+ var page = new Unreported006();
+ Assert.NotNull(page.GenericProperty);
+ Assert.That(page.GenericProperty, Is.TypeOf<StackLayout>());
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index d4b65438..3708d1f1 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -379,6 +379,12 @@
<Compile Include="Issues\Bz47950.xaml.cs">
<DependentUpon>Bz47950.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Unreported006.xaml.cs">
+ <DependentUpon>Unreported006.xaml</DependentUpon>
+ </Compile>
+ <Compile Include="Issues\Bz48554.xaml.cs">
+ <DependentUpon>Bz48554.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -679,6 +685,12 @@
<EmbeddedResource Include="Issues\Bz47950.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Unreported006.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz48554.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />