Skip to content

[XSG] XSG throws NotImplementedException when Style Setter targets partial property with [BindableProperty] attribute #33835

@simonrozsival

Description

@simonrozsival

Description

The XAML Source Generator (XSG) throws NotImplementedException with error MAUIG1001 when processing a Style.Setter that uses a markup extension (like {StaticResource}) on a partial property decorated with CommunityToolkit.MAUI's [BindableProperty] attribute.

Steps to Reproduce

  1. Create a .NET MAUI app targeting .NET 10
  2. Add CommunityToolkit.Maui package
  3. Create a custom control with a partial property using [BindableProperty]:
using CommunityToolkit.Maui.GeneratedBindableProperty;

public partial class MyLabel : Label
{
    [BindableProperty]
    public partial Color MyColor { get; set; }
}
  1. In XAML, use a Style.Setter with a markup extension targeting that property:
<ContentPage.Resources>
    <Color x:Key="TestColor">Red</Color>
    <Style TargetType="local:MyLabel">
        <Setter Property="MyColor" Value="{StaticResource TestColor}" />
    </Style>
</ContentPage.Resources>
  1. Build with: dotnet build -f net10.0-android

Expected Behavior

The XAML Source Generator should either:

  • Successfully generate code for the Style Setter
  • Or produce a clear diagnostic explaining that the BindableProperty field is not visible

Actual Behavior

Build fails with:

error MAUIG1001: An error occured while parsing Xaml: The method or operation is not implemented.

The MainPage.xaml.xsg.cs file is not generated at all.

Root Cause Analysis

The bug occurs because source generators run in isolation and in parallel:

  1. CommunityToolkit.MAUI's source generator creates MyColorProperty field from the [BindableProperty] attribute
  2. XAML Source Generator (XSG) runs in parallel and sees only the original compilation (without other SG's output)
  3. When XSG processes <Setter Property="MyColor" Value="{StaticResource TestColor}" />:
    • NodeSGExtensions.GetBindableProperty() looks for the MyColorProperty field
    • Field is not found → returns null
    • SetterValueProvider.TryProvideValue() calls bpRef.ToFQDisplayString() with null
    • ISymbolExtensions.ToFQDisplayString() has no type pattern matching null → throws NotImplementedException

Key code path:

  • SetterValueProvider.cs:54bpNode.GetBindableProperty(context) returns null
  • SetterValueProvider.cs:64bpRef.ToFQDisplayString() called with null
  • ISymbolExtensions.cs:24 → throws NotImplementedException (no pattern matches null)

Workaround

Use simple values instead of markup extensions:

<!-- Works -->
<Setter Property="MyColor" Value="Red" />

<!-- Fails -->
<Setter Property="MyColor" Value="{StaticResource TestColor}" />

Or manually define the BindableProperty field so XSG can see it.

Version Information

  • .NET 10 Preview
  • CommunityToolkit.Maui with [BindableProperty] attribute

Related

Discord converstaion: https://discord.com/channels/1351511037215772672/1433378741832122458/1463986720981778432
Repro project: https://github.com/tranb3r/Issues/tree/main/MauiAppTestXamlSG


/cc @tranb3r (original reporter)

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't workingxsgXaml sourceGen

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions