From 6753ace40e68f8aa6d45eefa90117f5650984c6f Mon Sep 17 00:00:00 2001 From: Stephane Delcroix Date: Wed, 19 Dec 2018 16:14:21 +0100 Subject: [PATCH] [Xaml] require escaping curly braces (#4723) This is a breaking change as we weren't throwing errors on that before. - fixes #2756 --- .../EmptyViewTemplateGallery.xaml | 2 +- Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml | 7 +++ Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml.cs | 34 ++++++++++++ Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml | 6 +-- Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml | 4 +- Xamarin.Forms.Xaml.UnitTests/Issues/Issue1549.cs | 2 +- .../MarkupExpressionParserTests.cs | 22 +++++--- Xamarin.Forms.Xaml/MarkupExpressionParser.cs | 14 +++-- Xamarin.Forms.Xaml/MarkupExtensionParser.cs | 62 ++++++++++++---------- 9 files changed, 108 insertions(+), 45 deletions(-) create mode 100644 Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml create mode 100644 Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml.cs diff --git a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EmptyViewGalleries/EmptyViewTemplateGallery.xaml b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EmptyViewGalleries/EmptyViewTemplateGallery.xaml index da35604..b94c268 100644 --- a/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EmptyViewGalleries/EmptyViewTemplateGallery.xaml +++ b/Xamarin.Forms.Controls/GalleryPages/CollectionViewGalleries/EmptyViewGalleries/EmptyViewTemplateGallery.xaml @@ -20,7 +20,7 @@ + Text="{Binding Filter, StringFormat='{}Your filter term of {0} did not match any records'}"> diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml new file mode 100644 index 0000000..c9259f7 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml @@ -0,0 +1,7 @@ + + + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml.cs new file mode 100644 index 0000000..eae564d --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh2756.xaml.cs @@ -0,0 +1,34 @@ +using NUnit.Framework; + +using Xamarin.Forms.Core.UnitTests; + +using Xamarin.Forms; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [XamlCompilation(XamlCompilationOptions.Skip)] + public partial class Gh2756 : ContentPage + { + public Gh2756() => InitializeComponent(); + public Gh2756(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 UnescapedBraces([Values(false, true)]bool useCompiledXaml) + { + if (useCompiledXaml) + Assert.Throws(() => MockCompiler.Compile(typeof(Gh2756))); + else + Assert.Throws(() => new Gh2756(useCompiledXaml)); + } + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml index a6b9da7..90a0b78 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh3539.xaml @@ -12,11 +12,11 @@ diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml index f31c52a..4fb3672 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Issue1438.xaml @@ -1,11 +1,11 @@ - +