summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Xaml.UnitTests
diff options
context:
space:
mode:
authorStephane Delcroix <stephane@delcroix.org>2016-12-12 21:03:30 +0100
committerGitHub <noreply@github.com>2016-12-12 21:03:30 +0100
commite45bce1a64bd30c462abf51ab3b4eec69d5346aa (patch)
tree1f0169edfc221b241f92d1588221fd9fcaa009ad /Xamarin.Forms.Xaml.UnitTests
parent8257753d1b48de0e81d5bd431604f60d2065b6cc (diff)
downloadxamarin-forms-e45bce1a64bd30c462abf51ab3b4eec69d5346aa.tar.gz
xamarin-forms-e45bce1a64bd30c462abf51ab3b4eec69d5346aa.tar.bz2
xamarin-forms-e45bce1a64bd30c462abf51ab3b4eec69d5346aa.zip
[XamlC] Box valueTypes on Add() (#624)
This doesn't happen often, and I haven't found any valid XAML file out there requiring this, but in the case of 49307, it at least generates valid IL, which then fails with a NRE as this is the nature of callvirt.
Diffstat (limited to 'Xamarin.Forms.Xaml.UnitTests')
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml7
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml.cs47
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj6
3 files changed, 60 insertions, 0 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml
new file mode 100644
index 00000000..3bb6e203
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Application xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="Xamarin.Forms.Xaml.UnitTests.Bz49307">
+ <Application.Resources>
+ <!-- Application resource dictionary -->
+ <Color x:Key="MyColor">#c2d1d3</Color>
+ </Application.Resources>
+</Application>
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml.cs
new file mode 100644
index 00000000..166706af
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz49307.xaml.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Xamarin.Forms;
+using Xamarin.Forms.Core.UnitTests;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class Bz49307 : Application
+ {
+ public Bz49307()
+ {
+ InitializeComponent();
+ }
+
+ public Bz49307(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 ThrowOnMissingDictionary(bool useCompiledXaml)
+ {
+ if (useCompiledXaml)
+ Assert.Throws<NullReferenceException>(() => new Bz49307(useCompiledXaml));
+ else
+ Assert.Throws(new XamlParseExceptionConstraint(5, 4), () => new Bz49307(useCompiledXaml));
+ }
+ }
+ }
+} \ 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 2234c7f9..4f14fd36 100644
--- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
+++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
@@ -403,6 +403,9 @@
<Compile Include="I8.xaml.cs">
<DependentUpon>I8.xaml</DependentUpon>
</Compile>
+ <Compile Include="Issues\Bz49307.xaml.cs">
+ <DependentUpon>Bz49307.xaml</DependentUpon>
+ </Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="..\.nuspec\Xamarin.Forms.Debug.targets" />
@@ -727,6 +730,9 @@
<EmbeddedResource Include="I8.xaml">
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
+ <EmbeddedResource Include="Issues\Bz49307.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />