Skip to content

Replace global singletons/service locators with first-class dependency injection #278

@tylerkron

Description

@tylerkron

Overview

The WPF app still wires services via static singletons (ConnectionManager, LoggingManager, AppLogger, etc.) and a custom DialogService.ServiceLocator. App.OnStartup mixes manual ServiceCollection setup with that locator, which makes mocking difficult and spreads lifetime management across the codebase.

Task

  1. Bootstrap the app with HostApplicationBuilder/GenericHost. Register all services (logging, device management, message consumers/producers, dialogs, EF context factory, view models).
  2. Convert singletons to regular classes with interfaces; register them with proper lifetimes.
  3. Remove the custom ServiceLocator once everything resolves through DI; update WPF windows/view models to request dependencies via constructor injection/factories.
  4. Update background workers/tasks to use injected dependencies instead of static Instance lookups.
  5. Adapt tests: build a minimal service provider and inject mocks/fakes.
  6. Update developer docs/README with new DI guidance.

Acceptance Criteria

  • No static Instance/ServiceLocator usage remains in production code.
  • All dependencies resolve through DI and can be overridden in tests.
  • Build & tests pass; regression coverage includes ConnectionManager duplicate-device handling and LoggingManager session lifecycle with injected fakes.
  • Documentation reflects the new startup/DI model.],

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions