Skip to content

MAUI Xaml SourceGen breaks when nullable is enabled and <WarningsAsErrors>Nullable</WarningsAsErrors> is set #32893

@Jakar510

Description

@Jakar510

Description

MAUI Xaml SourceGen breaks when nullable is enabled and <WarningsAsErrors>Nullable</WarningsAsErrors> is set in the csproj.

Steps to Reproduce

Setup your csproj something like:

<TargetFrameworks>net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks> <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net10.0-windows10.0.19041.0</TargetFrameworks> <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> <!-- <TargetFrameworks>$(TargetFrameworks);net10.0-tizen</TargetFrameworks> --> <UseMaui>true</UseMaui> <SingleProject>true</SingleProject> <ImplicitUsings>enable</ImplicitUsings> <Nullable>enable</Nullable> <AllowUnsafeBlocks>true</AllowUnsafeBlocks> <GeneratedFolder>Generated</GeneratedFolder> <MauiXamlInflator>SourceGen</MauiXamlInflator> <!-- <EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles> --> <!-- <CompilerGeneratedFilesOutputPath>Generated</CompilerGeneratedFilesOutputPath> --> <MauiEnableXamlCBindingWithSourceCompilation>true</MauiEnableXamlCBindingWithSourceCompilation> <NoWarn>$(NoWarn);1701;1702;1591;IDE0079;IDE0046;CA2208;IL2121;CS1573;CS1591;CA1416</NoWarn> <WarningsAsErrors>Nullable;CS0114;CS0108</WarningsAsErrors> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>

Try to run the build in release. debug has issues too but sometimes still builds and runs.

Link to public reproduction project repository

No response

Version with bug

10.0.11

Is this a regression from previous behavior?

No, this is something new

Last version that worked well

No response

Affected platforms

iOS, Android

Affected platform versions

iOS 26.1 / Android 16

Did you find any workaround?

Disable <WarningsAsErrors>Nullable</WarningsAsErrors>

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-xamlXAML, CSS, Triggers, Behaviorss/needs-attentionIssue has more information and needs another looks/needs-infoIssue needs more info from the authors/needs-reproAttach a solution or code which reproduces the issuet/bugSomething isn't workingxsgXaml sourceGen

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions