summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml15
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml.cs32
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/MockCompiler.cs30
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj11
4 files changed, 87 insertions, 1 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml
new file mode 100644
index 00000000..cc234879
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Bz43450">
+ <Grid>
+ <Grid.RowDefinition>
+ <RowDefinition Height="20"/>
+ <RowDefinition Height="*"/>
+ <RowDefinition Height="20"/>
+ </Grid.RowDefinition>
+ <BoxView BackgroundColor="Red"/>
+ <BoxView Grid.Row="1" BackgroundColor="Yellow"/>
+ <BoxView Grid.Row="2" BackgroundColor="Green"/>
+ </Grid>
+</ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml.cs
new file mode 100644
index 00000000..b3346b37
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz43450.xaml.cs
@@ -0,0 +1,32 @@
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ [XamlCompilation(XamlCompilationOptions.Skip)]
+ public partial class Bz43450 : ContentPage
+ {
+ public Bz43450()
+ {
+ InitializeComponent();
+ }
+
+ public Bz43450(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [TestCase(true)]
+ [TestCase(false)]
+ public void DoesNotAllowGridRowDefinition(bool useCompiledXaml)
+ {
+ if (!useCompiledXaml)
+ Assert.Throws<XamlParseException>(() => new Bz43450(useCompiledXaml));
+ else
+ Assert.Throws<XamlParseException>(() => MockCompiler.Compile(typeof(Bz43450)));
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/MockCompiler.cs b/Xamarin.Forms.Xaml.UnitTests/MockCompiler.cs
new file mode 100644
index 00000000..404169b3
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/MockCompiler.cs
@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+using Xamarin.Forms.Build.Tasks;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public static class MockCompiler
+ {
+ public static void Compile(Type type)
+ {
+ var assembly = type.Assembly.Location;
+ var refs = from an in type.Assembly.GetReferencedAssemblies()
+ let a = System.Reflection.Assembly.Load(an)
+ select a.Location;
+
+ var xamlc = new XamlCTask {
+ Assembly = assembly,
+ ReferencePath = string.Join(";", refs),
+ KeepXamlResources = true,
+ Type = type.FullName
+ };
+
+ var exceptions = new List<Exception>();
+ if (!xamlc.Compile(exceptions) && exceptions.Any())
+ throw exceptions [0];
+ }
+ }
+} \ 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 26bf6d41..16f54e88 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -81,6 +81,9 @@
<Link>MockPlatformServices.cs</Link>
</Compile>
<Compile Include="FontConverterTests.cs" />
+ <Compile Include="Issues\Bz43450.xaml.cs">
+ <DependentUpon>Bz43450.xaml</DependentUpon>
+ </Compile>
<Compile Include="Issues\Bz41296.xaml.cs">
<DependentUpon>Bz41296.xaml</DependentUpon>
</Compile>
@@ -362,6 +365,7 @@
<Compile Include="NativeViewsAndBindings.xaml.cs">
<DependentUpon>NativeViewsAndBindings.xaml</DependentUpon>
</Compile>
+ <Compile Include="MockCompiler.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -669,4 +673,9 @@
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
-</Project> \ No newline at end of file
+ <ItemGroup>
+ <EmbeddedResource Include="Issues\Bz43450.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ </ItemGroup>
+</Project>