Skip to content

Fix Shadow does not honour Styles#35081

Merged
kubaflo merged 5 commits into
dotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-19560
Apr 28, 2026
Merged

Fix Shadow does not honour Styles#35081
kubaflo merged 5 commits into
dotnet:inflight/currentfrom
KarthikRajaKalaimani:fix-19560

Conversation

@KarthikRajaKalaimani
Copy link
Copy Markdown
Contributor

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 from this PR and let us know in a comment if this change resolves your issue. Thank you!

Issue Details:

If I use a Shadow, and update the appropriate Style in Styles.xaml, the shadow does not apply the properties set in the style.

Root Cause:

Shadow inherits directly from Element and had no constructor. MAUI's implicit style system works by calling
MergedStyle.RegisterImplicitStyles() during an element's construction — this registers a SetDynamicResource(prop, type.FullName) listener that watches for <Style TargetType="Shadow"> entries in any ResourceDictionary up the visual tree. Since Shadow never initialized a MergedStyle, that listener was never registered. As a result, any implicit style targeting Shadow was silently ignored — the resources existed and were correctly propagated by the parent VisualElement, but Shadow had no mechanism to receive and apply them.

Description of Change:

An internal readonly MergedStyle _mergedStyle field and a public Shadow() constructor that initializes it with new MergedStyle(GetType(), this). Once constructed, MergedStyle automatically registers the dynamic resource
listener for the Shadow type, and implicit styles start resolving correctly. This is the exact same pattern used by Span, which faces the identical problem as another non-visual Element subclass that needs style resolution.

**Tested the behavior in the following platforms: **

  • Android
  • Windows
  • iOS
  • Mac

Reference:

N/A

Issues Fixed:

Fixes #19560

Screenshots

Before After
image image

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 35081

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 35081"

@dotnet-policy-service dotnet-policy-service Bot added the community ✨ Community Contribution label Apr 22, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Hey there @@KarthikRajaKalaimani! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Apr 22, 2026
@Tamilarasan-Paranthaman Tamilarasan-Paranthaman added the area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing label Apr 22, 2026
@sheiksyedm sheiksyedm marked this pull request as ready for review April 22, 2026 10:46
Copilot AI review requested due to automatic review settings April 22, 2026 10:46
Copy link
Copy Markdown
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

Fixes implicit <Style TargetType="Shadow"> resolution by ensuring Shadow participates in MAUI’s implicit style system and can resolve resources up the visual tree.

Changes:

  • Add MergedStyle initialization to Shadow so implicit styles are registered/applied.
  • Wire Shadow.Parent to the owning VisualElement while attached (and clear it when detached) to enable resource/tree-based style resolution.
  • Add a XAML unit test covering implicit style application to Shadow across inflators.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
src/Controls/src/Core/Shadow.cs Initialize MergedStyle in a new Shadow() ctor so implicit styles can apply.
src/Controls/src/Core/VisualElement/VisualElement.cs Set/clear Shadow.Parent during attach/detach to enable style/resource lookup via parent chain.
src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml Adds a page-local implicit Style targeting Shadow.
src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs Verifies styled Shadow properties across XAML inflators.

Comment on lines +2256 to +2263

SetInheritedBindingContext(shadow, null);
_shadowProxy?.Unsubscribe();

if (shadow.Parent == this)
{
shadow.Parent = null;
}
if (shadow is not null)
{
shadow.Parent = this;
SetInheritedBindingContext(shadow, BindingContext);
Comment on lines +2238 to 2241
shadow.Parent = this;
SetInheritedBindingContext(shadow, BindingContext);
_shadowChanged ??= (sender, e) => OnPropertyChanged(nameof(Shadow));
_shadowProxy ??= new();
@MauiBot MauiBot added s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review) labels Apr 22, 2026
Copy link
Copy Markdown
Contributor

@kubaflo kubaflo left a comment

Choose a reason for hiding this comment

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

Could you please review the ai's summary?

@dotnet dotnet deleted a comment from MauiBot Apr 25, 2026
@MauiBot
Copy link
Copy Markdown
Collaborator

MauiBot commented Apr 26, 2026

🤖 AI Summary

👋 @KarthikRajaKalaimani — new AI review results are available. Please review the latest session below.

📊 Review Sessionb329974 · Code improved · 2026-04-28 13:32 UTC
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: eb0b82fe

Test Without Fix (expect FAIL) With Fix (expect PASS)
📄 Maui19560 Maui19560 ✅ FAIL — 228s ✅ PASS — 191s
🔴 Without fix — 📄 Maui19560: FAIL ✅ · 228s

(truncated to last 15,000 chars)

