Skip to content

[Maintainability] Manager MainViewModel.cs — Child ViewModels newed up directly, not injectable #648

@Christophe-Rogiers

Description

@Christophe-Rogiers

Severity: Warning

File: src/Servy.Manager/ViewModels/MainViewModel.cs
Lines: 342–348

Description:
MainViewModel directly instantiates PerformanceViewModel, ConsoleViewModel, and DependenciesViewModel in its constructor. This tightly couples MainViewModel to all three child VMs' constructors and their (App)Application.Current dependency. Replacing a child VM with a different implementation or testing MainViewModel in isolation requires constructing the concrete child VMs. No interfaces exist for these child VMs.

Suggested fix:
Accept the child ViewModels as constructor parameters (or define interfaces). This would enable composition via DI and isolated testing of MainViewModel.

Metadata

Metadata

Assignees

Labels

refactorChanges that improve structure, readability, or maintainability without altering external behaviortestsChanges to test code and coverage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions