Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/VsixCommunity/Community.VisualStudio.Toolkit
Making it easier to write Visual Studio extensions
https://github.com/VsixCommunity/Community.VisualStudio.Toolkit
visual-studio visual-studio-extension vs-extension vsix
Last synced: 4 months ago
JSON representation
Making it easier to write Visual Studio extensions
- Host: GitHub
- URL: https://github.com/VsixCommunity/Community.VisualStudio.Toolkit
- Owner: VsixCommunity
- License: other
- Created: 2021-04-11T21:15:42.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T18:07:53.000Z (about 1 year ago)
- Last Synced: 2024-04-28T08:46:14.444Z (10 months ago)
- Topics: visual-studio, visual-studio-extension, vs-extension, vsix
- Language: C#
- Size: 1.36 MB
- Stars: 246
- Watchers: 18
- Forks: 41
- Open Issues: 61
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Community toolkit for Visual Studio extensions
A community driven effort for a better Visual Studio experience developing extensions.
[](https://ci.appveyor.com/project/madskristensen/community-visualstudio-toolkit-1dwx1)
[](https://nuget.org/packages/Community.VisualStudio.Toolkit.17/)The NuGet package [Community.VisualStudio.Toolkit.17](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.17/) acts as a companion to the regular Visual Studio SDK packages with helper methods, classes and extension methods that makes writing extensions a lot easier.
* The [VSIX Cookbook](https://www.vsixcookbook.com) shows you how to build extensions using this toolkit
* [Community.VisualStudio.Toolkit.17](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.17/) official NuGet package
* [CI NuGet feed](https://ci.appveyor.com/nuget/community-visualstudio-toolkit) for nightly builds## Supported versions
* Visual Studio 2015 ([Community.VisualStudio.Toolkit.14](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.14/))
* Visual Studio 2017 ([Community.VisualStudio.Toolkit.15](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.15/))
* Visual Studio 2019 ([Community.VisualStudio.Toolkit.16](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.16/))
* Visual Studio 2022 ([Community.VisualStudio.Toolkit.17](https://www.nuget.org/packages/Community.VisualStudio.Toolkit.17/))## Try the nightly builds
Create a file called **nuget.config** in your solution folder, and paste in the following content:
```xml
```
## Examples
Here are some examples of typical scenarios used in extensions.### Commands
You can now write commands much simpler than you're used to. Here's what a command that opens a tool window would look like:```c#
[Command(PackageIds.RunnerWindow)]
internal sealed class RunnerWindowCommand : BaseCommand
{
protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) =>
await RunnerWindow.ShowAsync();
}
```### Writing to the Status Bar
``` C#
await VS.StatusBar.ShowMessageAsync("My status bar text");
```### Showing a message box
``` C#
await VS.MessageBox.ShowAsync("Title", "Message");
```### Log error to output window
Synchronous version:``` C#
catch (Exception ex)
{
ex.Log();
}
```Async version:
``` C#
catch (Exception ex)
{
await ex.LogAsync();
}
```### Dependency Injection
To incorporate a DI container into your extension, see the complimentary project: [
Community.VisualStudio.Toolkit.DependencyInjection](https://github.com/VsixCommunity/Community.VisualStudio.Toolkit.DependencyInjection)## Purpose
This package attempts to solve multiple issues with the current extensibility model.### Too much boilerplate is needed to do simple things
Base classes, helper methods, and extension methods encapsulate the complexity so you don't have to.### It's difficult to find what services and components to use
Now the most common services are all easy to get to from the main `VS` object.### Best practices change with each version of VS. I can't keep up
The underlying implementation of the project uses the best practices for each version of VS it supports. This ensures that your extension is much more likely to handle threading correctly, and avoid hangs and crashes.### The API is dated and has lots of ugly COM legacy noise
The most common APIs of the old complex COM nature are wrapped to expose a modern async API. This makes it much easier to code against the API and you can avoid the `EnvDTE` object for most scenarios.### The API isn't async and getting threading right is too hard
All the base classes and helper methods are async by default. There are cases where they are not, but that is because it wouldn't be beneficial for them to be.### Only Microsoft can update the API and that doesn't scale
This is a living project where the whole community can contribute helpers on top of the official VS SDK. There is no need to wait for Microsoft to make an update, since this project gives the ability to continue the work in a separate work stream.### Breaking changes in the API between VS version are painful
This project works around those changes in the implementation of its public contracts and interfaces. This means that what was a breaking change to the VS SDK, becomes an implementation detail of this project and no user will be affected.## Templates
For both project- and item templates that utilizes this NuGet packages, download the Extensibility Template Pack:
* [Extensibility Template Pack 2022](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ExtensibilityItemTemplates2022) (Visual Studio 2022)
* [Extensibility Template Pack 2019](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.ExtensibilityItemTemplates) (Visual Studio 2019)