You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Project Guide: Workspace Launcher for Visual Studio & VS Code
2
2
3
3
This document provides an overview of the project's architecture, focusing on its design principles and key components.
4
4
@@ -8,31 +8,39 @@ The extension is designed following SOLID principles to ensure it is maintainabl
8
8
9
9
### Key Principles
10
10
11
-
***Single Responsibility Principle (SRP):** Each class has a single, well-defined responsibility. This is exemplified by the service layer, where responsibilities are highly granular. For instance, `VisualStudioCodeInstanceProvider` is solely responsible for discovering Visual Studio Code installations. `VisualStudioCodeWorkspaceProvider` orchestrates workspace discovery, which is further delegated to specialized reader classes like `VscdbWorkspaceReader` and `StorageJsonWorkspaceReader`, each handling a specific data source.
11
+
***Single Responsibility Principle (SRP):** Each class has a single, well-defined responsibility. This is exemplified by the service layer, where responsibilities are highly granular. For instance, `VisualStudioCodeInstanceProvider` is solely responsible for discovering Visual Studio Code installations, while `VisualStudioProvider` is responsible for discovering Visual Studio solutions.
12
12
***Dependency Inversion Principle (DIP):** High-level modules do not depend on low-level modules; both depend on abstractions. This is achieved through the use of interfaces like `IVisualStudioCodeService`. The `WorkspaceLauncherForVSCodeCommandsProvider` and `VisualStudioCodePage` depend on the `IVisualStudioCodeService` interface, not the concrete `VisualStudioCodeService` implementation. This decoupling allows for easier testing and maintenance.
13
13
14
14
## Project Structure
15
15
16
-
The project is organized into the following key directories within the `VisualStudioCode` project:
16
+
The project is organized into the following key directories within the `WorkspaceLauncherForVSCode` project:
17
17
18
18
-**`/`**:
19
19
-[`WorkspaceLauncherForVSCode.cs`](./WorkspaceLauncherForVSCode.cs) - The main extension implementation.
20
20
-**`/Classes`**: Contains core data models and helper classes.
-`VisualStudioCodeInstance.cs`, `VisualStudioCodeWorkspace.cs` - Core data models.
23
23
-**`/Commands`**: Contains command implementations that are executed by the user.
24
-
-`OpenVisualStudioCodeCommand.cs` - The primary command for launching a selected workspace.
25
-
-`CopyPathCommand.cs` - Copies the workspace path to the clipboard.
24
+
-`OpenVisualStudioCodeCommand.cs` - The primary command for launching a selected VS Code workspace.
25
+
-`OpenSolutionCommand.cs` - The primary command for launching a selected Visual Studio solution.
26
+
-`CopyPathCommand.cs` - Copies the workspace or solution path to the clipboard.
26
27
-`RemoveWorkspaceCommand.cs` - Removes a workspace from the recently opened list.
28
+
-**`/Components`**: Contains components for window management, adapted from the WindowWalker extension.
29
+
-`Window.cs` - Represents a single open window.
30
+
-`WindowProcess.cs` - Manages process information for a window.
31
+
-`OpenWindows.cs` - Manages the collection of open windows.
32
+
-**`/Helpers`**: Contains helper classes, including `NativeMethods.cs` for P/Invoke signatures.
27
33
-**`/Interfaces`**: Defines the contracts for services.
28
-
-`IVisualStudioCodeService.cs` - The contract for the main Visual Studio Code service.
34
+
-`IVisualStudioCodeService.cs` - The contract for the main service.
29
35
-**`/Pages`**: Contains UI components.
30
-
-[`VisualStudioCodePage.cs`](./Pages/VisualStudioCodePage.cs) - A dynamic list page that displays discovered workspaces.
36
+
-[`VisualStudioCodePage.cs`](./Pages/VisualStudioCodePage.cs) - A dynamic list page that displays discovered workspaces and solutions.
31
37
-**`/Services`**: Contains the primary service implementations.
32
38
-[`WorkspaceLauncherForVSCodeCommandsProvider.cs`](./Services/WorkspaceLauncherForVSCodeCommandsProvider.cs) - The entry point for providing commands to the Command Palette.
33
39
-[`VisualStudioCodeService.cs`](./Services/VisualStudioCodeService.cs) - Acts as a facade, orchestrating calls to more specialized provider classes.
34
40
-[`VisualStudioCodeInstanceProvider.cs`](./Services/VisualStudioCodeInstanceProvider.cs) - Discovers all installed instances of Visual Studio Code.
35
-
-[`VisualStudioCodeWorkspaceProvider.cs`](./Services/VisualStudioCodeWorkspaceProvider.cs) - Orchestrates the process of finding recent workspaces.
41
+
-[`VisualStudioCodeWorkspaceProvider.cs`](./Services/VisualStudioCodeWorkspaceProvider.cs) - Orchestrates the process of finding recent VS Code workspaces.
42
+
-[`VisualStudioProvider.cs`](./Services/VisualStudioProvider.cs) - Orchestrates the process of finding recent Visual Studio solutions.
43
+
-**`/Services/VisualStudio`**: Contains the integrated source code for discovering Visual Studio instances and their recent items.
-**`/Models`**: C# models that map to the JSON structures of Visual Studio Code's workspace storage.
38
46
-**`/Readers`**: Specialized classes for reading and parsing workspace data.
@@ -41,11 +49,29 @@ The project is organized into the following key directories within the `VisualSt
41
49
42
50
## Core Components
43
51
52
+
### WindowWalker Integration
53
+
54
+
The extension integrates logic from the **WindowWalker** extension to provide window-switching functionality. When a user attempts to open a Visual Studio solution, the extension first checks if that solution is already open in an existing Visual Studio instance.
55
+
56
+
- The `OpenWindows` class enumerates all open windows on the system.
57
+
- The `Window` and `WindowProcess` classes gather information about each window, including its title and process name.
58
+
- The `OpenSolutionCommand` checks the titles of open `devenv.exe` processes to see if the solution is already open. If a match is found, the extension switches to that window instead of launching a new process.
59
+
44
60
### Services and Providers
45
61
46
-
***`IVisualStudioCodeService` / `VisualStudioCodeService`**: This service acts as the primary entry point for interacting with local Visual Studio Code data. It delegates the complex tasks of instance and workspace discovery to specialized provider classes.
62
+
***`IVisualStudioCodeService` / `VisualStudioCodeService`**: This service acts as the primary entry point for interacting with local Visual Studio and Visual Studio Code data. It delegates the complex tasks of instance and workspace/solution discovery to specialized provider classes.
47
63
***`VisualStudioCodeInstanceProvider`**: A static provider class responsible for discovering all installed instances of Visual Studio Code (Stable, Insiders, User, System) by scanning known locations and the system's PATH environment variable.
48
-
***`VisualStudioCodeWorkspaceProvider`**: This static provider orchestrates the process of finding recently opened workspaces. It doesn't perform the reading itself but delegates the task to specialized reader classes.
64
+
***`VisualStudioCodeWorkspaceProvider`**: This static provider orchestrates the process of finding recently opened VS Code workspaces. It doesn't perform the reading itself but delegates the task to specialized reader classes.
65
+
***`VisualStudioProvider`**: This static provider orchestrates the process of finding recently opened Visual Studio solutions. It uses the integrated `VisualStudioService` to discover Visual Studio instances and their recent items.
66
+
67
+
### Visual Studio Integration
68
+
69
+
The extension now includes the core logic from the `PowerToys-Run-VisualStudio` project to discover Visual Studio installations and their recent solutions. This is accomplished by:
70
+
1. Using `vswhere.exe` to find all Visual Studio installations on the system.
71
+
2. Parsing the `ApplicationPrivateSettings.xml` file for each installation to find the location of the `CodeContainers.json` file.
72
+
3. Reading and deserializing the `CodeContainers.json` file to get a list of recent solutions.
73
+
74
+
This integration provides a seamless experience, allowing users to access both Visual Studio solutions and VS Code workspaces from a single interface.
49
75
50
76
### Workspace Readers and Performance
51
77
@@ -59,14 +85,14 @@ To ensure high performance and low memory usage, the extension uses the `System.
59
85
60
86
### UI and Commands
61
87
62
-
***`WorkspaceLauncherForVSCodeCommandsProvider`**: The main entry point for providing commands to the Command Palette. It initializes the required services (`SettingsManager`, `VisualStudioCodeService`) and creates the top-level command items. It also listens for settings changes to reload Visual Studio Code instances when necessary.
63
-
***`VisualStudioCodePage`**: A dynamic list page that displays the discovered Visual Studio Code workspaces. It receives the `IVisualStudioCodeService` to fetch workspace data asynchronously and handles user interactions like searching and scrolling.
64
-
***`OpenVisualStudioCodeCommand`**: The primary command responsible for launching a selected Visual Studio Code workspace.
88
+
***`WorkspaceLauncherForVSCodeCommandsProvider`**: The main entry point for providing commands to the Command Palette. It initializes the required services and creates the top-level command items.
89
+
***`VisualStudioCodePage`**: A dynamic list page that displays the discovered workspaces and solutions. It receives the `IVisualStudioCodeService` to fetch data asynchronously and handles user interactions like searching and scrolling.
90
+
***`OpenVisualStudioCodeCommand` & `OpenSolutionCommand`**: The primary commands responsible for launching a selected VS Code workspace or Visual Studio solution.
65
91
66
92
#### Secondary Commands
67
-
Beyond the primary action of opening a workspace, the extension provides secondary commands for managing the workspace list:
93
+
Beyond the primary action of opening a workspace or solution, the extension provides secondary commands for managing the list:
68
94
69
-
***`CopyPathCommand`**: This command allows the user to copy the full file path of a workspaceor folder directly to the clipboard, providing a quick way to access the location of the project.
70
-
***`RemoveWorkspaceCommand`**: This command provides the functionality to remove a workspace or folder entry from the Visual Studio Code's list of recently opened items. It first presents a confirmation dialog to prevent accidental removals. The command directly modifies the `state.vscdb` or `storage.json` files where VS Code stores this information.
95
+
***`CopyPathCommand`**: This command allows the user to copy the full file path of a workspace, solution, or folder directly to the clipboard.
96
+
***`RemoveWorkspaceCommand`**: This command provides the functionality to remove a workspace entry from the Visual Studio Code's list of recently opened items (not applicable to Visual Studio solutions).
71
97
72
98
This architecture ensures a clean separation of concerns, making the codebase easier to understand, extend, and debug.
This extension adapts and combines functionality from the following open-source projects. I acknowledge and appreciate the availability of their work under open-source licenses:
Copy file name to clipboardExpand all lines: README.md
+28-20Lines changed: 28 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,23 @@
1
-
# Workspace Launcher for VS Code
1
+
# Workspace Launcher for Visual Studio / Code
2
2
3
3
## Overview
4
4
5
-
This project provides a command palette extension for opening Visual Studio Code workspaces.
5
+
This project provides a command palette extension for opening Visual Studio solutions and Visual Studio Code workspaces from a single, unified interface.
6
6
7
-

