Repository navigation
Add typed ResourceBuilder overloads for native styling values - #1370
Conversation
Alexandre Zollinger Chohfi (azchohfi)
left a comment
There was a problem hiding this comment.
Thanks for this, the typed overloads fill a real gap. A few things to address inline: FontFamily equality across renders, making the Color overload's intent explicit, proving template consumption in the BreadcrumbBar fixture, and syncing the design specs plus a FontFamily example in the guide.
|
Thanks Alexandre Zollinger Chohfi (@azchohfi) for the detailed feedback! Addressed the review in 51dfc4f:
Validation: Release host build passed with no warnings/errors; 21 LightweightStyling unit tests and the targeted TypedResource selftests passed. Deliberately disabling the Thickness/FontWeight setters and FontFamily equality caused the relevant checks to fail; the restored implementation passed again. Styling documentation compiles and both API indexes match. Existing dependency warnings in the unit-test project and unresolved documentation cref warnings remain. Please let me know if anything else needs adjusting. |
* Add REACTOR_DYM_006: flag color strings BrushHelper can't parse (#1375) Constant color strings that BrushHelper.ParseColor doesn't recognize silently render gray. The new ColorStringLiteralAnalyzer flags them on BrushHelper.Parse, ResourceBuilder.Set(string, string) and the string overloads of Background/Foreground/BorderBrush/WithBorder, with a did-you-mean: - *FontFamily resource key -> new FontFamily(...) (only when the Set(string, FontFamily) overload exists, PR #1370) - #RGB/#ARGB shorthand -> #RRGGBB/#AARRGGBB; missing '#' -> add it - CSS/WinUI named color -> exact hex ColorStringLiteralCodeFix applies these rewrites. The mur check ColorStringLiteralRule mirrors it, anchored on the analyzer ID since the mistake raises no compiler error. BrushHelper gains an internal TryParseColor (no behavior change) so ColorStringParityTests can lock BrushHelper and both classifier copies together. Fixes the in-repo hits it found (AliceBlue in wct-controls, #888 in ReactorHostControlDemo), which all rendered gray. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address pr-review findings for REACTOR_DYM_006 - Prune branches a constant condition / non-null ?? left side / constant switch rules out, so dead code is never reported. - FontFamily: without the Set(string, FontFamily) overload (or inside a ?: branch) point at the .FontFamily(...) modifier; the fix renames a named color: argument to the overload's parameter. - mur check rule now reads the rewrite from the analyzer's message instead of re-deriving it; drops the CLI classifier copy and gives each ?: branch its own suggestion. - Tighter message wording; supported list includes grey/lightgrey. - Tests: live-Reactor target test, dead-branch, FontFamily-in-branch, named-argument fix, BrushHelper built-in colors + gray fallback. - Docs: skill row no longer recommends a non-existent overload; stale rule counts updated. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 1 - FontFamily suggestion escapes the value as a regular C# literal and includes the named-argument rename, so mur check's try: text compiles. - ?? pruning uses proven non-null results from nested selectors. - Switch pruning compares the pattern constant converted to the governing type. - Explicit Where filters in Targets.Resolve and the code fix. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 2 Qualify the suggested type as Microsoft.UI.Xaml.Media.FontFamily so the mur check try: text compiles without a using, and add a test that applies each suggestion, recompiles, and re-runs the analyzer. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 3 Without a rewrite of the argument, a *FontFamily key's .FontFamily(...) modifier advice was truncated out of mur check output. The rule now surfaces it as the try: text; test asserts on the final formatted line. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 4 Record REACTOR_DYM_006 and its TreatWarningsAsErrors impact in the CHANGELOG, per the changelog's contributor conventions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 5 A throw branch never yields null, so a ?? fallback after (cond ? "red" : throw ...) is unreachable and no longer reported. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 6 Skip arguments that reach the color parameter through a user-defined conversion: the operator's result, not the source strings, is parsed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 7 Treat any non-string or user-defined-conversion sub-expression as a boundary while walking selector branches, not just the whole argument. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 * Address review round 8 A ?? whose left side reaches string through a user-defined conversion is never provably non-null, so its outer fallback stays analyzed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8 --------- Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: b58aacd0-29b6-46c1-9603-b8a8b4eecbd8
|
Thanks for catching both issues! Fixed in dee803a:
The doc pipeline built the styling app and compiled the topic successfully. All 15 |
Alexandre Zollinger Chohfi (azchohfi)
left a comment
There was a problem hiding this comment.
Thanks kusutoriクスとり (@kusutori)! All review feedback is addressed and CI is green. LGTM.
4f0bf1c
into
microsoft:main
Summary
Add the missing typed
ResourceBuilder.Setoverloads forThickness,FontWeight,FontFamily,bool,Color, andGridLength, completing the common non-brush styling surface described by spec 015.ThemeRefbehavior; no generic catch-all orintoverload.Linked issue / spec
Fixes #1369
Related: spec 015.
Test plan
LightweightStylingTests: 20 passed, 0 failed/skipped.TypedResource_WinUI selftests: 2 fixtures, 27 checks passed.Thicknessoverload: its targeted test failed; restore the implementation and rerun the 20-test class successfully.mur devtoolsinspection: native BreadcrumbBar resources retain the expected types and values.Validation was focused on this change; the full solution/suites, MSIX, and Native AOT were not run locally. The unit-test build reported the upstream test graph's existing NU1902/NU1903 warnings for
System.Security.Cryptography.Pkcs9.0.6; package versions and auditing settings were not changed.Risk / breaking changes
Additive overloads only. Existing integer arguments still select
double; string arguments still create brushes. Reconciliation and theme resolution are unchanged.