rove runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.38]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.20]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.21]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.44]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:05.44]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.44]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.44]       Stack Trace:
[xUnit.net 00:00:05.44]     StylesAreAppliedToShadow(inflator: SourceGen) [FAIL]
[xUnit.net 00:00:05.45]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:05.45]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:05.45]            at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[xUnit.net 00:00:05.46]     StylesAreAppliedToShadow(inflator: XamlC) [FAIL]
[xUnit.net 00:00:05.46]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:05.46]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.46]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.46]       Stack Trace:
[xUnit.net 00:00:05.46]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:05.46]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:05.46]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:05.57]     StylesAreAppliedToShadow(inflator: Runtime) [FAIL]
[xUnit.net 00:00:05.57]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:05.57]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.57]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:05.57]       Stack Trace:
[xUnit.net 00:00:05.57]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:05.57]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:05.57]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:05.58]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Failed StylesAreAppliedToShadow(inflator: SourceGen) [110 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
  Failed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  Failed StylesAreAppliedToShadow(inflator: Runtime) [112 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Test Run Failed.
Total tests: 3
     Failed: 3
 Total time: 6.4073 Seconds

🟢 With fix — 📄 Maui19560: PASS ✅ · 191s

(truncated to last 15,000 chars)

i24472.xaml(41,32): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui24500.xaml(6,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25309.xaml(21,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25871.xaml(14,24): XamlC warning XC0045: Binding: Property "UpdateProgress" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui25871ViewModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25935.xaml(8,13): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(7,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(14,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(15,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(7,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(12,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(18,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(23,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.40]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:04.86]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:04.87]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.19]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Passed StylesAreAppliedToShadow(inflator: SourceGen) [92 ms]
  Passed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Passed StylesAreAppliedToShadow(inflator: Runtime) [107 ms]

Test Run Successful.
Total tests: 3
     Passed: 3
 Total time: 6.2515 Seconds

📁 Fix files reverted (2 files)
  • src/Controls/src/Core/Shadow.cs
  • src/Controls/src/Core/VisualElement/VisualElement.cs

🧪 UI Tests — Category Detection

Detected UI test categories: Shadow


🔍 Pre-Flight — Context & Validation

Issue: #19560 - Shadow does not honour Styles
PR: #35081 - Fix Shadow does not honour Styles
Platforms Affected: Android, iOS, macOS, Windows
Files Changed: 2 implementation, 2 test

Key Findings

  • Shadow inherits from Element (not StyleableElement) and had no constructor, so MergedStyle was never instantiated. Without it, SetDynamicResource for the implicit style key was never registered, causing all implicit <Style TargetType="Shadow"> entries to be silently ignored.
  • The fix adds a Shadow() constructor that initializes MergedStyle, following the exact same pattern as Span.
  • VisualElement.NotifyShadowChanges was changed to use shadow.Parent = this which handles resource listener registration, initial resource push, and BindingContext propagation via Element.SetParent — replacing the previous manual wiring.
  • StopNotifyingShadowChanges uses shadow.Parent = null for cleanup, but retains an explicit SetInheritedBindingContext(shadow, null) before the parent null assignment (minor redundancy, not a bug).
  • Copilot inline review comments on the PR mentioned the redundant SetInheritedBindingContext and potential duplicate resource notifications — the duplicate listener issue has been resolved by the PR (manual AddResourcesChangedListener was removed).

Edge Cases

  • Shadow is assigned to multiple VisualElements (shared instance): shadow.Parent could be overwritten — guarded with if (shadow.Parent == this) check in teardown.
  • Runtime style update after XAML inflation: exercised by the new _mergedStyle + parent wiring, but not covered by the test.

Code Review Summary

Verdict: LGTM
Confidence: high
Errors: 0 | Warnings: 2 | Suggestions: 2

Key code review findings:

  • ⚠️ src/Controls/src/Core/VisualElement/VisualElement.cs StopNotifyingShadowChanges: SetInheritedBindingContext(shadow, null) fires before shadow.Parent = null, causing redundant double BindingContext-null notification (also fires from inside SetParent(null)). Cosmetic issue — not a bug.
  • ⚠️ src/Controls/src/Core/VisualElement/VisualElement.cs: NotifyBackgroundChanges still uses the old manual resource-listener approach, creating an inconsistency with the new shadow pattern. Not introduced by this PR; should be a follow-up.
  • 💡 Shadow has no Style property — explicit style assignment (<Shadow Style="...">) still won't work. Only implicit styles are fixed.
  • 💡 Test covers only XAML inflation path, not runtime resource dictionary mutation.

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #35081 Add MergedStyle to Shadow constructor + use shadow.Parent = this for resource wiring ✅ PASSED (Gate) Shadow.cs, VisualElement.cs Original PR

Impacted UI Test Categories

Shadow — PR modifies Shadow style resolution and parent wiring


🔬 Code Review — Deep Analysis

Code Review — PR #35081

Independent Assessment

What this changes: Two related changes:

  1. Shadow.cs — Adds a default constructor that initializes _mergedStyle = new MergedStyle(GetType(), this). This calls RegisterImplicitStyles() + Apply() inside MergedStyle's constructor, setting up dynamic resource bindings keyed on typeof(Shadow).FullName.
  2. VisualElement.cs — Replaces manual resource-listener wiring with shadow.Parent = this in NotifyShadowChanges, relying on Element.SetParent to handle AddResourcesChangedListener, initial OnParentResourcesChanged, and inherited BindingContext propagation in one shot. StopNotifyingShadowChanges mirrors this with shadow.Parent = null (guarded), but retains an explicit SetInheritedBindingContext(shadow, null) call before the guard.

Inferred motivation: Shadow inherits from Element (not StyleableElement) and had no constructor, so MergedStyle was never instantiated. Without it, SetDynamicResource for the implicit style key Microsoft.Maui.Controls.Shadow was never registered. Additionally, NotifyShadowChanges manually tracked resource listeners without also establishing a parent relationship, so the shadow couldn't walk the resource tree correctly.


Reconciliation with PR Narrative

Author claims: Shadow lacked a constructor to call MergedStyle.RegisterImplicitStyles(), breaking implicit style resolution. The fix adds that constructor and replaces manual resource listener management with shadow.Parent = this.

Agreement: Matches exactly. The root cause analysis is correct. Element.SetParent handles all three concerns in one place: RemoveResourcesChangedListener (prior parent), AddResourcesChangedListener (new parent), initial OnParentResourcesChanged(GetMergedResources()), and SetChildInheritedBindingContext. Using the parent relationship is cleaner and more correct than the previous manual wiring.


Findings

⚠️ Warning — Redundant SetInheritedBindingContext in StopNotifyingShadowChanges

File: src/Controls/src/Core/VisualElement/VisualElement.csStopNotifyingShadowChanges

SetInheritedBindingContext(shadow, null);   // [1] explicit null
_shadowProxy?.Unsubscribe();
if (shadow.Parent == this)
{
    shadow.Parent = null;                   // [2] SetParent(null) also calls SetInheritedBindingContext(shadow, null)
}

Element.SetParent(null) already calls SetInheritedBindingContext(this, null) via its else branch. So step [1] is redundant: it fires an extra PropertyChanged("BindingContext") on the shadow before _shadowProxy is unsubscribed (meaning the proxy is still active for that notification), then step [2] fires it again. Neither call is incorrect, but the double-notification is unnecessary churn.

Note: When shadow.Parent != this, shadow.Parent = null is skipped, but the explicit SetInheritedBindingContext(shadow, null) still runs. This preserves a pre-existing behavioral choice — not introduced by this PR.

⚠️ Warning — NotifyBackgroundChanges uses the old manual approach; inconsistency introduced

File: src/Controls/src/Core/VisualElement/VisualElement.csNotifyBackgroundChanges

The analogous Background methods still use the old pattern:

SetInheritedBindingContext(background, BindingContext);
// ...
((IElementDefinition)this).AddResourcesChangedListener(background.OnParentResourcesChanged);

Shadow now uses the cleaner Parent-based approach, while Background doesn't. This inconsistency isn't a bug, but maintainers looking at these two side-by-side won't understand why the patterns differ. Worth a follow-up comment.

💡 Suggestion — Shadow still has no explicit Style property

_mergedStyle is initialized in the new constructor (implicit style support works ✅), but Shadow doesn't expose a Style property or StyleClass. This means <Shadow Style="{StaticResource MyShadowStyle}"> still won't compile. The test only covers the <Style TargetType="Shadow"> resource dictionary path. If explicit style assignment on Shadow is in scope, Shadow should inherit from StyleableElement or add a StyleProperty.

💡 Suggestion — Test covers only XAML inflation, not runtime resource updates

Maui19560.xaml.cs tests that styles are applied during XAML inflation. It doesn't exercise the path where the resource dictionary is mutated after the page is attached, which exercises the AddResourcesChangedListener path.


Devil's Advocate

Against finding #1 (redundant SetInheritedBindingContext): The explicit call before the guard ensures the binding context is always cleared, even if shadow.Parent != this. This may be intentional defensive code. Still redundant when Parent == this, but acceptable.

Against LGTM: The outstanding (non-outdated) review comment at line 2240 (r3123396599) mentions duplicate resource notifications. However, re-reading the current diff, AddResourcesChangedListener has already been removed from NotifyShadowChanges, and the _shadowProxy.Subscribe that remains is for PropertyChanged event forwarding (a different mechanism). The comment appears to be substantively stale.

Challenging the approach: Could the fix have been simpler — e.g., make Shadow inherit from StyleableElement? That would also add Style and StyleClass properties. It's a broader change that would require public API surface additions. The targeted approach (just _mergedStyle + parent wiring) is lower-risk for a bug fix.


Blast Radius

Low. Changes are confined to Shadow constructor and NotifyShadowChanges/StopNotifyingShadowChanges internal methods. The shadow.Parent = this change affects any VisualElement with a Shadow set, but only during the attach/detach lifecycle. Existing tests pass (Gate ✅ PASSED).

Failure-Mode Probes

  • Shadow shared across multiple VisualElements: The if (shadow.Parent == this) guard in teardown prevents clearing a parent that was reassigned. ✅ Handled.
  • Shadow set before element added to tree: NotifyShadowChanges is called during Shadow property set (via ShadowPropertyChanged). If called before tree attachment, shadow.Parent = this sets the parent to an unattached element, which could limit resource resolution. This is the same behavior as before (resources weren't resolved anyway), so not a regression.
  • Null Shadow: Both NotifyShadowChanges and StopNotifyingShadowChanges guard with if (shadow is not null). ✅ Handled.

Verdict: LGTM

Confidence: High
Summary: The fix is correct and well-motivated. Using shadow.Parent = this in NotifyShadowChanges is a clean replacement for the previous manual resource-listener wiring. The _mergedStyle initialization in Shadow's constructor follows the established pattern of Span. The two ⚠️ warnings (redundant SetInheritedBindingContext in teardown; inconsistency with Background) are cosmetic issues that don't affect correctness and could be addressed in a follow-up.


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) MergedStyle-Only: Add MergedStyle to Shadow constructor, keep VisualElement.cs untouched ✅ PASS 1 file (Shadow.cs) More minimal than PR — VisualElement.cs changes not needed
2 try-fix (claude-sonnet-4.6) Override OnParentResourcesChanged in Shadow to intercept resource updates; no MergedStyle, no VisualElement.cs changes ✅ PASS 1 file (Shadow.cs) Different mechanism — manual style apply/unapply; more code, less standard
3 try-fix (gpt-5.3-codex) Change Shadow to inherit from StyleableElement instead of Element ✅ PASS 1 file (Shadow.cs, 1-line change) Simplest code change; adds public Style/StyleClass API surface (potential breaking concern)
4 try-fix (gpt-5.5) Explicit implicit-style lookup in NotifyShadowChanges — VisualElement resolves and applies Shadow's style directly ✅ PASS 1 file (VisualElement.cs, +42/-9) Shadow.cs unchanged; most complex approach
PR PR #35081 Add MergedStyle to Shadow constructor + use shadow.Parent = this for resource wiring ✅ PASSED (Gate) 2 files Original PR

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No All major approaches covered
claude-sonnet-4.6 2 No All major approaches covered
gpt-5.3-codex 2 No All major approaches covered
gpt-5.5 2 No All major approaches covered

Exhausted: Yes
Selected Fix: Attempt 1 (MergedStyle-Only) — same Shadow.cs change as the PR but without the VisualElement.cs changes. Simpler (1 file vs 2 files), and the existing manual resource listener approach already worked once MergedStyle was initialized. The PR's VisualElement.cs refactoring (shadow.Parent = this) is a correct improvement but not required to fix the bug; it introduces a minor redundant BindingContext null notification on teardown.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #19560, XAML unit tests, 2 impl + 2 test files
Code Review LGTM (high) 0 errors, 2 warnings, 2 suggestions
Gate ✅ PASSED XAML unit tests (Maui19560), all inflators
Try-Fix ✅ COMPLETE 4 attempts, 4 passing
Report ✅ COMPLETE

Code Review Impact on Try-Fix

Code review flagged two ⚠️ warnings about the VisualElement.cs changes: (1) redundant SetInheritedBindingContext(shadow, null) in StopNotifyingShadowChanges that fires before shadow.Parent = null (which fires it again internally), and (2) inconsistency with NotifyBackgroundChanges still using the old manual pattern. These warnings directly informed Attempt 1's hypothesis: if the VisualElement.cs changes are the source of code quality concerns, test whether the bug can be fixed with the Shadow.cs constructor change alone — and it can. Attempt 1 confirmed that the VisualElement.cs refactoring is not required to fix the bug.

Summary

The PR correctly identifies the root cause: Shadow never initialized a MergedStyle, so implicit style listeners were never registered. The Shadow.cs constructor change is correct and necessary. However, the accompanying VisualElement.cs refactoring (shadow.Parent = this) — while architecturally sound — is not required for the bug fix and introduces redundant BindingContext notifications on both attach and detach. Try-Fix found a simpler alternative (Attempt 1) that fixes the bug with only the Shadow.cs change, leaving VisualElement.cs untouched. If the authors want to keep the VisualElement.cs cleanup, they should also remove the now-redundant PropagateBindingContextToShadow() call in OnBindingContextChanged and the explicit SetInheritedBindingContext(shadow, null) in StopNotifyingShadowChanges.

Root Cause

Shadow inherits from Element and had no constructor, so MergedStyle was never instantiated. Without MergedStyle, SetDynamicResource(StyleProperty, typeof(Shadow).FullName) was never called, meaning no listener was registered for <Style TargetType="Shadow"> dictionary entries. The resources existed and were correctly propagated by the parent VisualElement, but Shadow had no mechanism to receive and apply them.

Fix Quality

The Shadow.cs constructor change is correct, minimal, and follows the pattern established by Span. The VisualElement.cs changes use shadow.Parent = this which is the proper MAUI pattern for establishing resource propagation, but they introduce two side effects: (1) StopNotifyingShadowChanges calls SetInheritedBindingContext(shadow, null) explicitly, then shadow.Parent = null calls it again internally — double notification; (2) PropagateBindingContextToShadow() (still called from OnBindingContextChanged) is now redundant because the parent-child BindingContext propagation handles it. The simpler fix (Attempt 1: Shadow.cs only) avoids both issues. If the PR authors keep the VisualElement.cs cleanup, they should address these redundancies to complete the refactoring correctly.



📊 Review Sessionda60dc0 · brace added · 2026-04-26 00:54 UTC
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: eb0b82fe

Test Without Fix (expect FAIL) With Fix (expect PASS)
📄 Maui19560 Maui19560 ✅ FAIL — 204s ✅ PASS — 193s
🔴 Without fix — 📄 Maui19560: FAIL ✅ · 204s

(truncated to last 15,000 chars)

prove runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.30]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.88]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.89]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:06.10]     StylesAreAppliedToShadow(inflator: SourceGen) [FAIL]
[xUnit.net 00:00:06.11]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.11]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.11]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.11]       Stack Trace:
[xUnit.net 00:00:06.11]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.11]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:06.11]            at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[xUnit.net 00:00:06.12]     StylesAreAppliedToShadow(inflator: XamlC) [FAIL]
[xUnit.net 00:00:06.12]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.12]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.12]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.12]       Stack Trace:
[xUnit.net 00:00:06.12]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.12]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:06.12]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:06.22]     StylesAreAppliedToShadow(inflator: Runtime) [FAIL]
[xUnit.net 00:00:06.22]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.22]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.22]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.22]       Stack Trace:
[xUnit.net 00:00:06.22]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.22]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:06.22]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:06.22]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Failed StylesAreAppliedToShadow(inflator: SourceGen) [103 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
  Failed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  Failed StylesAreAppliedToShadow(inflator: Runtime) [98 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Test Run Failed.
Total tests: 3
     Failed: 3
 Total time: 7.2601 Seconds

🟢 With fix — 📄 Maui19560: PASS ✅ · 193s

(truncated to last 15,000 chars)

24472.xaml(41,32): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui24500.xaml(6,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25309.xaml(21,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25871.xaml(14,24): XamlC warning XC0045: Binding: Property "UpdateProgress" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui25871ViewModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25935.xaml(8,13): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(7,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(14,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(15,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(7,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(12,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(18,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(23,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.36]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.70]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.71]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:06.10]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Passed StylesAreAppliedToShadow(inflator: SourceGen) [103 ms]
  Passed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Passed StylesAreAppliedToShadow(inflator: Runtime) [150 ms]

Test Run Successful.
Total tests: 3
     Passed: 3
 Total time: 7.0722 Seconds

📁 Fix files reverted (2 files)
  • src/Controls/src/Core/Shadow.cs
  • src/Controls/src/Core/VisualElement/VisualElement.cs

🧪 UI Tests — Category Detection

Detected UI test categories: Shadow


🔍 Pre-Flight — Context & Validation

Issue: #19560 - Shadow does not honour Styles
PR: #35081 - Fix Shadow does not honour Styles
Platforms Affected: Android, Windows, iOS, macOS
Files Changed: 2 implementation, 2 test

Key Findings

  • Shadow extends Element directly with no constructor, so MergedStyle was never initialized and RegisterImplicitStyles() was never called — implicit <Style TargetType="Shadow"> styles were silently ignored
  • PR adds Shadow() constructor with MergedStyle initialization (correct fix, matches Span pattern)
  • PR also adds shadow.Parent = this in NotifyShadowChanges — correct intent but introduces duplicate resource listener registration
  • Element.SetParent() already calls AddResourcesChangedListener(OnParentResourcesChanged) AND OnParentResourcesChanged(GetMergedResources()) AND SetChildInheritedBindingContext, making the existing explicit calls in NotifyShadowChanges redundant/duplicated
  • CI has 2 failures: Helix Unit Tests Windows Debug (possibly related — test may be missing ApplicationFixture), RunOniOS_MauiRelease ARM64 (likely infra flake, unrelated)
  • Previous agent review (Copilot inline comments) flagged the duplicate listener issue at VisualElement.cs:2241 and redundant SetInheritedBindingContext at line 2239

Code Review Summary

Verdict: NEEDS_CHANGES
Confidence: high
Errors: 0 | Warnings: 3 | Suggestions: 1

Key code review findings:

  • ⚠️ VisualElement.cs:2238,2245shadow.Parent = this already registers shadow.OnParentResourcesChanged via SetParent; line 2245's explicit AddResourcesChangedListener is a duplicate registration
  • ⚠️ VisualElement.cs:2239SetInheritedBindingContext(shadow, BindingContext) is redundant; SetParent handles it via SetChildInheritedBindingContext
  • ⚠️ VisualElement.cs:2244OnParentResourcesChanged(this.GetMergedResources()) is redundant; SetParent already calls this internally
  • 💡 Maui19560.xaml.cs — Test class missing IClassFixture<ApplicationFixture> used by other style tests in the project

Fix Candidates

# Source Approach Test Result Files Changed Notes
PR PR #35081 Shadow() constructor + MergedStyle init + shadow.Parent = this ✅ PASSED (Gate) Shadow.cs, VisualElement.cs Original PR — has duplicate listener registration side effect

🔬 Code Review — Deep Analysis

Code Review — PR #35081

Independent Assessment

What this changes: Shadow gains a constructor that creates a MergedStyle, hooking it into the implicit style system. VisualElement.NotifyShadowChanges() now sets shadow.Parent = this to establish the element tree relationship, and StopNotifyingShadowChanges() clears it on teardown.

Inferred motivation: Shadow extends Element directly and had no constructor. Without a MergedStyle, the dynamic-resource listeners that back <Style TargetType="Shadow"> were never registered, so implicit styles silently had no effect.


Reconciliation with PR Narrative

Author claims: Root cause is correct — no MergedStyle constructor, so RegisterImplicitStyles() was never called. Compares to Span as the same pattern.

Agreement/disagreement: The MergedStyle initialization diagnosis is accurate. However, Span does NOT set Parent; the PR's shadow.Parent = this addition goes beyond the Span pattern and introduces a side effect (see findings below) that isn't acknowledged. The PR description describes two changes but the interaction between them is not analyzed.


Findings

⚠️ Warning — Double listener registration in NotifyShadowChanges

VisualElement.cs:2238 sets shadow.Parent = this. Internally, Element.SetParent() (line 426 of Element.cs) calls:

((IElementDefinition)RealParent).AddResourcesChangedListener(OnParentResourcesChanged);

This registers shadow.OnParentResourcesChanged on the VisualElement's _changeHandlers list (registration #1).

Then, NotifyShadowChanges line 2245 calls:

((IElementDefinition)this).AddResourcesChangedListener(shadow.OnParentResourcesChanged); // registration #2

_changeHandlers is a plain List<Action<...>> with no deduplication (Add is used, Remove only removes first occurrence). After NotifyShadowChanges, shadow.OnParentResourcesChanged is in the list twice. Every subsequent resource change fires the shadow twice per event.

The cleanup in StopNotifyingShadowChanges accidentally compensates (explicit RemoveResourcesChangedListener removes the first, and shadow.Parent = null removes the second via its internal RemoveResourcesChangedListener). There's no listener leak, but the double-fire during resource changes is wasteful and fragile — it will break if the cleanup order ever changes.

Fix: Remove the explicit AddResourcesChangedListener call from NotifyShadowChanges (since SetParent already registers it), and also remove the now-redundant OnParentResourcesChanged(this.GetMergedResources()) call (since SetParent already calls shadow.OnParentResourcesChanged(this.GetMergedResources()) directly).

⚠️ Warning — CI failing on "Helix Unit Tests Windows Debug"

Maui19560.xaml.cs does not set up a MockApplication. Neighboring style-related tests that use resource dictionaries (e.g., StyleTests.xaml.cs) use IClassFixture<ApplicationFixture>, which ensures Application.Current is non-null. Without it, style resolution paths that call Application.Current?.FindMauiContext() or fall back to Application.Current.Resources may behave differently — particularly in Debug builds where null guards differ.

This may be causing the Windows Helix Debug test failure. The fix is to add IClassFixture<ApplicationFixture> to the Tests class:

[Collection("Xaml Inflation")]
public class Tests : IClassFixture<ApplicationFixture>
{
    public Tests(ApplicationFixture fixture) { }
    ...
}

⚠️ Warning — Redundant SetInheritedBindingContext

shadow.Parent = this triggers SetChildInheritedBindingContext(shadow, BindingContext) inside SetParent (Element.cs:432). The explicit SetInheritedBindingContext(shadow, BindingContext) call on VisualElement.cs:2239 immediately after is redundant. It's idempotent but noisy.

💡 Suggestion — Shadow lacks explicit Style property

Unlike Span (the comparison class), Shadow has no StyleProperty backed by _mergedStyle.Style = (Style)newvalue. This means <Shadow Style="{StaticResource myShadow}" /> won't work — only implicit TargetType="Shadow" styles do. This is a partial fix. If explicit styles are out of scope, a code comment noting the limitation would help future contributors.


Devil's Advocate

  • Is the double registration benign? In practice yes — SetValue with the same value is idempotent, and style application is cheap. But the "correct by coincidence" symmetry in teardown is a maintenance trap. It should be explicit.
  • Is shadow.Parent = this necessary? The existing AddResourcesChangedListener + OnParentResourcesChanged pattern already propagated styles to shadow before this PR. Setting Parent additionally enables TryGetResource to walk up the tree from shadow directly, which is the "proper" MAUI idiom and handles future dynamic resource lookups on shadow. It's a good addition — the redundant explicit calls are what should be removed, not Parent setting.
  • iOS CI failure: RunOniOS_MauiRelease ARM64 is an integration test that is unrelated to Shadow — likely infrastructure flake, not caused by this PR.

Verdict: NEEDS_CHANGES

Confidence: high

Summary: The core fix (MergedStyle initialization in Shadow()) is correct and well-motivated. However, adding shadow.Parent = this while keeping the pre-existing explicit AddResourcesChangedListener creates a double listener registration that is coincidentally cleaned up but semantically incorrect. The failing Helix Debug CI check also needs investigation — the test likely needs IClassFixture<ApplicationFixture> to match the setup used by other style-resolution tests in the same project.


🔧 Fix — Analysis & Comparison

Fix Candidates

# Source Approach Test Result Files Changed Notes
1 try-fix (claude-opus-4.6) Shadow() + MergedStyle; VisualElement: shadow.Parent = this + remove redundant explicit calls (SetInheritedBindingContext, OnParentResourcesChanged, AddResourcesChangedListener); teardown via shadow.Parent = null ✅ PASS (3/3) Shadow.cs, VisualElement.cs Cleanest — delegates setup/teardown to SetParent, no duplicate listeners
2 try-fix (claude-sonnet-4.6) Shadow() + MergedStyle; VisualElement: fix OnParentResourcesChanged(this...)shadow.OnParentResourcesChanged(...) (1-word change only, no Parent assignment) ✅ PASS (3/3) Shadow.cs, VisualElement.cs Most minimal — fixes misdirected initial resource push without Parent relationship
3 try-fix (gpt-5.3-codex) Shadow : StyleableElement (drops explicit _mergedStyle); VisualElement: reorder AddResourcesChangedListener before initial push ✅ PASS Shadow.cs, VisualElement.cs Base-class approach — style infra from StyleableElement, but changes inheritance chain
4 try-fix (gpt-5.4) Shadow() + MergedStyle; VisualElement: shadow.ParentOverride = this + fix shadow.OnParentResourcesChanged(...) + shadow.ParentOverride = null in teardown ✅ PASS Shadow.cs, VisualElement.cs ParentOverride keeps shadow out of logical tree while giving ancestry
PR PR #35081 Shadow() + MergedStyle + shadow.Parent = this (keeps existing explicit calls) ✅ PASSED (Gate) Shadow.cs, VisualElement.cs Has duplicate listener registration (semantic issue, no test failure)

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No All meaningful approaches covered
claude-sonnet-4.6 2 No All meaningful approaches covered
gpt-5.3-codex 2 No Only untried: lazy init in OnParentSet — too similar to constructor init
gpt-5.4 2 Yes AddLogicalChild/RemoveLogicalChild — higher-risk, affects visual tree traversal

Exhausted: Yes
Selected Fix: Candidate #1 (claude-opus-4.6) — shadow.Parent = this + remove redundant explicit calls. Correct MAUI idiom for establishing parent relationship, eliminates duplicate listener registration, clean teardown. PR should be updated to remove the explicit SetInheritedBindingContext, OnParentResourcesChanged, and AddResourcesChangedListener calls that are already handled by SetParent internally. Minimal alternative is Candidate #2 if parent relationship is not desired.


📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #19560, Shadow implicit styles, 2 impl + 2 test files
Code Review NEEDS_CHANGES (high) 0 errors, 3 warnings
Gate ✅ PASSED android
Try-Fix ✅ COMPLETE 4 attempts, 4 passing
Report ✅ COMPLETE

Code Review Impact on Try-Fix

Code review identified that shadow.Parent = this in the PR causes duplicate registration of shadow.OnParentResourcesChanged — once via Element.SetParent() and again via the pre-existing explicit AddResourcesChangedListener call. This guided Try-Fix models:

  • Attempt 1 (✅) directly addressed the duplicate by replacing all redundant explicit calls with just shadow.Parent = this
  • Attempt 2 (✅) found an orthogonal root cause: OnParentResourcesChanged(this.GetMergedResources()) was calling the VisualElement's own method, not shadow's — a misdirected initial push. Fixed with a 1-word change.
  • Attempts 3 & 4 explored architectural alternatives (StyleableElement base class, ParentOverride).

All 4 alternatives pass tests. The code review warnings directly led to Attempt 1, which is the cleanest version of the PR's own approach.

Summary

The PR correctly identifies and fixes the root cause (missing MergedStyle initialization in Shadow). The Shadow() constructor adding MergedStyle is the right fix and matches the Span pattern. However, the PR also adds shadow.Parent = this in VisualElement.NotifyShadowChanges() while keeping the pre-existing explicit SetInheritedBindingContext, OnParentResourcesChanged, and AddResourcesChangedListener calls — all three of which are already handled internally by Element.SetParent(). This creates redundant double listener registration on every shadow hookup. The issue is semantically incorrect (fragile cleanup that coincidentally cancels out) even though tests currently pass.

Better alternative found (Candidate #1): Keep shadow.Parent = this, remove the three redundant explicit calls. Results in cleaner code, correct semantics, same test results.

Root Cause

Shadow inherits directly from Element without a constructor, so MergedStyle was never created and RegisterImplicitStyles() was never called. Without the dynamic resource listeners that MergedStyle registers, implicit <Style TargetType="Shadow"> entries in ResourceDictionary were silently ignored. The MergedStyle(GetType(), this) constructor call registers SetDynamicResource listeners for the Shadow type (and its base types up to Element), enabling the style system to resolve and apply them.

Fix Quality

The core of the fix (Shadow() constructor + MergedStyle) is correct. The VisualElement.cs change (shadow.Parent = this) establishes the proper MAUI parent relationship — good for future resource lookup from shadow. However, the PR leaves the three pre-existing explicit calls in place that SetParent now makes redundant:

  1. SetInheritedBindingContext(shadow, BindingContext) — redundant (SetParent calls SetChildInheritedBindingContext)
  2. OnParentResourcesChanged(this.GetMergedResources()) — redundant and misdirected (SetParent already pushes resources to shadow; calling this.OnParentResourcesChanged routes to the wrong target)
  3. ((IElementDefinition)this).AddResourcesChangedListener(shadow.OnParentResourcesChanged) — duplicate registration (SetParent already registers this listener)

Recommended change to PR: In NotifyShadowChanges, remove lines 2239, 2244, and 2245 (the three redundant explicit calls). In StopNotifyingShadowChanges, remove the explicit RemoveResourcesChangedListener call on line 2255 (already handled by shadow.Parent = null). This brings the implementation to Candidate #1.


@MauiBot MauiBot added the s/agent-fix-win AI found a better alternative fix than the PR label Apr 26, 2026
@KarthikRajaKalaimani
Copy link
Copy Markdown
Contributor Author

🤖 AI Summary

👋 @KarthikRajaKalaimani — new AI review results are available. Please review the latest session below.

📊 Review Sessionda60dc0 · brace added · 2026-04-26 00:54 UTC
🚦 Gate — Test Before & After Fix

Gate Result: ✅ PASSED

Platform: ANDROID · Base: main · Merge base: eb0b82fe

Test Without Fix (expect FAIL) With Fix (expect PASS)
📄 Maui19560 Maui19560 ✅ FAIL — 204s ✅ PASS — 193s
🔴 Without fix — 📄 Maui19560: FAIL ✅ · 204s
(truncated to last 15,000 chars)

prove runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.30]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.88]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.89]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:06.10]     StylesAreAppliedToShadow(inflator: SourceGen) [FAIL]
[xUnit.net 00:00:06.11]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.11]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.11]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.11]       Stack Trace:
[xUnit.net 00:00:06.11]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.11]            at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[xUnit.net 00:00:06.11]            at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
[xUnit.net 00:00:06.12]     StylesAreAppliedToShadow(inflator: XamlC) [FAIL]
[xUnit.net 00:00:06.12]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.12]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.12]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.12]       Stack Trace:
[xUnit.net 00:00:06.12]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.12]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:06.12]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:06.22]     StylesAreAppliedToShadow(inflator: Runtime) [FAIL]
[xUnit.net 00:00:06.22]       Assert.Equal() Failure: Values differ
[xUnit.net 00:00:06.22]       Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.22]       Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
[xUnit.net 00:00:06.22]       Stack Trace:
[xUnit.net 00:00:06.22]         /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs(21,0): at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator)
[xUnit.net 00:00:06.22]            at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
[xUnit.net 00:00:06.22]            at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
[xUnit.net 00:00:06.22]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Failed StylesAreAppliedToShadow(inflator: SourceGen) [103 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
  Failed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  Failed StylesAreAppliedToShadow(inflator: Runtime) [98 ms]
  Error Message:
   Assert.Equal() Failure: Values differ
Expected: [Color: Red=1, Green=0, Blue=0, Alpha=1]
Actual:   [Color: Red=0, Green=0, Blue=0, Alpha=1]
  Stack Trace:
     at Microsoft.Maui.Controls.Xaml.UnitTests.Maui19560.Tests.StylesAreAppliedToShadow(XamlInflator inflator) in /_/src/Controls/tests/Xaml.UnitTests/Issues/Maui19560.xaml.cs:line 21
   at InvokeStub_Tests.StylesAreAppliedToShadow(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

Test Run Failed.
Total tests: 3
     Failed: 3
 Total time: 7.2601 Seconds

🟢 With fix — 📄 Maui19560: PASS ✅ · 193s
(truncated to last 15,000 chars)

24472.xaml(41,32): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui24500.xaml(6,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25309.xaml(21,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25871.xaml(14,24): XamlC warning XC0045: Binding: Property "UpdateProgress" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui25871ViewModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui25935.xaml(8,13): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(7,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(14,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31939.xaml(15,29): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(7,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(12,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(18,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(23,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(30,56): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(36,84): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui31995.xaml(44,28): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32056.xaml(9,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32837.xaml(13,18): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(14,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(18,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(22,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui32924.xaml(27,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33291.xaml(20,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33291Item". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33293.xaml(14,29): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui33293Product". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui33876.xaml(8,20): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui34490.xaml(12,25): XamlC warning XC0045: Binding: Property "BindingContext" not found on "Microsoft.Maui.Controls.Xaml.UnitTests.Maui34490ItemModel". [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui6367.xaml(10,50): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Maui8149.xaml(12,43): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/RefToXamlControl.xaml(7,33): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(20,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(52,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/SetValue.xaml(53,27): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,25): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteBP" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,42): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoleteProp" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/WarnOnObsolete.xaml(6,61): XamlC warning XC0618: Property, Property setter or BindableProperty "ObsoletePropSetter" is deprecated. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(16,4): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,26): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/XReference.xaml(21,77): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Issues/Gh2007.rtxc.xaml(3,9): XamlC warning XC0022: Binding could be compiled to improve runtime performance if x:DataType is specified. See https://learn.microsoft.com/dotnet/maui/fundamentals/data-binding/compiled-bindings for more information. [/home/vsts/work/1/s/src/Controls/tests/Xaml.UnitTests/Controls.Xaml.UnitTests.csproj]
  Controls.Xaml.UnitTests -> /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll
Test run for /home/vsts/work/1/s/artifacts/bin/Controls.Xaml.UnitTests/Debug/net10.0/Microsoft.Maui.Controls.Xaml.UnitTests.dll (.NETCoreApp,Version=v10.0)
VSTest version 18.0.1 (x64)

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.8.2+699d445a1a (64-bit .NET 10.0.0)
[xUnit.net 00:00:00.36]   Discovering: Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.70]   Discovered:  Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:05.71]   Starting:    Microsoft.Maui.Controls.Xaml.UnitTests
[xUnit.net 00:00:06.10]   Finished:    Microsoft.Maui.Controls.Xaml.UnitTests
  Passed StylesAreAppliedToShadow(inflator: SourceGen) [103 ms]
  Passed StylesAreAppliedToShadow(inflator: XamlC) [1 ms]
  Passed StylesAreAppliedToShadow(inflator: Runtime) [150 ms]

Test Run Successful.
Total tests: 3
     Passed: 3
 Total time: 7.0722 Seconds

📁 Fix files reverted (2 files)

  • src/Controls/src/Core/Shadow.cs
  • src/Controls/src/Core/VisualElement/VisualElement.cs

🧪 UI Tests — Category Detection
Detected UI test categories: Shadow

🔍 Pre-Flight — Context & Validation
Issue: #19560 - Shadow does not honour Styles PR: #35081 - Fix Shadow does not honour Styles Platforms Affected: Android, Windows, iOS, macOS Files Changed: 2 implementation, 2 test

Key Findings

  • Shadow extends Element directly with no constructor, so MergedStyle was never initialized and RegisterImplicitStyles() was never called — implicit <Style TargetType="Shadow"> styles were silently ignored
  • PR adds Shadow() constructor with MergedStyle initialization (correct fix, matches Span pattern)
  • PR also adds shadow.Parent = this in NotifyShadowChanges — correct intent but introduces duplicate resource listener registration
  • Element.SetParent() already calls AddResourcesChangedListener(OnParentResourcesChanged) AND OnParentResourcesChanged(GetMergedResources()) AND SetChildInheritedBindingContext, making the existing explicit calls in NotifyShadowChanges redundant/duplicated
  • CI has 2 failures: Helix Unit Tests Windows Debug (possibly related — test may be missing ApplicationFixture), RunOniOS_MauiRelease ARM64 (likely infra flake, unrelated)
  • Previous agent review (Copilot inline comments) flagged the duplicate listener issue at VisualElement.cs:2241 and redundant SetInheritedBindingContext at line 2239

Code Review Summary

Verdict: NEEDS_CHANGES Confidence: high Errors: 0 | Warnings: 3 | Suggestions: 1

Key code review findings:

  • ⚠️ VisualElement.cs:2238,2245shadow.Parent = this already registers shadow.OnParentResourcesChanged via SetParent; line 2245's explicit AddResourcesChangedListener is a duplicate registration
  • ⚠️ VisualElement.cs:2239SetInheritedBindingContext(shadow, BindingContext) is redundant; SetParent handles it via SetChildInheritedBindingContext
  • ⚠️ VisualElement.cs:2244OnParentResourcesChanged(this.GetMergedResources()) is redundant; SetParent already calls this internally
  • 💡 Maui19560.xaml.cs — Test class missing IClassFixture<ApplicationFixture> used by other style tests in the project

Fix Candidates

Source Approach Test Result Files Changed Notes

PR PR #35081 Shadow() constructor + MergedStyle init + shadow.Parent = this ✅ PASSED (Gate) Shadow.cs, VisualElement.cs Original PR — has duplicate listener registration side effect
🔬 Code Review — Deep Analysis

Code Review — PR #35081

Independent Assessment

What this changes: Shadow gains a constructor that creates a MergedStyle, hooking it into the implicit style system. VisualElement.NotifyShadowChanges() now sets shadow.Parent = this to establish the element tree relationship, and StopNotifyingShadowChanges() clears it on teardown.

Inferred motivation: Shadow extends Element directly and had no constructor. Without a MergedStyle, the dynamic-resource listeners that back <Style TargetType="Shadow"> were never registered, so implicit styles silently had no effect.

Reconciliation with PR Narrative

Author claims: Root cause is correct — no MergedStyle constructor, so RegisterImplicitStyles() was never called. Compares to Span as the same pattern.

Agreement/disagreement: The MergedStyle initialization diagnosis is accurate. However, Span does NOT set Parent; the PR's shadow.Parent = this addition goes beyond the Span pattern and introduces a side effect (see findings below) that isn't acknowledged. The PR description describes two changes but the interaction between them is not analyzed.

Findings

⚠️ Warning — Double listener registration in NotifyShadowChanges

VisualElement.cs:2238 sets shadow.Parent = this. Internally, Element.SetParent() (line 426 of Element.cs) calls:

((IElementDefinition)RealParent).AddResourcesChangedListener(OnParentResourcesChanged);

This registers shadow.OnParentResourcesChanged on the VisualElement's _changeHandlers list (registration #1).

Then, NotifyShadowChanges line 2245 calls:

((IElementDefinition)this).AddResourcesChangedListener(shadow.OnParentResourcesChanged); // registration #2

_changeHandlers is a plain List<Action<...>> with no deduplication (Add is used, Remove only removes first occurrence). After NotifyShadowChanges, shadow.OnParentResourcesChanged is in the list twice. Every subsequent resource change fires the shadow twice per event.

The cleanup in StopNotifyingShadowChanges accidentally compensates (explicit RemoveResourcesChangedListener removes the first, and shadow.Parent = null removes the second via its internal RemoveResourcesChangedListener). There's no listener leak, but the double-fire during resource changes is wasteful and fragile — it will break if the cleanup order ever changes.

Fix: Remove the explicit AddResourcesChangedListener call from NotifyShadowChanges (since SetParent already registers it), and also remove the now-redundant OnParentResourcesChanged(this.GetMergedResources()) call (since SetParent already calls shadow.OnParentResourcesChanged(this.GetMergedResources()) directly).

⚠️ Warning — CI failing on "Helix Unit Tests Windows Debug"

Maui19560.xaml.cs does not set up a MockApplication. Neighboring style-related tests that use resource dictionaries (e.g., StyleTests.xaml.cs) use IClassFixture<ApplicationFixture>, which ensures Application.Current is non-null. Without it, style resolution paths that call Application.Current?.FindMauiContext() or fall back to Application.Current.Resources may behave differently — particularly in Debug builds where null guards differ.

This may be causing the Windows Helix Debug test failure. The fix is to add IClassFixture<ApplicationFixture> to the Tests class:

[Collection("Xaml Inflation")]
public class Tests : IClassFixture<ApplicationFixture>
{
    public Tests(ApplicationFixture fixture) { }
    ...
}

⚠️ Warning — Redundant SetInheritedBindingContext

shadow.Parent = this triggers SetChildInheritedBindingContext(shadow, BindingContext) inside SetParent (Element.cs:432). The explicit SetInheritedBindingContext(shadow, BindingContext) call on VisualElement.cs:2239 immediately after is redundant. It's idempotent but noisy.

💡 Suggestion — Shadow lacks explicit Style property

Unlike Span (the comparison class), Shadow has no StyleProperty backed by _mergedStyle.Style = (Style)newvalue. This means <Shadow Style="{StaticResource myShadow}" /> won't work — only implicit TargetType="Shadow" styles do. This is a partial fix. If explicit styles are out of scope, a code comment noting the limitation would help future contributors.

Devil's Advocate

  • Is the double registration benign? In practice yes — SetValue with the same value is idempotent, and style application is cheap. But the "correct by coincidence" symmetry in teardown is a maintenance trap. It should be explicit.
  • Is shadow.Parent = this necessary? The existing AddResourcesChangedListener + OnParentResourcesChanged pattern already propagated styles to shadow before this PR. Setting Parent additionally enables TryGetResource to walk up the tree from shadow directly, which is the "proper" MAUI idiom and handles future dynamic resource lookups on shadow. It's a good addition — the redundant explicit calls are what should be removed, not Parent setting.
  • iOS CI failure: RunOniOS_MauiRelease ARM64 is an integration test that is unrelated to Shadow — likely infrastructure flake, not caused by this PR.

Verdict: NEEDS_CHANGES

Confidence: high

Summary: The core fix (MergedStyle initialization in Shadow()) is correct and well-motivated. However, adding shadow.Parent = this while keeping the pre-existing explicit AddResourcesChangedListener creates a double listener registration that is coincidentally cleaned up but semantically incorrect. The failing Helix Debug CI check also needs investigation — the test likely needs IClassFixture<ApplicationFixture> to match the setup used by other style-resolution tests in the same project.

🔧 Fix — Analysis & Comparison

Fix Candidates

Source Approach Test Result Files Changed Notes

1 try-fix (claude-opus-4.6) Shadow() + MergedStyle; VisualElement: shadow.Parent = this + remove redundant explicit calls (SetInheritedBindingContext, OnParentResourcesChanged, AddResourcesChangedListener); teardown via shadow.Parent = null ✅ PASS (3/3) Shadow.cs, VisualElement.cs Cleanest — delegates setup/teardown to SetParent, no duplicate listeners
2 try-fix (claude-sonnet-4.6) Shadow() + MergedStyle; VisualElement: fix OnParentResourcesChanged(this...)shadow.OnParentResourcesChanged(...) (1-word change only, no Parent assignment) ✅ PASS (3/3) Shadow.cs, VisualElement.cs Most minimal — fixes misdirected initial resource push without Parent relationship
3 try-fix (gpt-5.3-codex) Shadow : StyleableElement (drops explicit _mergedStyle); VisualElement: reorder AddResourcesChangedListener before initial push ✅ PASS Shadow.cs, VisualElement.cs Base-class approach — style infra from StyleableElement, but changes inheritance chain
4 try-fix (gpt-5.4) Shadow() + MergedStyle; VisualElement: shadow.ParentOverride = this + fix shadow.OnParentResourcesChanged(...) + shadow.ParentOverride = null in teardown ✅ PASS Shadow.cs, VisualElement.cs ParentOverride keeps shadow out of logical tree while giving ancestry
PR PR #35081 Shadow() + MergedStyle + shadow.Parent = this (keeps existing explicit calls) ✅ PASSED (Gate) Shadow.cs, VisualElement.cs Has duplicate listener registration (semantic issue, no test failure)

Cross-Pollination

Model Round New Ideas? Details
claude-opus-4.6 2 No All meaningful approaches covered
claude-sonnet-4.6 2 No All meaningful approaches covered
gpt-5.3-codex 2 No Only untried: lazy init in OnParentSet — too similar to constructor init
gpt-5.4 2 Yes AddLogicalChild/RemoveLogicalChild — higher-risk, affects visual tree traversal
Exhausted: Yes Selected Fix: Candidate #1 (claude-opus-4.6) — shadow.Parent = this + remove redundant explicit calls. Correct MAUI idiom for establishing parent relationship, eliminates duplicate listener registration, clean teardown. PR should be updated to remove the explicit SetInheritedBindingContext, OnParentResourcesChanged, and AddResourcesChangedListener calls that are already handled by SetParent internally. Minimal alternative is Candidate #2 if parent relationship is not desired.

📋 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Phase Status

Phase Status Notes
Pre-Flight ✅ COMPLETE Issue #19560, Shadow implicit styles, 2 impl + 2 test files
Code Review NEEDS_CHANGES (high) 0 errors, 3 warnings
Gate ✅ PASSED android
Try-Fix ✅ COMPLETE 4 attempts, 4 passing
Report ✅ COMPLETE

Code Review Impact on Try-Fix

Code review identified that shadow.Parent = this in the PR causes duplicate registration of shadow.OnParentResourcesChanged — once via Element.SetParent() and again via the pre-existing explicit AddResourcesChangedListener call. This guided Try-Fix models:

  • Attempt 1 (✅) directly addressed the duplicate by replacing all redundant explicit calls with just shadow.Parent = this
  • Attempt 2 (✅) found an orthogonal root cause: OnParentResourcesChanged(this.GetMergedResources()) was calling the VisualElement's own method, not shadow's — a misdirected initial push. Fixed with a 1-word change.
  • Attempts 3 & 4 explored architectural alternatives (StyleableElement base class, ParentOverride).

All 4 alternatives pass tests. The code review warnings directly led to Attempt 1, which is the cleanest version of the PR's own approach.

Summary

The PR correctly identifies and fixes the root cause (missing MergedStyle initialization in Shadow). The Shadow() constructor adding MergedStyle is the right fix and matches the Span pattern. However, the PR also adds shadow.Parent = this in VisualElement.NotifyShadowChanges() while keeping the pre-existing explicit SetInheritedBindingContext, OnParentResourcesChanged, and AddResourcesChangedListener calls — all three of which are already handled internally by Element.SetParent(). This creates redundant double listener registration on every shadow hookup. The issue is semantically incorrect (fragile cleanup that coincidentally cancels out) even though tests currently pass.

Better alternative found (Candidate #1): Keep shadow.Parent = this, remove the three redundant explicit calls. Results in cleaner code, correct semantics, same test results.

Root Cause

Shadow inherits directly from Element without a constructor, so MergedStyle was never created and RegisterImplicitStyles() was never called. Without the dynamic resource listeners that MergedStyle registers, implicit <Style TargetType="Shadow"> entries in ResourceDictionary were silently ignored. The MergedStyle(GetType(), this) constructor call registers SetDynamicResource listeners for the Shadow type (and its base types up to Element), enabling the style system to resolve and apply them.

Fix Quality

The core of the fix (Shadow() constructor + MergedStyle) is correct. The VisualElement.cs change (shadow.Parent = this) establishes the proper MAUI parent relationship — good for future resource lookup from shadow. However, the PR leaves the three pre-existing explicit calls in place that SetParent now makes redundant:

  1. SetInheritedBindingContext(shadow, BindingContext) — redundant (SetParent calls SetChildInheritedBindingContext)
  2. OnParentResourcesChanged(this.GetMergedResources()) — redundant and misdirected (SetParent already pushes resources to shadow; calling this.OnParentResourcesChanged routes to the wrong target)
  3. ((IElementDefinition)this).AddResourcesChangedListener(shadow.OnParentResourcesChanged) — duplicate registration (SetParent already registers this listener)

Recommended change to PR: In NotifyShadowChanges, remove lines 2239, 2244, and 2245 (the three redundant explicit calls). In StopNotifyingShadowChanges, remove the explicit RemoveResourcesChangedListener call on line 2255 (already handled by shadow.Parent = null). This brings the implementation to Candidate #1.

addressed AI summary concerns.

@kubaflo kubaflo added the s/agent-fix-implemented PR author implemented the agent suggested fix label Apr 28, 2026
@kubaflo kubaflo changed the base branch from main to inflight/current April 28, 2026 18:44
@kubaflo kubaflo merged commit a6898f9 into dotnet:inflight/current Apr 28, 2026
31 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR7 milestone Apr 28, 2026
PureWeen pushed a commit that referenced this pull request Apr 29, 2026
<!-- 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!

### Issue Details:

If I use a Shadow, and update the appropriate Style in Styles.xaml, the
shadow does not apply the properties set in the style.
       
### Root Cause:

Shadow inherits directly from Element and had no constructor. MAUI's
implicit style system works by calling
MergedStyle.RegisterImplicitStyles() during an element's construction —
this registers a SetDynamicResource(prop, type.FullName) listener that
watches for <Style TargetType="Shadow"> entries in any
ResourceDictionary up the visual tree. Since Shadow never initialized a
MergedStyle, that listener was never registered. As a result, any
implicit style targeting Shadow was silently ignored — the resources
existed and were correctly propagated by the parent VisualElement, but
Shadow had no mechanism to receive and apply them.

### Description of Change:

An internal readonly MergedStyle _mergedStyle field and a public
Shadow() constructor that initializes it with new MergedStyle(GetType(),
this). Once constructed, MergedStyle automatically registers the dynamic
resource
listener for the Shadow type, and implicit styles start resolving
correctly. This is the exact same pattern used by Span, which faces the
identical problem as another non-visual Element subclass that needs
style resolution.

**Tested the behavior in the following platforms: **

- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #19560         

### Screenshots
| Before  | After  |
|---------|--------|
| <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/0b9bea52-3ac9-445a-8b76-f8189da3fa66"
/> | <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/edef89a1-a8ea-4e77-ac0d-6ecf6bee683c"
/> |
github-actions Bot pushed a commit that referenced this pull request May 6, 2026
<!-- 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!

### Issue Details:

If I use a Shadow, and update the appropriate Style in Styles.xaml, the
shadow does not apply the properties set in the style.
       
### Root Cause:

Shadow inherits directly from Element and had no constructor. MAUI's
implicit style system works by calling
MergedStyle.RegisterImplicitStyles() during an element's construction —
this registers a SetDynamicResource(prop, type.FullName) listener that
watches for <Style TargetType="Shadow"> entries in any
ResourceDictionary up the visual tree. Since Shadow never initialized a
MergedStyle, that listener was never registered. As a result, any
implicit style targeting Shadow was silently ignored — the resources
existed and were correctly propagated by the parent VisualElement, but
Shadow had no mechanism to receive and apply them.

### Description of Change:

An internal readonly MergedStyle _mergedStyle field and a public
Shadow() constructor that initializes it with new MergedStyle(GetType(),
this). Once constructed, MergedStyle automatically registers the dynamic
resource
listener for the Shadow type, and implicit styles start resolving
correctly. This is the exact same pattern used by Span, which faces the
identical problem as another non-visual Element subclass that needs
style resolution.

**Tested the behavior in the following platforms: **

- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #19560         

### Screenshots
| Before  | After  |
|---------|--------|
| <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/0b9bea52-3ac9-445a-8b76-f8189da3fa66"
/> | <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/edef89a1-a8ea-4e77-ac0d-6ecf6bee683c"
/> |
@kubaflo kubaflo added the s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) label May 20, 2026
github-actions Bot pushed a commit that referenced this pull request May 25, 2026
<!-- 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!

### Issue Details:

If I use a Shadow, and update the appropriate Style in Styles.xaml, the
shadow does not apply the properties set in the style.
       
### Root Cause:

Shadow inherits directly from Element and had no constructor. MAUI's
implicit style system works by calling
MergedStyle.RegisterImplicitStyles() during an element's construction —
this registers a SetDynamicResource(prop, type.FullName) listener that
watches for <Style TargetType="Shadow"> entries in any
ResourceDictionary up the visual tree. Since Shadow never initialized a
MergedStyle, that listener was never registered. As a result, any
implicit style targeting Shadow was silently ignored — the resources
existed and were correctly propagated by the parent VisualElement, but
Shadow had no mechanism to receive and apply them.

### Description of Change:

An internal readonly MergedStyle _mergedStyle field and a public
Shadow() constructor that initializes it with new MergedStyle(GetType(),
this). Once constructed, MergedStyle automatically registers the dynamic
resource
listener for the Shadow type, and implicit styles start resolving
correctly. This is the exact same pattern used by Span, which faces the
identical problem as another non-visual Element subclass that needs
style resolution.

**Tested the behavior in the following platforms: **

- [x] Android
- [x] Windows
- [x] iOS
- [x] Mac

### Reference:

N/A

### Issues Fixed:

Fixes  #19560         

### Screenshots
| Before  | After  |
|---------|--------|
| <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/0b9bea52-3ac9-445a-8b76-f8189da3fa66"
/> | <img width="300" height="600" alt="image"
src="https://github.com/user-attachments/assets/edef89a1-a8ea-4e77-ac0d-6ecf6bee683c"
/> |
@PureWeen PureWeen mentioned this pull request Jun 2, 2026
PureWeen added a commit that referenced this pull request Jun 2, 2026
## What's Coming

.NET MAUI inflight/candidate introduces significant improvements across
all platforms with focus on quality, performance, and developer
experience. This release includes 85 commits with various improvements,
bug fixes, and enhancements.


## Button
- [Android, iOS] Button: Fix VisualState properties not restored when
leaving custom state by @BagavathiPerumal in
#33346
  <details>
  <summary>🔧 Fixes</summary>

- [Button VisualStates do not
work](#19690)
  </details>

## CollectionView
- Fix CollectionView grid spacing updates for first row and column by
@KarthikRajaKalaimani in #34527
  <details>
  <summary>🔧 Fixes</summary>

- [[MAUI] I2_Vertical grid for horizontal Item Spacing and Vertical Item
Spacing - horizontally updating the spacing only applies to the second
column](#34257)
  </details>

- CarouselView: Fix cascading PositionChanged/CurrentItemChanged events
on collection update by @praveenkumarkarunanithi in
#31275
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows] CurrentItemChangedEventArgs and PositionChangedEventArgs
Not Working Properly in
CarouselView](#29529)
  </details>

- [Windows] Fixed ItemSpacing doesn't work in Carousel View by
@SubhikshaSf4851 in #30014
  <details>
  <summary>🔧 Fixes</summary>

- [ItemSpacing on CarouselView is not applied on
Windows.](#29772)
  </details>

- Fix CollectionView not scrolling to top on iOS status bar tap by
@jfversluis in #34687
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] UICollectionView ScrollToTop does not
work](#19866)
  </details>

- [iOS] Fixed CollectionView Scroll Jitter for TextType HTML Labels by
@SubhikshaSf4851 in #34383
  <details>
  <summary>🔧 Fixes</summary>

- [CollectionView scrolling is jittery when ItemTemplate contains Label
with TextType="Html" in .NET
10](#33065)
  </details>

- Fix CollectionView Header is not visible when ItemsSource is not set
and an EmptyView is set in iOS, Mac platform by @KarthikRajaKalaimani in
#34989
  <details>
  <summary>🔧 Fixes</summary>

- [CollectionView Header is not visible when ItemsSource is not set and
EmptyView is set in iOS, Mac
platform](#34897)
  </details>

- [Android] Fix CollectionView EmptyView not displayed correctly by
@KarthikRajaKalaimani in #34956
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] CollectionView - EmptyView not displayed
correctly](#34861)
  </details>

- [iOS] Fix CollectionView ScrollOffset not resetting when ItemsSource
changes by @SyedAbdulAzeemSF4852 in
#34488
  <details>
  <summary>🔧 Fixes</summary>

- [[IOS] CollectionView ScrollOffset does not reset when the ItemSource
is changed in iOS.](#26366)
- [Re-enable Issue7993 test on iOS/Catalyst - CollectionView scroll
position not reset when updating
ItemsSource](#33500)
  </details>

- [Revert] [iOS] Fixed CollectionView Scroll Jitter for TextType HTML
Labels by @SubhikshaSf4851 in #35341

## Core Lifecycle
- [Android] Fix NRE in ContainerView when Android Context is null during
lifecycle transition by @rmarinho in
#34901
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] NullReferenceException in NavigationRootManager.Connect
when mapping Window
content](#34900)
  </details>

## DateTimePicker
- [Android] Fix for TimePicker Dialog doesn't update the layout when
rotating the device with dialog open by @HarishwaranVijayakumar in
#31910
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] TimePicker Dialog doesn't update the layout when rotating
the device with dialog
open](#31658)
  </details>

- [Android, iOS] Fixed TimePicker FlowDirection Not Applied Across
Platforms by @Dhivya-SF4094 in #30369
  <details>
  <summary>🔧 Fixes</summary>

- [TimePicker FlowDirection Not Working on All
Platforms](#30192)
  </details>

- [Windows] Fixed TimePicker CharacterSpacing issue by @SubhikshaSf4851
in #30533
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows] TimePicker CharacterSpacing Property Not Working on
Windows](#30199)
  </details>

- [MacCatalyst] Fix DatePicker Opened/Closed events not being raised by
@SubhikshaSf4851 in #34970
  <details>
  <summary>🔧 Fixes</summary>

- [[MacCatalyst] DatePicker Opened and Closed events are not raised on
Mac platform](#34848)
  </details>

## Dialogalert
- [Android] Fix AlertDialog, ActionSheet, and Prompt render with
Material 2 styles when Material 3 is enabled by @HarishwaranVijayakumar
in #35121
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] AlertDialog, ActionSheet, and Prompt render with Material 2
styles when Material 3 is
enabled](#35119)
  </details>

## Docs
- docs: Add UITesting-Guide, ReleasePlanning, and ReleaseProcess to
docs/README.md index by @PureWeen in
#35195

- docs: Fix hardcoded path and add library overview in Essentials.AI
README by @PureWeen in #35194

- docs: Update branch reference from net10.0 to net11.0 in
DEVELOPMENT.md by @PureWeen in #35193

## Drawing
- Fix Path Rendering Issue Inside StackLayout When Margin Is Set by
@Shalini-Ashokan in #28071
  <details>
  <summary>🔧 Fixes</summary>

- [Path does not render if it has
Margin](#13801)
  </details>

- Fixed FlowDirection property not working on Drawable control and
GraphicsView by @Dhivya-SF4094 in
#34557
  <details>
  <summary>🔧 Fixes</summary>

- [[Android, Windows, iOS, macOS] FlowDirection property not working on
BoxView Control](#34402)
  </details>

- [iOS & Mac] Fix image tile misalignment in GraphicsView ImagePaint by
@SubhikshaSf4851 in #34935
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] Image resized with ResizeMode.Fit is not rendered correctly in
GraphicsView](#34755)
  </details>

- Fix Shadow does not honour Styles by @KarthikRajaKalaimani in
#35081
  <details>
  <summary>🔧 Fixes</summary>

- [Shadow does not honour
Styles](#19560)
  </details>

## Entry
- [iOS/macCatalyst] Fix Entry and Editor BackgroundColor reset when set
to null by @Shalini-Ashokan in #34741
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS, Maccatalyst] Entry & Editor BackgroundColor not reset to
Null](#34611)
  </details>

- [Windows] Fix password Entry crash when setting text on empty field by
@praveenkumarkarunanithi in #33891
  <details>
  <summary>🔧 Fixes</summary>

- [[WinUI] Password Obfuscation causes unhandled
crash](#33334)
  </details>

## Essentials
- [Essentials] Use mean sea level altitude on Android API 34+ by
@KitKeen in #35097
  <details>
  <summary>🔧 Fixes</summary>

- [Add support for MslAltitudeMeters in Essentials Geolocation on
Android](#27554)
  </details>

## Flyout
- Fixed Flyout Not Displayed on Android When FlyoutWidth Is Set Only for
Desktop via OnIdiom by @NanthiniMahalingam in
#29028
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] FlyoutWidth with OnIdiom shows no
flyout](#13243)
  </details>

- Revert "[Windows] Fix Flyout/Locked mode header collapse regression
causing UI test failures on candidate branch" by @kubaflo in
#35339

- Revert "Revert "[Windows] Fix Flyout/Locked mode header collapse
regression causing UI test failures on candidate branch"" by @kubaflo in
#35342

## Flyoutpage
- Fix [Android] Title of FlyOutPage is not updating anymore after
showing a NonFlyOutPage by @KarthikRajaKalaimani in
#34839
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Title of FlyOutPage is not updating anymore after showing a
NonFlyOutPage](#33615)
  </details>

## Label
- [iOS] Fix span Tap gesture on wrapped Label lines in iOS 26+ by
@SubhikshaSf4851 in #34640
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS]Span TapGestureRecognizer does not work on the second line of
the span, if the span is wrapped to the next
line](#34504)
  </details>

## Layout
- Fixed Stacklayout is not rendered when clip is applied and StackLayout
placed child to the Border control in iOS/ Mac platform by
@KarthikRajaKalaimani in #33330
  <details>
  <summary>🔧 Fixes</summary>

- [[Mac/iOS] StackLayout fails to render content while applying Clip,
and the layout is placed inside a Border with Background in .NET
MAUI](#33241)
  </details>

## Map
- Fix Changing Location on a Pin does nothing by @NirmalKumarYuvaraj in
#30201
  <details>
  <summary>🔧 Fixes</summary>

- [[Maps] [Regression from Xamarin.Forms.Maps] Changing Location on a
Pin does nothing](#12916)
  </details>

## Mediapicker
- [iOS] Fix HEIC images picked via PickPhotosAsync not displayed by
@HarishwaranVijayakumar in #34954
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] [Regression] HEIC images picked via PickPhotosAsync not
displayed](#34953)
  </details>

- [Android] Fix MediaPicker.PickPhotosAsync UnauthorizedAccessException
on API 28 and below by @HarishwaranVijayakumar in
#34981
  <details>
  <summary>🔧 Fixes</summary>

- [MediaPicker.PickPhotos fails to modify image, tries to load original
source, fails to load source on Android
9.0](#34889)
  </details>

## Pages
- [iOS] Fix ContentPage with ToolbarItem Clicked event leaks when
presented as modal page by @devanathan-vaithiyanathan in
#35009
  <details>
  <summary>🔧 Fixes</summary>

- [ContentPage with ToolbarItem Clicked event leaks when presented as
modal page](#34892)
  </details>

## Platform
- [Android] Fix OnBackButtonPressed not invoked for Shell by
@Dhivya-SF4094 in #35150
  <details>
  <summary>🔧 Fixes</summary>

- [On Screen Back Button Does Not Fire OnBackButtonPressed in
Android](#9095)
  </details>

## RadioButton
- Fix RadioButtonGroup not working with ContentView by @Dhivya-SF4094 in
#34781
  <details>
  <summary>🔧 Fixes</summary>

- [RadioButtonGroup not working with
ContentView](#34759)
  </details>

- [Windows] Fix for RadioButton BorderColor and BorderWidth not updated
at runtime by @SyedAbdulAzeemSF4852 in
#28335
  <details>
  <summary>🔧 Fixes</summary>

- [RadioButton Border color not working for focused visual
state](#15806)
  </details>

- [iOS] Fix RadioButton BackgroundColor bleeding outside CornerRadius by
@SyedAbdulAzeemSF4852 in #34844
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] RadioButton BackgroundColor bleeds outside
CornerRadius](#34842)
  </details>

## SafeArea
- [iOS] Fix stale bottom safe area after changing SafeAreaEdges with
keyboard open by @praveenkumarkarunanithi in
#35083
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] ContentPage bottom has white space after changing SafeAreaEdges
while keyboard is open](#34846)
  </details>

## ScrollView
- [Windows] Fix Preserve ScrollView offsets when Orientation changes to
Neither by @SubhikshaSf4851 in #34827
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows] ScrollView offsets do not preserve when Orientation changes
to Neither](#34671)
  </details>

## Searchbar
- [iOS] Fix SearchBar unexpected left margin in iPad windowed mode on 26
Version by @SubhikshaSf4851 in #34704
  <details>
  <summary>🔧 Fixes</summary>

- [in iPad windowed mode SearchBar adds left margin equivaltent to
SafeAreaInsets when placed inside
grid](#34551)
  </details>

## Shell
- [Windows] Fix for Shell.FlyoutBehavior="Flyout" forces the title
height space above the tab bar even if the page title is empty by
@BagavathiPerumal in #30382
  <details>
  <summary>🔧 Fixes</summary>

- [(Windows) Shell.FlyoutBehavior="Flyout" forces the title height space
above the tab bar even if the page title is
empty](#30254)
  </details>

- Fix Shell flyout items scrolling behind FlyoutHeader on iOS by @Qythyx
in #34936
  <details>
  <summary>🔧 Fixes</summary>

- [Shell flyout items scroll behind FlyoutHeader on
iOS](#34925)
  </details>

- [iOS, Mac] Fix Shell.CurrentState.Location stale in OnNavigated after
GoToAsync by @Vignesh-SF3580 in
#34880
  <details>
  <summary>🔧 Fixes</summary>

- [Shell.OnNavigated not called for route
navigation](#34662)
  </details>

- [iOS26]Fix
BackButtonBehavior_IsEnabled_False_BackButtonDoesNotNavigate UITest
fails by @devanathan-vaithiyanathan in
#34890
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS 26] BackButtonBehavior_IsEnabled_False_BackButtonDoesNotNavigate
test fails with
TimeoutException](#34771)
  </details>

- [iOS] Fix Shell page memory leak when using TitleView with x:Name by
@Shalini-Ashokan in #35082
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS] Title view memory
leak](#34975)
  </details>

- [Material 3] Fix Material 2 color flash in AppBar when switching tabs
for the first time by @Dhivya-SF4094 in
#35117
  <details>
  <summary>🔧 Fixes</summary>

- [Material 3: AppBar briefly displays Material 2 colors when switching
tabs for the first time](#35116)
  </details>

- [Android] Fix Shell/TabbedPage "More" BottomSheet uses hard-coded M2
colors when Material3 is enabled by @HarishwaranVijayakumar in
#35129
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Shell/TabbedPage "More" BottomSheet uses hard-coded M2
colors when Material3 is
enabled](#35127)
  </details>

- [Android] Shell: Fix top-tab unselected text visibility in Material 3
light theme by @SyedAbdulAzeemSF4852 in
#35128
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Shell top-tab unselected text appears too faint in Material
3 light theme](#35125)
  </details>

- Fix Shell.Items.Clear() memory leak by disconnecting child handlers on
removal (#34898) by @Shalini-Ashokan in
#35031
  <details>
  <summary>🔧 Fixes</summary>

- [Shell.Items.Clear() does not disconnect handlers
correctly](#34898)
  </details>

- [iOS&Mac] Fix Shell SearchHandler Query update on Initial load by
@SubhikshaSf4851 in #35008
  <details>
  <summary>🔧 Fixes</summary>

- [[iOS&Mac] Shell SearchHandler Query not shown in search bar on
initial load](#35005)
  </details>

## SwipeView
- [iOS,MacCatalyst] Fix for SwipeView.Open() throwing an
ArgumentException on the second programmatic call by @BagavathiPerumal
in #34982
  <details>
  <summary>🔧 Fixes</summary>

- [[net 11.0][iOS,MacCatalyst] SwipeView.Open() throws ArgumentException
on second programmatic
call](#34917)
  </details>

- [Android/iOS] Fix SwipeItem visibility change causing double command
execution in Execute mode by @praveenkumarkarunanithi in
#35087
  <details>
  <summary>🔧 Fixes</summary>

- [Changing visibility on an SwipeItem causes multiple items to be
executed](#7580)
  </details>

## Switch
- [iOS] Fix Switch ThumbColor reset on iOS 26+ theme changes. by
@Shalini-Ashokan in #33953
  <details>
  <summary>🔧 Fixes</summary>

- [Switch ThumbColor not Initialized Using VisualStateManager on iOS
Device](#33783)
- [I9-On macOS 26.2, the "Animate scroll" button is white by default on
iOS and Maccatalyst
platforms.](#33767)
  </details>

## TabbedPage
- [Windows] TabbedPage: Refresh layout when NavigationView size changes
by @BagavathiPerumal in #26217
  <details>
  <summary>🔧 Fixes</summary>

- [TabbedPage - ScrollView not allowing scrolling when it
should](#26103)
- [TabbedPage App on resize hides page bottom
content](#11402)
- [Grid overflows child ContentPage of parent TabbedPage on initial load
and when resizing on
Windows](#20028)
  </details>

- [Android] Material 3 Fixed BottomNavigationView overflowing in Tabbed
page by @NirmalKumarYuvaraj in #35064
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] Material3 - TabbedPage bottom tabs overflowing the
contents](#35063)
  </details>

- [Windows] Fix for Multiple Tabs Being Selected in WinUI TabbedPage by
@SyedAbdulAzeemSF4852 in #33312
  <details>
  <summary>🔧 Fixes</summary>

- [WinUI TabbedPage can have multiple tabs
selected](#31799)
  </details>

## Theming
- [iOS] Fix StaticResource Hot Reload crash on iOS by @StephaneDelcroix
in #35020
  <details>
  <summary>🔧 Fixes</summary>

- [The maui app quit and no errors in error list after editing
ResourceDictionary XAML file on iOS Simulator with MAUI SR6
10.0.60](#35018)
  </details>

## Toolbar
- [Windows] Fix for CS1061 build error caused by missing
HasMenuBarContent property in MauiToolbar by @BagavathiPerumal in
#35040

## Tooling
- Fix VisualStateGroups duplicate name crash with implicit styles
(#34716) by @StephaneDelcroix in
#34719
  <details>
  <summary>🔧 Fixes</summary>

- [SourceGen: VisualStateManager.VisualStateGroups causes 'Names must be
unique' at startup](#34716)
  </details>

## WebView
- Refactor the HybridWebView and properly support complex parameters by
@mattleibow in #32491

- [Android] Fix WebView scrolling inside ScrollView by @Shalini-Ashokan
in #33133
  <details>
  <summary>🔧 Fixes</summary>

- [[Android] WebView's content does not scroll when placed inside a
ScrollView](#32971)
  </details>


<details>
<summary>🔧 Infrastructure (1)</summary>

- [Windows] Fix Narrator announcing ContentView children twice when
Description is set by @praveenkumarkarunanithi in
#33979
  <details>
  <summary>🔧 Fixes</summary>

- [[Windows] SemanticProperties.Description announced twice when set on
focusable container cell (Label
inside)](#33373)
  </details>

</details>

<details>
<summary>🧪 Testing (14)</summary>

- [Testing] SafeArea Feature Matrix Test Cases for ContentPage by
@TamilarasanSF4853 in #34877
- [Windows] Fix CollectionView ScrollTo related test cases failed in CI
by @HarishwaranVijayakumar in #34907
  <details>
  <summary>🔧 Fixes</summary>

- [[Testing][Windows]CollectionView ScrollTo related test cases failed
in CI](#34772)
  </details>
- [Testing] Fixed Build error on inflight/ candidate PR 35234 by
@HarishKumarSF4517 in #35241
- Fix CI for
ValidateKeyboardRuntime_SwitchContainerToSoftInput_WhileKeyboardOpen
test failure in May 4th Candidate by @devanathan-vaithiyanathan in
#35307
- [Windows] Fix Flyout/Locked mode header collapse regression causing UI
test failures on candidate branch by @BagavathiPerumal in
#35312
- [iOS/macCatalyst] [Candidate Fix] Editor shadow and theme regression
caused by BackgroundColor reset on initial handler connection by
@Shalini-Ashokan in #35343
- [Testing] Fixed UI test image failure in PR 35234 - [30/03/2026]
Candidate - 1 by @HarishKumarSF4517 in
#35325
- [iOS] Fix ShellFeatureMatrix test failures on candidate branch by
@Vignesh-SF3580 in #35346
- [Windows] Fix Issue29529VerifyPreviousPositionOnInsert test failure on
candidate branch by @praveenkumarkarunanithi in
#35398
- [Android] [Candidate Fix] Shell: Fix handler disconnect timing to
preserve WebView navigation and memory leak fix by @Shalini-Ashokan in
#35417
- [Testing]Revert 'Fix Preserve ScrollView offsets when Orientation
changes to Neither' by @TamilarasanSF4853 in
#35412
- [Windows] Fix VerifyAllIndicatorDotsShowShadowsWhenIndicatorSize test
failure on candidate branch by @praveenkumarkarunanithi in
#35458
- [Testing] Fixed test failure in PR 35234 - [05/08/2026] Candidate by
@TamilarasanSF4853 in #35362
- [Testing] Fixed test failure in PR 35234 - [05/04/2026] Candidate - 3
by @TamilarasanSF4853 in #35639

</details>

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

- [UIKit] Avoid useless measure invalidation propagation cycles by
@albyrock87 in #33459
- BindableObject property access micro-optimizations by @albyrock87 in
#33584
- Extract filename from DisplayName and add extension if missing by
@mattleibow in #35050
- [core] Add keyed-DI screenshot extensibility for 3rd-party platform
backends by @Redth in #35096
  <details>
  <summary>🔧 Fixes</summary>

- [`ViewExtensions.CaptureAsync(IView)` and `IPlatformScreenshot` need
extensibility for third-party platform
backends](#34266)
  </details>
- Fix MainThread throwing on custom platform backends by @Redth in
#35070
  <details>
  <summary>🔧 Fixes</summary>

- [`MainThread.BeginInvokeOnMainThread` throws on custom platform
backends - Common UI-thread marshaling pattern crashes; `Dispatcher`
works but isn't the documented/recommended
path](#34101)
  </details>
- Tests: Add 11 missing UnitConverters unit tests by @PureWeen in
#35191

</details>

<details>
<summary>📝 Issue References</summary>

Fixes #7580, Fixes #9095, Fixes #11402, Fixes #12916, Fixes #13243,
Fixes #13801, Fixes #15806, Fixes #19560, Fixes #19690, Fixes #19866,
Fixes #20028, Fixes #26103, Fixes #26366, Fixes #27554, Fixes #29529,
Fixes #29772, Fixes #30192, Fixes #30199, Fixes #30254, Fixes #31658,
Fixes #31799, Fixes #32971, Fixes #33065, Fixes #33241, Fixes #33334,
Fixes #33373, Fixes #33500, Fixes #33615, Fixes #33767, Fixes #33783,
Fixes #34101, Fixes #34257, Fixes #34266, Fixes #34402, Fixes #34504,
Fixes #34551, Fixes #34611, Fixes #34662, Fixes #34671, Fixes #34716,
Fixes #34755, Fixes #34759, Fixes #34771, Fixes #34772, Fixes #34842,
Fixes #34846, Fixes #34848, Fixes #34861, Fixes #34889, Fixes #34892,
Fixes #34897, Fixes #34898, Fixes #34900, Fixes #34917, Fixes #34925,
Fixes #34953, Fixes #34975, Fixes #35005, Fixes #35018, Fixes #35063,
Fixes #35116, Fixes #35119, Fixes #35125, Fixes #35127

</details>

**Full Changelog**:
main...inflight/candidate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-drawing Shapes, Borders, Shadows, Graphics, BoxView, custom drawing community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-implemented PR author implemented the agent suggested fix s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Shadow does not honour Styles

6 participants