Skip to content

Commit

Permalink
Merge branch '3.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
StephaneDelcroix committed Mar 26, 2018
2 parents 2679246 + 4214466 commit f70dad0
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 2 deletions.
8 changes: 8 additions & 0 deletions Xamarin.Forms.Xaml.UnitTests/Issues/Gh2171.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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="using:Xamarin.Forms.Xaml.UnitTests"
x:Class="Xamarin.Forms.Xaml.UnitTests.Gh2171"
x:Name="this"
BindingContext="{local:Gh2171 Foo='foo', Binding={Binding Text, Source={x:Reference this}}, Bar='bar'}">
</ContentPage>
54 changes: 54 additions & 0 deletions Xamarin.Forms.Xaml.UnitTests/Issues/Gh2171.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using NUnit.Framework;
using Xamarin.Forms.Core.UnitTests;

namespace Xamarin.Forms.Xaml.UnitTests
{
public partial class Gh2171 : ContentPage
{
public Gh2171()
{
InitializeComponent();
}

public Gh2171(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(false), TestCase(true)]
public void ParsingNestedMarkups(bool useCompiledXaml)
{
var layout = new Gh2171(useCompiledXaml);
var markup = layout.BindingContext as Gh2171Extension;
Assert.That(markup, Is.Not.Null);
Assert.That(markup.Foo, Is.EqualTo("foo"));
Assert.That(markup.Bar, Is.EqualTo("bar"));
Assert.That((markup.Binding as Binding).Path, Is.EqualTo("Text"));
}
}
}

public class Gh2171Extension : IMarkupExtension
{
public string Foo { get; set; }
public string Bar { get; set; }
public BindingBase Binding { get; set; }
object IMarkupExtension.ProvideValue(IServiceProvider serviceProvider) => this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@
<Compile Include="Issues\Gh2130.xaml.cs">
<DependentUpon>Gh2130.xaml</DependentUpon>
</Compile>
<Compile Include="Issues\Gh2171.xaml.cs">
<DependentUpon>Gh2171.xaml</DependentUpon>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

Expand Down Expand Up @@ -1074,6 +1077,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
<EmbeddedResource Include="Issues\Gh2171.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
Expand Down
6 changes: 4 additions & 2 deletions Xamarin.Forms.Xaml/MarkupExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

namespace Xamarin.Forms.Xaml
{
internal abstract class MarkupExpressionParser
abstract class MarkupExpressionParser
{
public object ParseExpression(ref string expression, IServiceProvider serviceProvider)
{
if (serviceProvider == null)
throw new ArgumentNullException("serviceProvider");
throw new ArgumentNullException(nameof(serviceProvider));
if (expression.StartsWith("{}", StringComparison.Ordinal))
return expression.Substring(2);

Expand Down Expand Up @@ -131,6 +131,8 @@ protected void HandleProperty(string prop, IServiceProvider serviceProvider, ref

if (remaining.Length > 0 && remaining[0] == ',')
remaining = remaining.Substring(1);
else if (remaining.Length > 0 && remaining[0] == '}')
remaining = remaining.Substring(1);

str_value = value as string;
}
Expand Down

0 comments on commit f70dad0

Please sign in to comment.