Skip to content

[WIP] AutoShell Refactoring#2117

Draft
TalZaccai wants to merge 15 commits intomainfrom
talzacc/autoshell_refactor
Draft

[WIP] AutoShell Refactoring#2117
TalZaccai wants to merge 15 commits intomainfrom
talzacc/autoshell_refactor

Conversation

@TalZaccai
Copy link
Copy Markdown
Contributor

@TalZaccai TalZaccai commented Apr 1, 2026

Structural refactoring of autoShell to make the codebase testable, maintainable, and extensible. No behavior changes — all 78 commands continue to work identically.

Phase 1: Structural Refactoring (Make It Testable)

  • Extract OS abstraction interfaces (IAudioService, IRegistryService, ISystemParametersService, IProcessService)
  • Extract 9 command handler classes by domain (AudioCommandHandler, WindowCommandHandler, SettingsCommandHandler, etc.)
  • Replace 78-case execLine switch with CommandDispatcher + dictionary lookup
  • Add missing error handling (centralized try/catch in dispatcher)
  • Remove quit from handler return type — dispatcher handles it directly
  • Add XML doc comments to all interface methods + <inheritdoc/> on implementations
  • Clean up unused using directives across all files
  • Add explicit private modifiers (satisfying .editorconfig rules)
  • Unify all command names to PascalCase (C# handlers + TS schemas + connector)
  • Run dotnet format for code style consistency

Phase 2: Unit Tests

  • Create autoShell.Tests xUnit project with Moq
  • Test command dispatch (verify correct handler for each action)
  • Test AudioCommandHandler with mocked IAudioService (18 tests)
  • Test settings handlers with mocked IRegistryService / ISystemParametersService (14 test classes)
  • Test AppCommandHandler, ThemeCommandHandler, SystemCommandHandler with mocked services
  • Test parameter parsing edge cases (covered by handler tests)
  • Add reflection-based coverage test enforcing every command has at least one unit test
  • Add dotnet test to CI

Phase 3: Deep Refactoring

  • Split SettingsCommandHandler into 9 domain sub-handlers (Taskbar, Display, Mouse, Accessibility, Privacy, Power, FileExplorer, Personalization, SystemSettings)
  • Extract shared app data into IAppRegistry service (replaces static fields)
  • Migrate all scenario-specific logic from AutoShell.cs into handlers (~1429 → ~152 lines)
  • Move all P/Invoke declarations into their respective domain handlers
  • Move all COM interop (Virtual Desktop, Network) into respective handlers
  • Add cross-handler helpers (WindowCommandHandler.RaiseWindow, FindProcessWindowHandle)
  • Delete AutoShell_Win32.cs — all declarations now live in handlers
  • Improve logging (replace Debug.WriteLine with proper abstraction)
  • Enforce code style with dotnet format CI check
  • Fix all build warnings (CA1806, SYSLIB1054) — target zero warnings

The PascalCase rename missed the .agr (agent grammar) files, causing
agc compilation failures in CI. Updated all actionName values in 5 .agr
files to match their PascalCase counterparts in the TypeScript schemas.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
TalZaccai and others added 2 commits April 1, 2026 11:58
Phase 2 unit test project with three test classes:
- CommandDispatcherTests: quit detection, routing, error isolation, empty/unknown commands
- AudioCommandHandlerTests: volume set/restore, mute on/off, invalid input handling
- HandlerRegistrationTests: all 77 commands registered, no duplicates, PascalCase enforced

Uses xUnit + Moq for mocking IAudioService and other internal interfaces.
Added InternalsVisibleTo for test project and DynamicProxyGenAssembly2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Runs dotnet test for autoShell.Tests after the MSBuild build step,
in both Debug and Release configurations.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@TalZaccai TalZaccai force-pushed the talzacc/autoshell_refactor branch from fba483e to b450c9d Compare April 1, 2026 20:24
TalZaccai and others added 2 commits April 2, 2026 12:36
Add explicit this. prefix to all instance field accesses, property
accesses, and method calls across 19 files in the autoShell project
to comply with .editorconfig rules:
- dotnet_style_qualification_for_field = true:error
- dotnet_style_qualification_for_property = true:error
- dotnet_style_qualification_for_method = true:error
- dotnet_style_qualification_for_event = true:error

Co-authored-by: Copilot <223556219+Copilot@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.

1 participant