summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2017-01-28 00:32:45 +0100
committerE.Z. Hart <hartez@users.noreply.github.com>2017-01-27 16:32:45 -0700
commit1d3e7cf380a8a3a6949bd3f97f0d5ac41ae2d19d (patch)
tree9783dcde26a5800a2b98dc65f080ac8dd1d521f8 /Xamarin.Forms.Xaml.UnitTests
parent5d8575b77c42b36125eb7d1b57547ca69e5392b4 (diff)
downloadxamarin-forms-1d3e7cf380a8a3a6949bd3f97f0d5ac41ae2d19d.tar.gz
xamarin-forms-1d3e7cf380a8a3a6949bd3f97f0d5ac41ae2d19d.tar.bz2
xamarin-forms-1d3e7cf380a8a3a6949bd3f97f0d5ac41ae2d19d.zip
[XamlC] skip static .cctor while looking for default .ctor (#718)
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml14
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml.cs140
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj6
3 files changed, 160 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml
new file mode 100644
index 00000000..daaa8daa
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml
@@ -0,0 +1,14 @@
+<?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.Bz45299">
+ <local:Bz45299Control
+ BackgroundColor="Silver"
+ HorizontalOptions="FillAndExpand"
+ VerticalOptions="FillAndExpand" x:Name="ctrl">
+ <local:Bz45299Control.PortraitLayout>
+ <local:Bz45299OrientationLayout Count="3" Spacing="1" />
+ </local:Bz45299Control.PortraitLayout>
+ </local:Bz45299Control>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml.cs
new file mode 100644
index 00000000..791e870f
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz45299.xaml.cs
@@ -0,0 +1,140 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Xamarin.Forms;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public class Bz45299Control : ContentView
+ {
+ public static readonly BindableProperty PortraitLayoutProperty =
+ BindableProperty.Create(nameof(PortraitLayout), typeof(Bz45299OrientationLayout), typeof(Bz45299Control));
+ public Bz45299OrientationLayout PortraitLayout {
+ get { return (Bz45299OrientationLayout)GetValue(PortraitLayoutProperty); }
+ set { this.SetValue(PortraitLayoutProperty, value); }
+ }
+
+ }
+
+ public class Bz45299OrientationLayout : BindableObject
+ {
+ public static readonly BindableProperty SizeProperty =
+ BindableProperty.Create(nameof(Size), typeof(Bz45299UISize), typeof(Bz45299OrientationLayout), Bz45299UISize.Zero);
+ public Bz45299UISize Size {
+ get { return (Bz45299UISize)GetValue(SizeProperty); }
+ set { SetValue(SizeProperty, value); }
+ }
+
+ public static readonly BindableProperty SpacingProperty =
+ BindableProperty.Create(nameof(Spacing), typeof(Bz45299UILength), typeof(Bz45299OrientationLayout), Bz45299UILength.Zero);
+ public Bz45299UILength Spacing {
+ get { return (Bz45299UILength)GetValue(SpacingProperty); }
+ set { SetValue(SpacingProperty, value); }
+ }
+
+ public static readonly BindableProperty CountProperty =
+ BindableProperty.Create(nameof(Count), typeof(int), typeof(Bz45299OrientationLayout), 1);
+ public int Count {
+ get { return (int)GetValue(CountProperty); }
+ set { SetValue(CountProperty, value); }
+ }
+ }
+
+ [TypeConverter(typeof(Bz45299UILengthTypeConverter))]
+ public class Bz45299UILength
+ {
+ public static Bz45299UILength Zero => new Bz45299UILength { Value = 0 };
+
+ public double Value { get; set; }
+
+ public static implicit operator string(Bz45299UILength uiLength) => uiLength.Value.ToString();
+ public static implicit operator double(Bz45299UILength uiLength) => uiLength.Value;
+
+ public static implicit operator Bz45299UILength(string value) => Zero;
+ public static implicit operator Bz45299UILength(long value) => Zero;
+ public static implicit operator Bz45299UILength(ulong value) => Zero;
+ public static implicit operator Bz45299UILength(int value) => Zero;
+ public static implicit operator Bz45299UILength(uint value) => Zero;
+ public static implicit operator Bz45299UILength(double value) => Zero;
+ public static implicit operator Bz45299UILength(float value) => Zero;
+ }
+
+ public class Bz45299UILengthTypeConverter : TypeConverter
+ {
+ static readonly Type StringType = typeof(string);
+ public override bool CanConvertFrom(Type sourceType)
+ {
+ if (sourceType != StringType)
+ return false;
+
+ return true;
+ }
+
+ public override object ConvertFromInvariantString(string value) => Bz45299UILength.Zero;
+ }
+
+ [TypeConverter(typeof(Bz45299UISizeTypeConverter))]
+ public class Bz45299UISize
+ {
+ public static Bz45299UISize Zero => new Bz45299UISize { Width = 0, Height = 0 };
+
+ public Bz45299UILength Width { get; set; }
+ public Bz45299UILength Height { get; set; }
+
+ public static implicit operator Bz45299UISize(string value) => Zero;
+ public static implicit operator Size(Bz45299UISize uiSize) => new Size(uiSize.Width, uiSize.Height);
+ public static implicit operator Bz45299UISize(Size size) => new Bz45299UISize { Width = size.Width, Height = size.Height };
+ }
+
+ public class Bz45299UISizeTypeConverter : TypeConverter
+ {
+ private static readonly Type StringType = typeof(string);
+
+ public override bool CanConvertFrom(Type sourceType)
+ {
+ if (sourceType != StringType)
+ return false;
+
+ return true;
+ }
+
+ public override object ConvertFromInvariantString(string value) => Bz45299UISize.Zero;
+ }
+
+ public partial class Bz45299 : ContentPage
+ {
+ public Bz45299()
+ {
+ InitializeComponent();
+ }
+ public Bz45299(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [SetUp]
+ public void Setup()
+ {
+ Device.PlatformServices = new MockPlatformServices();
+ }
+
+ [TearDown]
+ public void TearDown()
+ {
+ Device.PlatformServices = null;
+ }
+
+ [TestCase(true)]
+ [TestCase(false)]
+ public void XamlCCustomTypeConverter(bool useCompiledXaml)
+ {
+ var p = new Bz45299(useCompiledXaml);
+ Assert.AreEqual(0d, p.ctrl.PortraitLayout.Spacing.Value);
+ }
+ }
+ }
+} \ 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 e4ac262f..631d0010 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -418,6 +418,9 @@
<Compile Include="Issues\Bz42531.xaml.cs">
<DependentUpon>Bz42531.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Bz45299.xaml.cs">
+ <DependentUpon>Bz45299.xaml</DependentUpon>
+ </Compile>
<Compile Include="Issues\Bz43733.xaml.cs">
<DependentUpon>Bz43733.xaml</DependentUpon>
</Compile>
@@ -760,6 +763,9 @@
<EmbeddedResource Include="Issues\Bz42531.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz45299.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
<EmbeddedResource Include="Issues\Bz43733.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>