Priority
P3
Context
Found during a static DRY/KISS/SPoA/SPoT/Clean Code regression audit of main at commit 874b1d74381af65d3d95b955a5bea6c7680876a9 (0.5.0.30).
Problem
AppTheme centralizes most colors, but several semantic variants remain local Color.FromArgb values, including the alternating grid-row background and danger hover/pressed/border states in ModernButton.ResolveColors.
Changing the visual semantics of a danger control or alternate surface therefore requires editing multiple implementation details rather than one theme definition.
AppTheme.CreateUiFont creates a new Font object on every call. Most controls own these fonts through WinForms disposal, but fallback expressions in selector rendering/configuration can allocate fonts without explicit ownership, for example:
cellStyle.Font ?? AppTheme.CreateUiFont(9.5f)
In ModernSelectorComboBoxCell.Paint, this fallback occurs on a rendering path and the newly created font is not disposed.
Impact
- theme variants can drift from the central palette;
- changes to danger styling require multiple edits;
- paint-path fallback allocation can leak GDI font objects;
- font ownership is unclear at fallback call sites;
- adding controls encourages additional local color constants.
Proposed direction
- Add semantic theme tokens for remaining variants, for example
SurfaceAlternate, DangerHover, DangerPressed, and DangerBorder.
- Replace local semantic
Color.FromArgb values with these tokens.
- Avoid allocating a font inside paint fallback expressions; use an existing owned control/grid/default font.
- Review
CreateUiFont call sites and ensure every created font is owned by a disposable component or explicitly disposed.
- Keep the current simple static theme model; no theme framework is required.
Acceptance criteria
Priority
P3
Context
Found during a static DRY/KISS/SPoA/SPoT/Clean Code regression audit of
mainat commit874b1d74381af65d3d95b955a5bea6c7680876a9(0.5.0.30).Problem
AppThemecentralizes most colors, but several semantic variants remain localColor.FromArgbvalues, including the alternating grid-row background and danger hover/pressed/border states inModernButton.ResolveColors.Changing the visual semantics of a danger control or alternate surface therefore requires editing multiple implementation details rather than one theme definition.
AppTheme.CreateUiFontcreates a newFontobject on every call. Most controls own these fonts through WinForms disposal, but fallback expressions in selector rendering/configuration can allocate fonts without explicit ownership, for example:In
ModernSelectorComboBoxCell.Paint, this fallback occurs on a rendering path and the newly created font is not disposed.Impact
Proposed direction
SurfaceAlternate,DangerHover,DangerPressed, andDangerBorder.Color.FromArgbvalues with these tokens.CreateUiFontcall sites and ensure every created font is owned by a disposable component or explicitly disposed.Acceptance criteria
Fontinstances;CreateUiFontresult has clear ownership;