Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obsolete AutomationProperties properties cause XamlC exception on NET 8 #17484

Closed
GalaxiaGuy opened this issue Sep 19, 2023 · 2 comments · Fixed by #17507
Closed

Obsolete AutomationProperties properties cause XamlC exception on NET 8 #17484

GalaxiaGuy opened this issue Sep 19, 2023 · 2 comments · Fixed by #17507
Assignees
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.2.9373 Look for this fix in 8.0.0-rc.2.9373! migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 t/bug Something isn't working
Milestone

Comments

@GalaxiaGuy
Copy link
Contributor

GalaxiaGuy commented Sep 19, 2023

Description

Using AutomationProperties.Name or AutomationProperties.Hint (and I would guess the other deprecated AutomationProperties attached properties) inside a DataTemplate in a control's Resources generates the error XamlC error : Object reference not set to an instance of an object. at compile time.

I'm in the process of porting a large app. It previously worked against .NET 7 and did not see this issue.

Steps to Reproduce

Add something like the following to a XAML file:

    <ContentPage.Resources>
        <DataTemplate x:Key="Template">
            <Image
                Source="dotnet_bot.png"
                AutomationProperties.Name="Cute dot net bot waving hi to you!"
                HeightRequest="200"
                HorizontalOptions="Center" />        
        </DataTemplate>
    </ContentPage.Resources>

Link to public reproduction project repository

https://github.com/GalaxiaGuy/MauiBugs/tree/main

Version with bug

8.0.0-preview.1.7762

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, Yes, this used to work in Xamarin.Forms

Last version that worked well

7.0.92

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

Updating the properties to the correct SemanticProperties equivalents allows the project to compile. It took some trial and error to work out what was causing the problem though.

Relevant log output

No response

@GalaxiaGuy GalaxiaGuy added the t/bug Something isn't working label Sep 19, 2023
@GalaxiaGuy GalaxiaGuy changed the title Deprecated AutomationProperties properties cause XamlC exception on NET 8 Obsolete AutomationProperties properties cause XamlC exception on NET 8 Sep 19, 2023
@samhouts samhouts changed the title Obsolete AutomationProperties properties cause XamlC exception on NET 8 [regression/8.0.0] Obsolete AutomationProperties properties cause XamlC exception on NET 8 Sep 19, 2023
@samhouts samhouts added area-xaml XAML, CSS, Triggers, Behaviors potential-regression This issue described a possible regression on a currently supported version., verification pending labels Sep 19, 2023
@samhouts samhouts added this to the .NET 8 GA milestone Sep 19, 2023
@samhouts samhouts added the migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert label Sep 19, 2023
@samhouts samhouts changed the title [regression/8.0.0] Obsolete AutomationProperties properties cause XamlC exception on NET 8 Obsolete AutomationProperties properties cause XamlC exception on NET 8 Sep 19, 2023
@samhouts
Copy link
Member

The AutomationProperties were obsoleted in #13104, which released in 8.0.0-preview.1.7762. I think it's technically not a regression in XamlC (it probably always had the behavior of blowing up on now non-existent attached properties), but it does need to have a better error message.

@samhouts samhouts removed the potential-regression This issue described a possible regression on a currently supported version., verification pending label Sep 19, 2023
@StephaneDelcroix
Copy link
Contributor

there is a LogWarning, but it looks like it's throwing anyway

@samhouts samhouts added the fixed-in-8.0.0-rc.2.9373 Look for this fix in 8.0.0-rc.2.9373! label Oct 10, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Nov 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-xaml XAML, CSS, Triggers, Behaviors fixed-in-8.0.0-rc.2.9373 Look for this fix in 8.0.0-rc.2.9373! migration-compatibility Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert platform/android 🤖 platform/iOS 🍎 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants