summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schwarz <christian.schwarz@refactory.at>2016-05-27 13:58:21 +0200
committerRui Marinho <me@ruimarinho.net>2016-05-27 12:58:21 +0100
commitd1ab4e1ce8b77a6df1d9981db69eff156ee945a6 (patch)
treefea48d174c403e8090418bd16f5637e67b7b0dd2
parentbf7399d06815d906bde609e23ad48faa452390f0 (diff)
downloadxamarin-forms-d1ab4e1ce8b77a6df1d9981db69eff156ee945a6.tar.gz
xamarin-forms-d1ab4e1ce8b77a6df1d9981db69eff156ee945a6.tar.bz2
xamarin-forms-d1ab4e1ce8b77a6df1d9981db69eff156ee945a6.zip
[Xaml] Fix MarkupExtension not found in default namespace (#183)
* [Xaml] Fix MarkupExtension not found in default namespace * Fixed indentation * Added XamlC unit test
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml7
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml.cs33
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/MarkupExtensionTests.cs16
-rw-r--r--Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj9
-rw-r--r--Xamarin.Forms.Xaml/XamlServiceProvider.cs2
5 files changed, 65 insertions, 2 deletions
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml
new file mode 100644
index 00000000..cfa42575
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<forms:ContentPage xmlns="clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests"
+ xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
+ xmlns:forms="http://xamarin.com/schemas/2014/forms"
+ x:Class="Xamarin.Forms.Xaml.UnitTests.Bz41296">
+ <forms:Label x:Name="TestLabel" Text="{AppendMarkupExtension Value0=Foo, Value1=Bar}" />
+</forms:ContentPage> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml.cs
new file mode 100644
index 00000000..f717d443
--- /dev/null
+++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Bz41296.xaml.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+
+using Xamarin.Forms;
+using NUnit.Framework;
+
+namespace Xamarin.Forms.Xaml.UnitTests
+{
+ public partial class Bz41296 : ContentPage
+ {
+ public Bz41296()
+ {
+ InitializeComponent ();
+ }
+
+ public Bz41296(bool useCompiledXaml)
+ {
+ //this stub will be replaced at compile time
+ }
+
+ [TestFixture]
+ class Tests
+ {
+ [TestCase(true)]
+ [TestCase(false)]
+ public void MarkupExtensionInDefaultNamespace(bool useCompiledXaml)
+ {
+ var layout = new Bz41296 (useCompiledXaml);
+ Assert.AreEqual("FooBar", layout.TestLabel.Text.ToString());
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml.UnitTests/MarkupExtensionTests.cs b/Xamarin.Forms.Xaml.UnitTests/MarkupExtensionTests.cs
index ebc32f4a..9d76c016 100644
--- a/Xamarin.Forms.Xaml.UnitTests/MarkupExtensionTests.cs
+++ b/Xamarin.Forms.Xaml.UnitTests/MarkupExtensionTests.cs
@@ -158,6 +158,22 @@ namespace Xamarin.Forms.Xaml.UnitTests
}
[Test]
+ public void TestMarkupExtensionInDefaultNamespace ()
+ {
+ var xaml = @"
+ <forms:Label
+ xmlns=""clr-namespace:Xamarin.Forms.Xaml.UnitTests;assembly=Xamarin.Forms.Xaml.UnitTests""
+ xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
+ xmlns:forms=""http://xamarin.com/schemas/2014/forms""
+ Text=""{AppendMarkupExtension Value0=Foo, Value1=Bar}""
+ />";
+
+ var label = new Label();
+ label.LoadFromXaml(xaml);
+ Assert.AreEqual("FooBar", label.Text.ToString());
+ }
+
+ [Test]
public void TestDocumentationCode ()
{
var xaml =@"
diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj
index 41ff3afd..417e800a 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\Bz41296.xaml.cs">
+ <DependentUpon>Bz41296.xaml</DependentUpon>
+ </Compile>
<Compile Include="LoaderTests.cs" />
<Compile Include="ViewExtensionsTest.cs" />
<Compile Include="MarkupExpressionParserTests.cs" />
@@ -629,5 +632,9 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
- <ItemGroup />
+ <ItemGroup>
+ <EmbeddedResource Include="Issues\Bz41296.xaml">
+ <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
+ </EmbeddedResource>
+ </ItemGroup>
</Project> \ No newline at end of file
diff --git a/Xamarin.Forms.Xaml/XamlServiceProvider.cs b/Xamarin.Forms.Xaml/XamlServiceProvider.cs
index 8998e6f5..77ed6345 100644
--- a/Xamarin.Forms.Xaml/XamlServiceProvider.cs
+++ b/Xamarin.Forms.Xaml/XamlServiceProvider.cs
@@ -235,7 +235,7 @@ namespace Xamarin.Forms.Xaml.Internals
xmlLineInfo = lineInfoProvider.XmlLineInfo;
}
- var namespaceuri = string.IsNullOrEmpty(prefix) ? "" : namespaceResolver.LookupNamespace(prefix);
+ var namespaceuri = prefix == null ? "" : namespaceResolver.LookupNamespace(prefix);
if (namespaceuri == null)
{
exception = new XamlParseException(string.Format("No xmlns declaration for prefix \"{0}\"", prefix), xmlLineInfo);