diff --git a/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs b/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs index 85c3ca395..3f6ef265a 100644 --- a/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs +++ b/Xamarin.Forms.Build.Tasks/NodeILExtensions.cs @@ -103,8 +103,13 @@ namespace Xamarin.Forms.Build.Tasks if (compiledConverterName != null && (compiledConverterType = Type.GetType (compiledConverterName)) != null) { var compiledConverter = Activator.CreateInstance (compiledConverterType); var converter = typeof(ICompiledTypeConverter).GetMethods ().FirstOrDefault (md => md.Name == "ConvertFromString"); - var instructions = (IEnumerable)converter.Invoke (compiledConverter, new object[] { + IEnumerable instructions; + try { + instructions = (IEnumerable)converter.Invoke(compiledConverter, new object[] { node.Value as string, context, node as BaseNode}); + } catch (System.Reflection.TargetInvocationException tie) when (tie.InnerException is XamlParseException) { + throw tie.InnerException; + } foreach (var i in instructions) yield return i; if (targetTypeRef.IsValueType && boxValueTypes) diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml new file mode 100644 index 000000000..15a902e4f --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml @@ -0,0 +1,6 @@ + + + + diff --git a/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml.cs b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml.cs new file mode 100644 index 000000000..d78db0260 --- /dev/null +++ b/Xamarin.Forms.Xaml.UnitTests/Issues/Gh4099.xaml.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +using NUnit.Framework; + +using Xamarin.Forms; +using Xamarin.Forms.Core.UnitTests; + +namespace Xamarin.Forms.Xaml.UnitTests +{ + [XamlCompilation(XamlCompilationOptions.Skip)] + public partial class Gh4099 : ContentPage + { + public Gh4099() + { + InitializeComponent(); + } + + public Gh4099(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)] + public void BetterExceptionReport(bool useCompiledXaml) + { + if(useCompiledXaml) { + try { + MockCompiler.Compile(typeof(Gh4099)); + } catch (XamlParseException xpe) { + Assert.That(xpe.XmlInfo.LineNumber, Is.EqualTo(5)); + Assert.Pass(); + } + Assert.Fail(); + } + } + } + } +} diff --git a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj index 06c451db0..406404e0c 100644 --- a/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj +++ b/Xamarin.Forms.Xaml.UnitTests/Xamarin.Forms.Xaml.UnitTests.csproj @@ -652,6 +652,9 @@ Gh3821View.xaml + + Gh4099.xaml + @@ -1200,6 +1203,10 @@ Designer MSBuild:UpdateDesignTimeXaml + + MSBuild:UpdateDesignTimeXaml + Designer +