8
-
9
-
## Replacing PowerToys Run
10
-
Suggested usage to replace PowerToys Run with this extension:
11
-
12
-
1. Open the Command Palette settings > Extensions > Workspace Launcher for VS Code.
13
-
2. Assign **Alt + Space** as the global hotkey (requires disabling PowerToys Run) or assign `{` as an alias with Direct toggled.

16
8
17
9
## Features
18
10
11
+
-**Unified Launcher**: Launch both Visual Studio solutions and Visual Studio Code workspaces from a single, convenient interface.
12
+
-**Window-Switching**: If a Visual Studio solution is already open, the extension will switch to the existing window instead of opening a new instance.
19
13
-**Workspace Management**: Retrieve and display a list of available workspaces, including their paths and types (e.g., Local, WSL, Remote).
20
-
-**Command Execution**: Open workspaces in Visual Studio Code using a dedicated command.
21
-
-**Multi-Installation Support**: Works for multiple installations of Visual Studio Code, including Insider and system installations.
22
-
-**Secondary Actions**: Access additional commands for each workspace entry:
23
-
-**Copy Path**: Copies the full file path of the workspace or folder to the clipboard.
24
-
-**Remove from List**: Removes the workspace entry from Visual Studio Code's list of recently opened projects. A confirmation is required to prevent accidental removal.
25
-
-**Open in Explorer**: Opens the workspace or folder location in the default file explorer.
26
-
-**Refresh Workspaces**: Manually reloads the list of workspaces to reflect any recent changes.
14
+
-**Command Execution**: Open solutions in Visual Studio and workspaces in Visual Studio Code using dedicated commands.
15
+
-**Multi-Installation Support**: Works for multiple installations of Visual Studio and Visual Studio Code, including Insider and system installations.
16
+
-**Secondary Actions**: Access additional commands for each entry:
17
+
-**Copy Path**: Copies the full file path of the solution, workspace, or folder to the clipboard.
18
+
-**Remove from List**: Removes the workspace entry from Visual Studio Code's list of recently opened projects (not available for Visual Studio solutions).
19
+
-**Open in Explorer**: Opens the solution, workspace, or folder location in the default file explorer.
20
+
-**Refresh Workspaces**: Manually reloads the list of solutions and workspaces to reflect any recent changes.
27
21
28
22
## Installation
29
23
@@ -39,7 +33,7 @@ Suggested usage to replace PowerToys Run with this extension:
39
33
### Via Command Palette
40
34
41
35
1. Open Command Palette
42
-
2. Select "Workspace Launcher for VS Code"
36
+
2. Select "Workspace Launcher for Visual Studio / Code"
43
37
44
38
<!-- ### Via Winget
45
39
@@ -49,11 +43,20 @@ Suggested usage to replace PowerToys Run with this extension:
-**Preferred Edition**: Determines which edition (Default or Insider) is used when a folder or workspace has been opened in both editions of Visual Studio Code.
@@ -67,7 +70,12 @@ Suggested usage to replace PowerToys Run with this extension:
67
70
68
71
## How It Works
69
72
70
-
This extension scans for installations of Visual Studio Code on your system, including stable, Insiders, and system-wide installations. It then reads the workspace history from Visual Studio Code's internal storage files (`state.vscdb` and `storage.json`) to populate the list of recent workspaces.
73
+
This extension discovers installations of Visual Studio and Visual Studio Code on your system.
74
+
- For **Visual Studio Code**, it reads the workspace history from the internal storage files (`state.vscdb` and `storage.json`).
75
+
- For **Visual Studio**, it uses `vswhere.exe` to find installations and then reads their configuration files to discover recent solutions.
76
+
- The extension also includes logic from the **WindowWalker** extension to detect if a solution is already open. If so, it switches to the existing Visual Studio window instead of creating a new one.
77
+
78
+
The results are then combined into a single, unified list for easy access.
71
79
72
80
For more detailed technical information about the project's architecture and components, please see the [Project Guide](./GUIDE.md).
0 commit comments