Skip to content

Obsolete AutomationProperties properties cause XamlC exception on NET 8 #17484

@GalaxiaGuy

Description

@GalaxiaGuy

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

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions