Repository navigation
Fix ThemeRef PaneBackground, InteractionStates restore, author Style and key quoting on the Style path - #1636
Draft
Alexandre Zollinger Chohfi (azchohfi) wants to merge 1 commit into
Conversation
…and key quoting on the Style path Port the #1618 ThemeRef fixes that don't need SetThemeResourceBinding, keeping the XamlReader {ThemeResource} Style: - SplitView.PaneBackground(ThemeRef) maps to the pane background, and the descriptor clears a removed brush. A loaded SplitView rejects any Style not BasedOn DefaultSplitViewStyle (E_INVALIDARG), so the themed Style is built on it. - InteractionStates captures the normal brush lazily and, on restore, clears a property that had no local value instead of writing back a brush captured at setup. - The themed Style is built BasedOn the control's own Style (setter, ApplyStyle, named styles), targeting the control's exact type, cached per stamped base id, and ClearThemeBindings restores the base. - ThemeRef keys are quoted and escaped in the setter value. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
📦 Build metricsArtifact sizes for Packages (compressed .nupkg)
Assemblies in Microsoft.UI.Reactor
Assemblies in Microsoft.UI.Reactor.Advanced
Assemblies in Microsoft.UI.Reactor.Devtools
✅ smaller / |
Comment on lines
+8421
to
+8428
| catch (Exception ex) | ||
| { | ||
| Microsoft.UI.Reactor.Core.Diagnostics.DiagnosticLog.SwallowedError( | ||
| Microsoft.UI.Reactor.Core.Diagnostics.LogCategory.Theme, | ||
| "ApplyThemeBindings", | ||
| ex); | ||
| return; | ||
| } |
Comment on lines
+8437
to
+8443
| catch (Exception ex) | ||
| { | ||
| Microsoft.UI.Reactor.Core.Diagnostics.DiagnosticLog.SwallowedError( | ||
| Microsoft.UI.Reactor.Core.Diagnostics.LogCategory.Theme, | ||
| "ApplyThemeBindings", | ||
| ex); | ||
| } |
Comment on lines
+8538
to
+8541
| catch (Exception) | ||
| { | ||
| return null; | ||
| } |
Contributor
🧪 Merged coverageCoverage for
No coverage change beyond the noise floor. ✅ ✅ higher / |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Lands the ThemeRef fixes from #1618 that don't need
SetThemeResourceBinding, on the stable Windows App SDK, keepingReconciler.ApplyThemeBindings' XamlReader{ThemeResource}Style. #1618 stays the later API swap. Doesn't touchThemeRef.ResolveorThemeResourceProbe(#1633).SplitView.PaneBackground(ThemeRef)was a silent no-op.GetDependencyPropertyNameandGetStyleTargetTypenow map it, and the descriptor entry is the Optional-backedOneWay(..., dp:), so a removed.PaneBackground(brush)is cleared. Found along the way: a loadedSplitViewthrows E_INVALIDARG on anyStylewrite (even an empty Style, orClearValue) unless the new Style isBasedOnDefaultSplitViewStyle. That already crashes on main when aThemeRefis added to or removed from a mounted SplitView. The themed Style for a SplitView is now built onDefaultSplitViewStyle.ClearValue, so the{ThemeResource}setter takes over again. Opacity-only states no longer touch brushes.Styleis kept. This covers.Set(c => c.Style = s),.ApplyStyle,.AccentButton(),.SubtleButton(),.TextLink(),Title(...)and the other typography factories. The themed Style is builtBasedOnit and targets the control's own WinUI type, soBasedOnis always valid.null, so a customTemplateisn't rebuilt.ClearThemeBindingsrestores the base. Same idea as draft Add native SettingsCard and SettingsExpander (spec 065) #1531'sIReactorBaseStyleHost, done generically.ThemeResourceProbe.BuildStyleXamlin Resolve ThemeRef through WinUI instead of reading theme dictionaries #1633, so this can be deduped once that lands. A key that can't be written skips only that setter and logs aDiagnosticLog.Warning.Linked issue / spec
Part of #1618 (stable-SDK half). Related: #1633, #1531, #522.
Test plan
ThemeRefStyleFixtures(9 fixtures, 75 checks). Each oracle was confirmed to fail on the pre-fixReconciler.cs/Element.cs. Targeted mutations also redden their oracle: toggling throughnull(template rebuilt), the loose TargetType (CheckBox not themed), and noDefaultSplitViewStylebase (the app crashes).FormatThemeResourceReferenceinReconcilerCacheKeyTests.ModifierTableIntegrityTestsexempts the element-specificPaneBackground, as Bind ThemeRef properties with SetThemeResourceBinding instead of a parsed Style #1618 does.dotnet test tests/Reactor.Tests: passed (16057 passed, 18 skipped).dotnet test tests/Reactor.SelfTests -p:Platform=x64: passed.dotnet run --project tests/Reactor.AppTests.Host -- --self-test --filterforThemeRefStyle,Issue522,PanelBorder,ThemeBindings,InterState,Theme,SplitView,NamedStyle,AnimCombo,InteractionandPool: all pass.dotnet restore Reactor.slnx, thendotnet build Reactor.slnx --no-restore -c Release -p:SkipSignaturesGen=truewithNuGetAudit=false: 0 errors. Locally the network blocks nuget.org's vulnerability feed (NU1900), and SignaturesGen's nested restore can't skip it. CI isn't affected.stylingtopic.Risk / breaking changes