Skip to content

SourceGen with invalid x:DataType or invalid bindings does not emit errors #33417

@zwikk

Description

@zwikk

Description

Looks like applying <MauiXamlInflator>SourceGen</MauiXamlInflator> while having invalid x:DataType or bindings no longer raises build errors.

I have tested a couple of scenario's with and without SourceGen in Debug and Release builds. Am I using it wrong?

Compile invalid x:DataType

Expectation: local:Foo does not exist, build should fail

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MauiApp5"
             x:Class="MauiApp5.MainPage"
             x:DataType="local:Foo">
    
</ContentPage>
  1. Debug, runtime inflation => SUCCESS
  2. Debug, source generator => SUCCESS
  3. Release, XamlC => Error XC0000 XamlC: Cannot resolve type "clr-namespace:MauiApp5:Foo".
  4. Release, source generator => SUCCESS

Only XamlC seems to work correct. I would expect SourceGen to fail in both Debug and Release builds.

Compile invalid Binding

Expectation: {Binding Foo} does not exist, build should fail

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:MauiApp5"
             x:Class="MauiApp5.MainPage"
             x:DataType="local:MainPage">
    
    <Label Text="{Binding Foo}"></Label>
    
</ContentPage>
  1. Debug, runtime inflation => SUCCESS
  2. Debug, source generator => SUCCESS
  3. Release, XamlC => Error XC0045 XamlC: Binding: Property "Foo" not found on "MauiApp5.MainPage".
  4. Release, source generator => SUCCESS

Again only XamlC seems to work correct. I would expect SourceGen to fail in both Debug and Release builds.

Also MauiStrictXamlCompilation does not seem to have any effect in all scenario's

Steps to Reproduce

  1. Open the repro project
  2. Compile with SourceGen
  3. Observe no build errors, which is unexpected.

Link to public reproduction project repository

https://github.com/zwikk/maui-playground/tree/main/Source/SourceGenTest

Version with bug

10.0.20

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

Unknown/Other

Affected platforms

iOS, Android

Affected platform versions

No response

Did you find any workaround?

Do not use SourceGen.

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorsi/regressionThis issue described a confirmed regression on a currently supported versionpartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/androidregressed-in-10-rc1s/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions