Skip to content

fix: DI bypass in 3 views, binding bugs, converter misuse - #380

Merged
laurentiu021 merged 1 commit into
mainfrom
fix/di-bypass-binding-bugs
May 15, 2026
Merged

fix: DI bypass in 3 views, binding bugs, converter misuse#380
laurentiu021 merged 1 commit into
mainfrom
fix/di-bypass-binding-bugs

Conversation

@laurentiu021

@laurentiu021 laurentiu021 commented May 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes 5 HIGH-severity findings from the full codebase audit:

DI Bypass (H-01, H-02, H-03)

  • AppBlockerView, AppAlertsView, ShortcutCleanerView all created their own ViewModel instances via XAML DataContext, completely bypassing the DI container. The DI-registered singletons (with shared services) were never used by these views.
  • Fix: Removed XAML DataContext assignment. Views now receive DataContext from NavItem.View property which sets it to the DI-resolved ViewModel.

Binding Bugs (H-05)

  • DashboardView bound string properties (e.g. #22C55E) directly to Foreground via SolidColorBrush Color binding — Color expects a Color type, not a hex string. This produced silent runtime binding errors.
  • Fix: Use HexToBrushConverter on all ColorHex bindings (health ring, recommendations, disk verdicts, overall verdict).

Converter Misuse (H-06)

  • WindowsFeaturesView used BoolToVis (standard BooleanToVisibilityConverter) with ConverterParameter=Inverse — but this converter ignores the parameter. The "Not elevated" warning badge was always visible.
  • Fix: Changed to FlexVis (FlexibleBoolToVisibilityConverter) which supports the Inverse parameter.

Styling Consistency (XAML-04, XAML-05)

  • AppBlocker and AppAlerts views used legacy SystemControlForegroundBaseHighBrush (ModernWpf) instead of the app-standard TextPrimary/TextSecondary/Border1 resources.

Housekeeping

  • Fixed stale comment in MainWindowViewModel (said "non-DI resolved" but all 4 VMs ARE resolved from DI).
  • Added audit JSON files to .gitignore.

Build

  • 0 errors, 16 warnings (all pre-existing CS0618/NU — unrelated)
  • Tests project: 0 errors

Summary by CodeRabbit

  • Bug Fixes

    • Fixed data-binding/DI issues across multiple views
    • Corrected color rendering in the Dashboard
    • Fixed "Not elevated" badge visibility in Windows Features
  • Style

    • Unified theming to use consistent app-standard text and border colors
  • Documentation

    • Added changelog entry for version 0.48.15

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 073beb67-1c54-4f72-96d0-f16901ba7ae2

📥 Commits

Reviewing files that changed from the base of the PR and between 803dccc6b7f7787ae6d036cea99205384a91e099 and ca9be61.

📒 Files selected for processing (8)
  • .gitignore
  • CHANGELOG.md
  • SysManager/SysManager/ViewModels/MainWindowViewModel.cs
  • SysManager/SysManager/Views/AppAlertsView.xaml
  • SysManager/SysManager/Views/AppBlockerView.xaml
  • SysManager/SysManager/Views/DashboardView.xaml
  • SysManager/SysManager/Views/ShortcutCleanerView.xaml
  • SysManager/SysManager/Views/WindowsFeaturesView.xaml
✅ Files skipped from review due to trivial changes (2)
  • SysManager/SysManager/ViewModels/MainWindowViewModel.cs
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (3)
  • SysManager/SysManager/Views/WindowsFeaturesView.xaml
  • SysManager/SysManager/Views/AppBlockerView.xaml
  • SysManager/SysManager/Views/DashboardView.xaml
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build & unit tests
  • GitHub Check: Analyze (csharp)
🔇 Additional comments (2)
SysManager/SysManager/Views/ShortcutCleanerView.xaml (1)

5-9: LGTM!

SysManager/SysManager/Views/AppAlertsView.xaml (1)

5-9: LGTM!

Also applies to: 22-22, 24-24, 42-42, 55-55


📝 Walkthrough

Walkthrough

Refactors views to use design-time d:DataContext instead of runtime instantiation, standardizes foreground/border brushes to app theme resources, converts ColorHex bindings through HexBrush in Dashboard, swaps one visibility converter to FlexVis, and adds changelog plus a MainWindowViewModel comment update.

Changes

UI DI, Theme Resources, and Converter Updates

Layer / File(s) Summary
DI/Design-Time DataContext Migration
SysManager/SysManager/Views/AppAlertsView.xaml, SysManager/SysManager/Views/AppBlockerView.xaml, SysManager/SysManager/Views/ShortcutCleanerView.xaml, SysManager/SysManager/ViewModels/MainWindowViewModel.cs
Removes runtime UserControl.DataContext instantiation and adds root-level design-time d:DataContext d:DesignInstance entries; updates MainWindowViewModel comment to indicate DI-resolved view models at runtime.
Theme Resource Standardization
SysManager/SysManager/Views/AppAlertsView.xaml, SysManager/SysManager/Views/AppBlockerView.xaml
Replaces legacy DynamicResource SystemControlForeground* and low/high brushes with StaticResource app theme keys (TextPrimary, TextSecondary, Border1) for headers, statuses, DataGrid borders, and footers.
Dashboard Color Hex Converter Updates
SysManager/SysManager/Views/DashboardView.xaml
Routes *ColorHex/OverallColorHex bindings through HexBrush converter for health gauge border, recommendation icon/message foregrounds, disk result verdict, and tune-up overall verdict.
Windows Features Visibility Converter Update
SysManager/SysManager/Views/WindowsFeaturesView.xaml
Changes "Not elevated — toggle disabled" badge visibility converter from BoolToVis to FlexVis while retaining ConverterParameter=Inverse.
Release Notes Documentation
CHANGELOG.md
Adds the 0.48.15 changelog section documenting the DI DataContext, theme resource, converter, and MainWindowViewModel comment updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 In design-time light my whiskers twitch and play,
I moved runtime DataContexts so DI leads the way.
Brushes hop to theme keys, hex colors gleam anew,
Converters hum and badges flip with just a view.
A tidy little patch — a rabbit’s cheerful coup.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the three main fixes: DI bypass in 3 views, binding bugs in DashboardView, and converter misuse in WindowsFeaturesView, matching the core changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/di-bypass-binding-bugs

Comment @coderabbitai help to get the list of available commands and usage tips.

@laurentiu021
laurentiu021 force-pushed the fix/di-bypass-binding-bugs branch from 0c496f5 to 803dccc Compare May 15, 2026 09:00
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

- Remove <UserControl.DataContext> from AppBlockerView, AppAlertsView,
  ShortcutCleanerView — these created isolated VM instances bypassing DI
- DashboardView: use HexToBrushConverter for ColorHex Foreground bindings
  (health ring, recommendations, disk verdicts, overall verdict)
- WindowsFeaturesView: change BoolToVis to FlexVis for Inverse parameter
- Replace legacy SystemControlForeground* brushes with app-standard
  TextPrimary/TextSecondary/Border1 in AppBlocker and AppAlerts views
- Fix stale comment in MainWindowViewModel (VMs ARE DI-resolved)
- Add audit JSON files to .gitignore
@laurentiu021
laurentiu021 force-pushed the fix/di-bypass-binding-bugs branch from 803dccc to ca9be61 Compare May 15, 2026 09:08
@laurentiu021
laurentiu021 merged commit 7580420 into main May 15, 2026
5 checks passed
@laurentiu021
laurentiu021 deleted the fix/di-bypass-binding-bugs branch May 15, 2026 09:14
laurentiu021 added a commit that referenced this pull request May 22, 2026
- Remove <UserControl.DataContext> from AppBlockerView, AppAlertsView,
  ShortcutCleanerView — these created isolated VM instances bypassing DI
- DashboardView: use HexToBrushConverter for ColorHex Foreground bindings
  (health ring, recommendations, disk verdicts, overall verdict)
- WindowsFeaturesView: change BoolToVis to FlexVis for Inverse parameter
- Replace legacy SystemControlForeground* brushes with app-standard
  TextPrimary/TextSecondary/Border1 in AppBlocker and AppAlerts views
- Fix stale comment in MainWindowViewModel (VMs ARE DI-resolved)
- Add audit JSON files to .gitignore

Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants