Bad XAML still compiles with no error, then runtime error occurs in Xamarin.Forms project

Viewed 516

Context

In my all projects (including a freshly created one) I can make typo's in my XAML, which then compiles with no error, no warning. Of course runtime an Exception throws.

Question

Is this normal or something went wrong in my Visual Studio 2017.3?

enter image description here

1 Answers

This is normal when writing Xaml both for Xamarin.Forms and WPF

One benefit Xamarin does bring though is Xaml Compliation

XAML can be optionally compiled directly into intermediate language (IL) with the XAML compiler (XAMLC).

XAMLC offers a number of a benefits:

  • It performs compile-time checking of XAML, notifying the user of any errors.

  • It removes some of the load and instantiation time for XAML elements.

  • It helps to reduce the file size of the final assembly by no longer including .xaml files.

Notice the first bullet point here:

  • It performs compile-time checking of XAML, notifying the user of any errors.

To use this do the following:

The following code example demonstrates enabling XAMLC at the assembly level:

using Xamarin.Forms.Xaml;
...
[assembly: XamlCompilation (XamlCompilationOptions.Compile)]
namespace PhotoApp
{
   ...
}
Related