Skip to content

Build succeeds with bad XAML - source gen #31602

@davidortinau

Description

@davidortinau

Description

I was getting an error at runtime

Object of type 'System.String' cannot be converted to type 'Microsoft.Maui.Controls.Setter'.

I found that this XAML was in the project.

<Style TargetType="Page"
               ApplyToDerivedTypes="True">
                <Setter Property="Padding"
                        Value="0"/>
                ckgroundColor"
                        Value="{AppThemeBinding Light={StaticResource LightBackground}, Dark={StaticResource DarkBackground}}"/>
        </Style>

Which is obviously incomplete (thanks to a borked refactoring). This should never have been able to build.

I have XAML source gen enabled.

WellDone.zip

By some accident of fortune, the app would actually run in some cases too after passing the RTE. Other times it would crash. I think it depended on which debugger was being used.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

10.0.0-rc.1

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI, No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

macOS, Windows, Android, iOS

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

Metadata

Metadata

Labels

area-xamlXAML, CSS, Triggers, Behaviorst/bugSomething isn't workingxsgXaml sourceGen

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions