Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for third party extension #1081

Merged
merged 5 commits into from
Mar 23, 2024
Merged

Conversation

veler
Copy link
Collaborator

@veler veler commented Mar 13, 2024

Pull request type

Please check the type of change your PR introduces:

  • Bugfix
  • New feature or enhancement
  • UI change (please include screenshot!)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Internationalization and localization
  • Other (please describe):

What is the current behavior?

Using DevToys 2.0, we can't easily create an extension as a third-party developer.

What is the new behavior?

  • Updated the DevToys.API project while preparing to publish it on NuGet.org. It is now unlisted on https://www.nuget.org/packages/DevToys.Api/
    image
  • Added a helper method to AppHelper that retrieves a specified command line argument.
  • Updated CommandLineLauncherService so it uses the new helper method from AppHelper.
  • Updated MefComposer so it looks for a --extraplugin: command line argument. This argument can be used to indicate DevToys should load an extra plugin that isn't installed in the app. This will be useful to let third party developers debug an extension without having to clone the DevToys repository.
  • Updated the CI so it can publish a .app on MacOS. I realized it wasn't working as I never updated it since we switch from MacCatalyst to AppKit.

Other information

We can now debug a third party extension on Windows Mac and Linux from VS, VS Code and Rider:

image

Video:
https://github.com/DevToys-app/DevToys/assets/3747805/e5834d56-8fe9-4c5c-926d-cc8e254fb654

Hot Reload

Hot Reload is supported when developing third party extension. But a user action is needed. User needs to click on the following button in DevToys UI to reload the extension.
This button is only displayed when DevToys is attached to a debugger. Ultimately, this button throws away the UI of the tool and rebuild it. That's it. And it works! 😁
image

In addition, in VS Code, an experimental option needs to be turned ON:
image
See https://www.poppastring.com/blog/hot-reload-for-c-dev-kit

Here is a sample Extension project:

Sample Extension.zip

To use it:

On Windows

  1. Press Win+S, search "Edit environment variable" and press Enter. A window opens. Click on "Environment variables".
  2. Add a user environment variable DevToysDebugEntryPoint. The value must be like <your_path>/DevToys.Windows.exe. For example, C:/Program Files/DevToys/DevToys.Windows.exe.
  3. Start Visual Studio / Visual Studio Code and open Sample Extension.
  4. Press F5
  5. DevToys will start and the extension will be deployed.

On MacOS

  1. Open a terminal
  2. Type nano ~/.zshrc
  3. Add an environment variable DevToysDebugEntryPoint. The value must be like <your_path>/DevToys.MacOS.app/Contents/MacOS/DevToys.MacOS.
    For example, add to the file export DevToysDebugEntryPoint="/Users/JohnDoe/Applications/DevToys.MacOS.app/Contents/MacOS/DevToys.MacOS".
  4. Save and exit Nano (press Ctrl+X, then Y, then Enter)
  5. Still in the terminal, type source ~/.zshrc to apply the changes.
  6. Restart your Mac
  7. Open the Sample Extension project in JetBrains Rider or Visual Studio Code with C# DevKit extension.
  8. Press F5
  9. DevToys will start and the extension will be deployed.

On Linux

  1. Open a terminal
  2. Type nano ~/.bashrc
  3. Add an environment variable DevToysDebugEntryPoint. The value must be like <your_path>/DevToys.Linux.
    For example, add to the file export DevToysDebugEntryPoint=$HOME/DevToys/DevToys.Linux.
  4. Save and exit Nano (press Ctrl+X, then Y, then Enter)
  5. Still in the terminal, type source ~/.bashrc to apply the changes.
  6. Open the Sample Extension project in JetBrains Rider or Visual Studio Code with C# DevKit extension.
  7. Press F5
  8. DevToys will start and the extension will be deployed.

Quality check

Before creating this PR:

  • Did you follow the code style guideline as described in CONTRIBUTING.md
  • Did you build the app and test your changes?
  • Did you check for accessibility? On Windows, you can use Accessibility Insights for this.
  • Did you verify that the change work in Release build configuration
  • Did you verify that all unit tests pass
  • If necessary and if possible, did you verify your changes on:
    • Windows
    • macOS (DevToys 2.0)
    • Linux (DevToys 2.0)

@veler veler added the devtoys-v2.0 DevToys v2.0 label Mar 13, 2024
@veler veler requested a review from btiteux March 13, 2024 16:27
@veler veler merged commit 3d659ed into main Mar 23, 2024
@veler veler deleted the dev/2.0-support-third-party-extension branch March 23, 2024 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devtoys-v2.0 DevToys v2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants