dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
21.99k stars 1.72k forks source link

Converters are not validated after navigation with debugger #6171

Open pekspro opened 2 years ago

pekspro commented 2 years ago

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

XamlTest commented 2 years ago

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

ghost commented 2 years ago

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.

pekspro commented 1 year ago

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

homeyf commented 1 year ago

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

NeilN1 commented 6 months ago

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?