Skip to content

Comments

[XSG] Fix Style Setters referencing source-generated bindable properties#33562

Merged
PureWeen merged 2 commits intoinflight/currentfrom
dev/simonrozsival/fix-null-bindable-property-fqdisplayname
Jan 19, 2026
Merged

[XSG] Fix Style Setters referencing source-generated bindable properties#33562
PureWeen merged 2 commits intoinflight/currentfrom
dev/simonrozsival/fix-null-bindable-property-fqdisplayname

Conversation

@simonrozsival
Copy link
Member

Description

Fixes an issue where using source-generated bindable properties (created via [BindableProperty] attribute) in Style Setters would cause the XAML source generator to fail with error MAUIG1001: The method or operation is not implemented.

Problem

When a Style Setter references a source-generated bindable property, GetBindableProperty() returns null because the property field symbol is not available the same way as for manually-defined bindable properties. The code then called bpRef.ToFQDisplayString() on a null reference, causing the failure.

Example XAML that failed:

<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>

Where MyProperty is defined as:

public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}

Solution

Added a fallback mechanism in SetterValueProvider that:

  1. When GetBindableProperty() returns null, parses the property name from the Setter's Property attribute
  2. Resolves the target type from the parent Style/Trigger element
  3. Uses HasBindablePropertyHeuristic to verify a bindable property exists
  4. Constructs the fully-qualified property reference directly (e.g., global::Namespace.MyLabel.MyPropertyProperty)

Testing

  • All 147 source generator unit tests pass
  • Verified with repro project that previously failed now builds successfully and generates correct code

Copilot AI review requested due to automatic review settings January 16, 2026 13:28
@simonrozsival simonrozsival changed the base branch from main to inflight/current January 16, 2026 13:33
@simonrozsival simonrozsival force-pushed the dev/simonrozsival/fix-null-bindable-property-fqdisplayname branch from 5fcca7d to 36c4dc1 Compare January 16, 2026 13:36

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.

… Setters

When the XAML source generator encounters a Style Setter that references
a source-generated bindable property (e.g., from [BindableProperty] attribute),
the GetBindableProperty method returns null because the property metadata
isn't available in the same way as for manually-defined bindable properties.

This change adds a fallback mechanism in GetBindablePropertyNameAndType that:
1. Parses the property name from the Setter's Property attribute
2. Uses HasBindablePropertyHeuristic to detect if a bindable property exists
3. Constructs the fully-qualified property name directly

This fixes issue where using source-generated bindable properties in
ResourceDictionary styles would fail with 'MAUIG1001: The method or
operation is not implemented' error.

Fixes #xxxxx
- Changed TryGetBindablePropertyNameAndType to return false instead of 'null' string when property cannot be resolved
- Added explicit handling for null bpType case in TryProvideValue to return false
- Extracted GetTargetTypeSymbol as shared public method in NodeSGExtensions to avoid code duplication
- Added test coverage for Style Setters with source-generated bindable properties
@PureWeen PureWeen force-pushed the dev/simonrozsival/fix-null-bindable-property-fqdisplayname branch from 8fff22f to c62aa40 Compare January 16, 2026 23:53
@simonrozsival
Copy link
Member Author

