maui icon indicating copy to clipboard operation
maui copied to clipboard

Converters are not validated after navigation with debugger

Open pekspro opened this issue 3 years ago • 3 comments

Description

If you have a control like this with an converter that doesn't exist:

    <Label Text="{Binding SomeProperty, Converter={StaticResource NoneExistingConverter}}" />

You will get an XamlParseException with a message like:

Position 10:16. StaticResource not found for key NoneExistingConverter

But only on the primary page it seems. If this control instead exists on a page that is later navigated to with debugger attached, no exception will be thrown. But the application will crash when executed without a debugger.

Demo project

Steps to Reproduce

1 Create a new MAUI app. 2 Update MainPage.xaml:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiIssues.MainPage">
    <VerticalStackLayout>
        <Label 
            Text="Hello, World!"
            FontSize="32"
            HorizontalOptions="Center" />

        <Button 
            Text="Open second page"
            Clicked="OnCounterClicked"
            HorizontalOptions="Center" />
    </VerticalStackLayout>
</ContentPage>

3 MainPage.cs:

public partial class MainPage : ContentPage
{
	public MainPage()
	{
		InitializeComponent();
	}

	private async void OnCounterClicked(object sender, EventArgs e)
	{
		Routing.RegisterRoute(nameof(SecondPage), typeof(SecondPage));
		await Shell.Current.GoToAsync(nameof(SecondPage));
	}
}

4 Add SecondPage:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="MauiIssues.SecondPage">
    <VerticalStackLayout>
        <Label Text="Hello world" />
        <Label Text="{Binding SomeProperty, Converter={StaticResource NoneExistingConverter}}" />
        <Label Text="This page will work debugger attached, but crash without debugger." />
    </VerticalStackLayout>
</ContentPage>
  1. Run the application with and without a debugger.

Version with bug

Release Candidate 1 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android, Windows, I was not able test on other platforms

Affected platform versions

Windows 10.0.17763.0, Android 10

Did you find any workaround?

No response

Relevant log output

No response

pekspro avatar Apr 17 '22 07:04 pekspro

Verified this issue with Visual Studio Enterprise 17.3.0 Preview 1.0 [32414.199.main]. Repro on Windows and Android with above project.

XamlTest avatar Apr 18 '22 01:04 XamlTest

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

ghost avatar Aug 30 '22 15:08 ghost

I've updated sample application to .NET 7. The same issue remains.

pekspro avatar Nov 11 '22 19:11 pekspro

Verified this issue with Visual Studio Enterprise 17.6.0 Preview 2.0. Repro on android emulator with above project. image

homeyf avatar Apr 20 '23 05:04 homeyf

I'm not sure why this issue isn't receiving more attention. Right now, we have an iOS MAUI app and the only way to find StaticResource not found errors is to deploy the app on a physical device. Is there another approach?

NeilN1 avatar Mar 18 '24 16:03 NeilN1