Skip to content

Commit

Permalink
[X] Don't remove enclosing quotes (xamarin#12813) fixes xamarin#12763
Browse files Browse the repository at this point in the history
Quotes are already parsed, and handled elsewhere

- fixes xamarin#12763
  • Loading branch information
StephaneDelcroix authored Nov 12, 2020
1 parent e622481 commit b2a1a82
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Xamarin.Forms.Xaml.UnitTests/Issues/Gh12763.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?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.Gh12763">
<Label x:Name="label" Text="{Binding ., StringFormat='&quot;{0}&quot;', Source=Foo}" />
</ContentPage>
33 changes: 33 additions & 0 deletions Xamarin.Forms.Xaml.UnitTests/Issues/Gh12763.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
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 Gh12763 : ContentPage
{
public Gh12763() => InitializeComponent();
public Gh12763(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;

[Test]
public void QuotesInStringFormat([Values(false, true)] bool useCompiledXaml)
{
var layout = new Gh12763(useCompiledXaml);
Assert.That(layout.label.Text, Is.EqualTo("\"Foo\""));
}
}
}
}
11 changes: 0 additions & 11 deletions Xamarin.Forms.Xaml/MarkupExpressionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,6 @@ string GetNextPiece(IServiceProvider serviceProvider, ref string remaining, out
while (piece.Length > 0 && char.IsWhiteSpace(piece[piece.Length - 1]))
piece.Length--;

if (piece.Length >= 2)
{
char first = piece[0];
char last = piece[piece.Length - 1];
if ((first == '\'' && last == '\'') || (first == '"' && last == '"'))
{
piece.Remove(piece.Length - 1, 1);
piece.Remove(0, 1);
}
}

return piece.ToString();
}

Expand Down

0 comments on commit b2a1a82

Please sign in to comment.