/azp run maui-pr-uitests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@PureWeen PureWeen merged commit 2b14711 into inflight/current Jan 19, 2026
141 of 155 checks passed
@PureWeen PureWeen deleted the dev/simonrozsival/fix-null-bindable-property-fqdisplayname branch January 19, 2026 17:32
github-actions bot pushed a commit that referenced this pull request Jan 20, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
github-actions bot pushed a commit that referenced this pull request Jan 21, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
github-actions bot pushed a commit that referenced this pull request Jan 23, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
PureWeen pushed a commit that referenced this pull request Jan 27, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
PureWeen pushed a commit that referenced this pull request Jan 29, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
PureWeen pushed a commit that referenced this pull request Feb 2, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
simonrozsival pushed a commit that referenced this pull request Feb 3, 2026
…dableProperty - Candidate Failure Feb 2nd (#33854)

### Root Cause of the issue



- The SourceGen XAML inflator was silently failing when a Setter
referenced a **non-BindableProperty**/ Property doesn't exist, while
XamlC and Runtime inflators correctly reported errors.
 
The Problem:
XamlC behavior (compile-time): Throws BuildException when encountering
<Setter Property="NonBindable" /> on a property that isn't a
BindableProperty
 
Runtime inflator behavior: Throws XamlParseException for the same
invalid XAML
 
SourceGen behavior (BEFORE fix):
 
SetterValueProvider.TryProvideValue() would detect the property can't be
resolved
Returns `false` without reporting any diagnostic

**Silently fails - no error message to the developer**
Test expected (`ShouldThrow(inflator: SourceGen`)
Assert.NotEmpty(result.Diagnostics) but got empty diagnostics ❌
Why It Failed Silently:
When TryGetBindablePropertyNameAndType() returns false (property not
found):


### Description of Change



- Detects failure: When TryGetBindablePropertyNameAndType returns false
(property doesn't exist or isn't a BindableProperty)
 
Reports diagnostic: Uses Descriptors.MemberResolution (MAUIX2002) - the
standard "cannot resolve member" error
 
Provides context:
 
Exact location in XAML file (line/column)
Property name that failed to resolve
Consistent behavior: Now all three inflators report errors for invalid
Setter properties:
 
✅ XamlC → BuildException
✅ Runtime → XamlParseException
✅ SourceGen → Diagnostic (MAUIX2002)


### Unit Test case failed

**ShouldThrow(inflator: SourceGen**

https://dev.azure.com/dnceng-public/public/_build/results?buildId=1272666&view=ms.vss-test-web.build-test-results-tab&runId=35509658&resultId=101501&paneView=debug

Test location:
https://github.com/dotnet/maui/blob/inflight/candidate/src/Controls/tests/Xaml.UnitTests/Validation/SetterOnNonBP.rt.xaml.cs#L22



### Issues Fixed



Fixes #33562 


### Screenshot



| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/8128a742-460a-48fa-82bb-d310b80f688c"/>
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/196f856b-9d45-4604-adc9-ae233ac09b1f">
|
github-actions bot pushed a commit that referenced this pull request Feb 4, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
github-actions bot pushed a commit that referenced this pull request Feb 8, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
github-actions bot pushed a commit that referenced this pull request Feb 8, 2026
…dableProperty - Candidate Failure Feb 2nd (#33854)

### Root Cause of the issue



- The SourceGen XAML inflator was silently failing when a Setter
referenced a **non-BindableProperty**/ Property doesn't exist, while
XamlC and Runtime inflators correctly reported errors.
 
The Problem:
XamlC behavior (compile-time): Throws BuildException when encountering
<Setter Property="NonBindable" /> on a property that isn't a
BindableProperty
 
Runtime inflator behavior: Throws XamlParseException for the same
invalid XAML
 
SourceGen behavior (BEFORE fix):
 
SetterValueProvider.TryProvideValue() would detect the property can't be
resolved
Returns `false` without reporting any diagnostic

**Silently fails - no error message to the developer**
Test expected (`ShouldThrow(inflator: SourceGen`)
Assert.NotEmpty(result.Diagnostics) but got empty diagnostics ❌
Why It Failed Silently:
When TryGetBindablePropertyNameAndType() returns false (property not
found):


### Description of Change



- Detects failure: When TryGetBindablePropertyNameAndType returns false
(property doesn't exist or isn't a BindableProperty)
 
Reports diagnostic: Uses Descriptors.MemberResolution (MAUIX2002) - the
standard "cannot resolve member" error
 
Provides context:
 
Exact location in XAML file (line/column)
Property name that failed to resolve
Consistent behavior: Now all three inflators report errors for invalid
Setter properties:
 
✅ XamlC → BuildException
✅ Runtime → XamlParseException
✅ SourceGen → Diagnostic (MAUIX2002)


### Unit Test case failed

**ShouldThrow(inflator: SourceGen**

https://dev.azure.com/dnceng-public/public/_build/results?buildId=1272666&view=ms.vss-test-web.build-test-results-tab&runId=35509658&resultId=101501&paneView=debug

Test location:
https://github.com/dotnet/maui/blob/inflight/candidate/src/Controls/tests/Xaml.UnitTests/Validation/SetterOnNonBP.rt.xaml.cs#L22



### Issues Fixed



Fixes #33562 


### Screenshot



| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/8128a742-460a-48fa-82bb-d310b80f688c"/>
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/196f856b-9d45-4604-adc9-ae233ac09b1f">
|
PureWeen pushed a commit that referenced this pull request Feb 9, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
PureWeen pushed a commit that referenced this pull request Feb 9, 2026
…dableProperty - Candidate Failure Feb 2nd (#33854)

### Root Cause of the issue



- The SourceGen XAML inflator was silently failing when a Setter
referenced a **non-BindableProperty**/ Property doesn't exist, while
XamlC and Runtime inflators correctly reported errors.
 
The Problem:
XamlC behavior (compile-time): Throws BuildException when encountering
<Setter Property="NonBindable" /> on a property that isn't a
BindableProperty
 
Runtime inflator behavior: Throws XamlParseException for the same
invalid XAML
 
SourceGen behavior (BEFORE fix):
 
SetterValueProvider.TryProvideValue() would detect the property can't be
resolved
Returns `false` without reporting any diagnostic

**Silently fails - no error message to the developer**
Test expected (`ShouldThrow(inflator: SourceGen`)
Assert.NotEmpty(result.Diagnostics) but got empty diagnostics ❌
Why It Failed Silently:
When TryGetBindablePropertyNameAndType() returns false (property not
found):


### Description of Change



- Detects failure: When TryGetBindablePropertyNameAndType returns false
(property doesn't exist or isn't a BindableProperty)
 
Reports diagnostic: Uses Descriptors.MemberResolution (MAUIX2002) - the
standard "cannot resolve member" error
 
Provides context:
 
Exact location in XAML file (line/column)
Property name that failed to resolve
Consistent behavior: Now all three inflators report errors for invalid
Setter properties:
 
✅ XamlC → BuildException
✅ Runtime → XamlParseException
✅ SourceGen → Diagnostic (MAUIX2002)


### Unit Test case failed

**ShouldThrow(inflator: SourceGen**

https://dev.azure.com/dnceng-public/public/_build/results?buildId=1272666&view=ms.vss-test-web.build-test-results-tab&runId=35509658&resultId=101501&paneView=debug

Test location:
https://github.com/dotnet/maui/blob/inflight/candidate/src/Controls/tests/Xaml.UnitTests/Validation/SetterOnNonBP.rt.xaml.cs#L22



### Issues Fixed



Fixes #33562 


### Screenshot



| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/8128a742-460a-48fa-82bb-d310b80f688c"/>
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/196f856b-9d45-4604-adc9-ae233ac09b1f">
|
github-actions bot pushed a commit that referenced this pull request Feb 9, 2026
…ies (#33562)

## Description

Fixes an issue where using source-generated bindable properties (created
via `[BindableProperty]` attribute) in Style Setters would cause the
XAML source generator to fail with error `MAUIG1001: The method or
operation is not implemented`.

## Problem

When a Style Setter references a source-generated bindable property,
`GetBindableProperty()` returns `null` because the property field symbol
is not available the same way as for manually-defined bindable
properties. The code then called `bpRef.ToFQDisplayString()` on a null
reference, causing the failure.

Example XAML that failed:
```xml
<Style x:Key="MyLabelStyle" TargetType="local:MyLabel">
    <Setter Property="MyProperty" Value="Bar" />
</Style>
```

Where `MyProperty` is defined as:
```csharp
public partial class MyLabel : Label
{
    [BindableProperty]
    public partial string MyProperty { get; set; }
}
```

## Solution

Added a fallback mechanism in `SetterValueProvider` that:
1. When `GetBindableProperty()` returns null, parses the property name
from the Setter's `Property` attribute
2. Resolves the target type from the parent Style/Trigger element
3. Uses `HasBindablePropertyHeuristic` to verify a bindable property
exists
4. Constructs the fully-qualified property reference directly (e.g.,
`global::Namespace.MyLabel.MyPropertyProperty`)

## Testing

- All 147 source generator unit tests pass
- Verified with repro project that previously failed now builds
successfully and generates correct code
github-actions bot pushed a commit that referenced this pull request Feb 9, 2026
…dableProperty - Candidate Failure Feb 2nd (#33854)

### Root Cause of the issue



- The SourceGen XAML inflator was silently failing when a Setter
referenced a **non-BindableProperty**/ Property doesn't exist, while
XamlC and Runtime inflators correctly reported errors.
 
The Problem:
XamlC behavior (compile-time): Throws BuildException when encountering
<Setter Property="NonBindable" /> on a property that isn't a
BindableProperty
 
Runtime inflator behavior: Throws XamlParseException for the same
invalid XAML
 
SourceGen behavior (BEFORE fix):
 
SetterValueProvider.TryProvideValue() would detect the property can't be
resolved
Returns `false` without reporting any diagnostic

**Silently fails - no error message to the developer**
Test expected (`ShouldThrow(inflator: SourceGen`)
Assert.NotEmpty(result.Diagnostics) but got empty diagnostics ❌
Why It Failed Silently:
When TryGetBindablePropertyNameAndType() returns false (property not
found):


### Description of Change



- Detects failure: When TryGetBindablePropertyNameAndType returns false
(property doesn't exist or isn't a BindableProperty)
 
Reports diagnostic: Uses Descriptors.MemberResolution (MAUIX2002) - the
standard "cannot resolve member" error
 
Provides context:
 
Exact location in XAML file (line/column)
Property name that failed to resolve
Consistent behavior: Now all three inflators report errors for invalid
Setter properties:
 
✅ XamlC → BuildException
✅ Runtime → XamlParseException
✅ SourceGen → Diagnostic (MAUIX2002)


### Unit Test case failed

**ShouldThrow(inflator: SourceGen**

https://dev.azure.com/dnceng-public/public/_build/results?buildId=1272666&view=ms.vss-test-web.build-test-results-tab&runId=35509658&resultId=101501&paneView=debug

Test location:
https://github.com/dotnet/maui/blob/inflight/candidate/src/Controls/tests/Xaml.UnitTests/Validation/SetterOnNonBP.rt.xaml.cs#L22



### Issues Fixed



Fixes #33562 


### Screenshot



| Before Issue Fix | After Issue Fix |
|----------|----------|
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/8128a742-460a-48fa-82bb-d310b80f688c"/>
| <img width="400" height="500"
src="https://github.com/user-attachments/assets/196f856b-9d45-4604-adc9-ae233ac09b1f">
|
PureWeen added a commit that referenced this pull request Feb 10, 2026
.NET MAUI inflight/candidate introduces significant improvements across
all platforms with focus on quality, performance, and developer
experience. This release includes 20 commits with various improvements,
bug fixes, and enhancements.


## Blazor
- Fix for BlazorWebView Back Navigation Issues on Android 13+ After
Predictive Back Gesture Changes by @SuthiYuvaraj in
#33213
  <details>
  <summary>🔧 Fixes</summary>

- [Back navigation different between .net 9 and .net 10 blazor
hybrid](#32767)
  </details>

## CollectionView
- [Android] Fix for CollectionView.EmptyView does not remeasure its
height when the parent layout changes dynamically, causing incorrect
sizing. by @BagavathiPerumal in
#33559
  <details>
  <summary>🔧 Fixes</summary>

- [`CollectionView.EmptyView` does not remeasure its height when the
parent layout changes dynamically, causing incorrect
sizing.](#33324)
  </details>

- [Android] Fixed CollectionView reordering last item by @vitalii-vov in
#17825
  <details>
  <summary>🔧 Fixes</summary>

- [Android app crashes when dragging into
CollectionView](#17823)
  </details>

## DateTimePicker
- [iOS] Fix VoiceOver focus not shifting to Picker/DatePicker/TimePicker
popups by @kubaflo in #33152
  <details>
  <summary>🔧 Fixes</summary>

- [Voiceover does not automatically shift focus to the "Category" popup
when it opens.: A11y_Developer balance version .NET
10_Project_ScreenReader](#30746)
  </details>

## Dialogalert
- [iOS 26] Fix DisplayPromptAsync maxLength not enforced due to new
multi-range delegate by @Shalini-Ashokan in
#33616
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS 26.1] DisplayPromptAsync ignores maxLength and does not respect
RTL FlowDirection](#33549)
  </details>

## Flyout
- [iOS] Shell: Account for SafeArea when positioning flyout footer by
@kubaflo in #32891
  <details>
  <summary>🔧 Fixes</summary>

- [[IOS] Footer not displaying in iOS when StackOrientation.Horizontal
is set on FlyoutFooter](#26395)
  </details>

## Fonts
- Hide obsolete FontSize values from IDE autocomplete by @noiseonwires
in #33694

## Gestures
- Android pan fixes by @BurningLights in
#21547
  <details>
  <summary>🔧 Fixes</summary>

- [Flickering occurs while updating the width of ContentView through
PanGestureRecognizer.](#20772)
  </details>

## Navigation
- Shell: Add duplicate route validation for sibling elements by
@SubhikshaSf4851 in #32296
  <details>
  <summary>🔧 Fixes</summary>

- [OnNavigatedTo is not called when navigating from a specific
page](#14000)
  </details>

## Picker
- Improved Unfocus support for Picker on Mac Catalyst by @kubaflo in
#33127
  <details>
  <summary>🔧 Fixes</summary>

- [When using voiceover unable to access expanded list of project combo
box: A11y_.NET maui_user can creat a tak_Screen
reader](#30897)
- [Task and Project controls are not accessible with keyboard:A11y_.NET
maui_User can create a new
task_Keyboard](#30891)
  </details>

## SafeArea
- [iOS] SafeArea: Return Empty for non-ISafeAreaView views (opt-in
model) by @praveenkumarkarunanithi in
#33526
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] SafeArea is not applied when a ContentPage uses a
ControlTemplate](#33458)
  </details>

## Shell
- [iOS] Fix ObjectDisposedException in TraitCollectionDidChange on
window disposal by @jeremy-visionaid in
#33353
  <details>
  <summary>🔧 Fixes</summary>

- [Intermittent crash on exit on MacCatalyst -
ObjectDisposedException](#33352)
  </details>

- [Issue-Resolver] Explicit fallback for BackButtonBehavior lookup by
@kubaflo in #33204
  <details>
  <summary>🔧 Fixes</summary>

- [Setting BackButtonBehavior to not visible or not enabled does not
work](#28570)
- [BackButtonBehavior not
bound](#33139)
  </details>

## Templates
- [Templates] Remove redundant SemanticProperties.Description attribute
by @kubaflo in #33621
  <details>
  <summary>🔧 Fixes</summary>

- [Task and Project controls are not accessible with keyboard:A11y_.NET
maui_User can create a new
task_Keyboard](#30891)
- [Unable to select "Tags" when Voiceover is turned on.: A11y_Developer
balance version .NET
10_Project_ScreenReader](#30749)
  </details>

## Theme
- [Windows] Fix runtime theme update for controls and TitleBar by
@Tamilarasan-Paranthaman in #31714
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows][MacOS?] Change title bar color when switching light/dark
theme at runtime](#12507)
- [OS system components ignore app
theme](#22058)
- [[Mac Catalyst][Windows] TitleBar not reacting on UserAppTheme
changes](#30518)
- [In dark theme "Back" and "hamburger" button icon color contrast with
background color is less than 3:1: A11y_.NET maui_User can get all the
insights of Dashboard_Non text
Contrast](#30807)
- [`Switch` is invisible on `PointOver` when theme has
changed](#31819)
  </details>

## Theming
- [XSG] Fix Style Setters referencing source-generated bindable
properties by @simonrozsival in
#33562

## Titlebar
- [Windows] Fix TitleBar.IsVisible = false the caption buttons become
unresponsive by @devanathan-vaithiyanathan in
#33256
  <details>
  <summary>🔧 Fixes</summary>

- [When TitleBar.IsVisible = false the caption buttons become
unresponsive on Windows](#33171)
  </details>

## WebView
- Fix WebView JavaScript string escaping for backslashes and quotes by
@StephaneDelcroix in #33726

## Xaml
- [XSG] Fix NaN value in XAML generating invalid code by
@StephaneDelcroix in #33533
  <details>
  <summary>🔧 Fixes</summary>

- [[XSG] NaN value in XAML generates invalid
code](#33532)
  </details>


<details>
<summary>📦 Other (1)</summary>

- Remove InternalsVisibleTo attributes for .NET MAUI Community Toolkit
by @jfversluis via @Copilot in #33442

</details>
**Full Changelog**:
main...inflight/candidate
simonrozsival added a commit that referenced this pull request Feb 11, 2026
…erated BindableProperty

Fixes #33835

When a Style Setter uses a markup extension (e.g., {StaticResource}) on a
property with [BindableProperty] attribute from CommunityToolkit.MAUI,
the XSG couldn't find the BindableProperty field because it's generated
by another source generator running in parallel.

The markup extension case wasn't handled by the existing fix (#33562)
because SetterValueProvider.CanProvideValue returns false for markup
extensions, causing the Setter to go through the standard processing
path via BindablePropertyConverter, which called GetBindableProperty()
and crashed on the null result.

Fix:
- Make GetBindableProperty(ValueNode) return IFieldSymbol? (nullable)
  instead of throwing when BP field is not found
- Add heuristic fallback in BindablePropertyConverter to detect
  [BindableProperty] attributes on properties, matching the approach
  already used in SetterValueProvider
- Add tests for the markup extension scenario
StephaneDelcroix pushed a commit that referenced this pull request Feb 11, 2026
…erated BindableProperty

Fixes #33835

When a Style Setter uses a markup extension (e.g., {StaticResource}) on a
property with [BindableProperty] attribute from CommunityToolkit.MAUI,
the XSG couldn't find the BindableProperty field because it's generated
by another source generator running in parallel.

The markup extension case wasn't handled by the existing fix (#33562)
because SetterValueProvider.CanProvideValue returns false for markup
extensions, causing the Setter to go through the standard processing
path via BindablePropertyConverter, which called GetBindableProperty()
and crashed on the null result.

Fix:
- Make GetBindableProperty(ValueNode) return IFieldSymbol? (nullable)
  instead of throwing when BP field is not found
- Add heuristic fallback in BindablePropertyConverter to detect
  [BindableProperty] attributes on properties, matching the approach
  already used in SetterValueProvider
- Add tests for the markup extension scenario
PureWeen pushed a commit that referenced this pull request Feb 11, 2026
…erated BindableProperty (#33836)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

## Description

Fixes #33835

This PR fixes a remaining gap in the XSG handling of source-generated
bindable properties (from CommunityToolkit.MAUI `[BindableProperty]`
attribute) — specifically when **markup extensions** like
`{StaticResource}` are used in Style Setters.

### Background

PR #33562 fixed Style Setters with **simple literal values** on
source-generated bindable properties. However, when the Setter value
uses a **markup extension** (e.g., `{StaticResource TestColor}`), a
different code path is taken:

1. `SetterValueProvider.CanProvideValue()` returns `false` for markup
extensions
2. The Setter goes through the standard processing path via
`BindablePropertyConverter`
3. `BindablePropertyConverter` calls `GetBindableProperty()` which
returns null (field not visible to XSG)
4. This causes `MAUIG1001: The method or operation is not implemented`

### Changes

- **`NodeSGExtensions.GetBindableProperty(ValueNode)`**: Changed return
type to `IFieldSymbol?` (nullable) — returns null instead of throwing
when the bindable property field is not found
- **`BindablePropertyConverter`**: Added heuristic fallback to detect
`[BindableProperty]` attributes and construct the BP reference, matching
the approach already used in `SetterValueProvider`
- **Tests**: Added SourceGen unit tests and XAML unit tests covering the
markup extension scenario

### Review Note

The Copilot reviewer comment about missing `TestColor` resource was
incorrect — the resource IS defined in both tests that reference it. The
3rd test uses a simple string value and correctly does not define it.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants