We continue to invest in the VisualStudio.Extensibility SDK to allow users like you to create extensions that run faster and smoother than ever before! VisualStudio.Extensibility helps you build extensions that run outside the main Visual Studio IDE process for improved performance, reliability, and installation without restarting Visual Studio. Additional benefits include a sleek and intuitive .NET 8-based API and comprehensive, well-maintained documentation to help you develop amazing extensions faster than ever before.
For the latest up-to-date docs and installation instructions, visit https://aka.ms/VisualStudio.Extensibility. We encourage you to report bugs and suggest features via the issue tracker on our GitHub repo, where you can also find extension samples to help you get started.
What’s new for VisualStudio.Extensibility in 17.13?
Our 17.13 release of VisualStudio.Extensibility includes the following features:
- Enhanced editor extensibility through tagger support
- Expanded settings API to allow for observation of changed settings values
Both sets of APIs are marked as experimental, which means that they are subject to change as we iterate on the design based on customer feedback. A core principle of VisualStudio.Extensibility is to provide intuitive APIs. As hard as we work to shape the API to be intuitive from inception, we understand that there are likely gaps we’re missing or assumptions we’re making that could be addressed over time. We therefore mark new APIs as experimental to allow customers to report such gaps so we can address them. To read more about our experimental API and breaking changes policy, please see here.
Taggers – the foundation of custom text decoration
A powerful editor is foundational to a developer’s daily workflow, providing the essential tools and features needed to write, debug, and maintain code efficiently. In Visual Studio, text decorators are one of the key differentiators that enhance this experience. These decorators, such as text colorization and CodeLens, offer contextual information to help developers understand and navigate their code more effectively. At the heart of these decorative features is the concept of taggers. Taggers are the mechanism to mark the text in the editor with hidden information, enabling the editor to adopt various text decorations later.
For example, to provide a custom CodeLens, first we need to define where the CodeLens should show up. Is it CodeLens for a method or a class? Different languages have different syntax for how methods are defined, and some languages may not have classes at all. To know where the blocks of code that make sense for your custom CodeLens to show up, we first need to “tag” the text in the editor with additional information. In 17.12, we talked about how CodeLens can only be created for languages supported by default in Visual Studio, like .NET or C++. This is because the text is already tagged by our own language services to contain the metadata needed for CodeLens. In 17.13, we are providing the API to provide your own tags, so that you can add CodeLens to languages not supported by Visual Studio. The following example shows a snippet of how to define CodeLens tags for a markdown file.
[VisualStudioContribution]
internal class MarkdownCodeLensTaggerProvider : ExtensionPart, ITextViewTaggerProvider<CodeLensTag>, ITextViewChangedListener
{
private readonly object lockObject = new();
private readonly Dictionary<Uri, List<MarkdownCodeLensTagger>> taggers = new();
public TextViewExtensionConfiguration TextViewExtensionConfiguration => new()
{
AppliesTo = [DocumentFilter.FromDocumentType("vs-markdown")],
};
public Task<TextViewTagger<CodeLensTag>> CreateTaggerAsync(ITextViewSnapshot textView, CancellationToken cancellationToken)
{
var tagger = new MarkdownCodeLensTagger(this, textView.Document.Uri);
lock (this.lockObject)
{
if (!this.taggers.TryGetValue(textView.Document.Uri, out var taggers))
{
taggers = new();
this.taggers[textView.Document.Uri] = taggers;
}
taggers.Add(tagger);
}
return Task.FromResult<TextViewTagger<CodeLensTag>>(tagger);
}
}
Of course, there’s a lot more that goes into creating taggers for markdown files, so to view the whole code sample, please see here, or you can refer to our documentation for more details. Try it out and customize the CodeLens experience in your extension even more!
Observing changes to settings values
Another addition we introduced in 17.13 is an enhancement to our settings API which allows extenders to get notified of changes to their settings values. Extenders can now generate settings observers to monitor changes and read their settings value snapshot.
public MyToolWindow(MyCategoryObserver settingsObserver)
{
settingsObserver.Changed += this.SettingsObserver_ChangedAsync;
}
private async Task SettingsObserver_ChangedAsync(MyCategorySnapshot settingsSnapshot)
{
this.MySetting = settingsSnapshot.MySetting.ValueOrDefault(defaultValue: true);
...
}
Please read our documentation for more detailed information and walk through our sample code for full context.
We want to hear from you!
The time and effort you’ve spent reporting issues and sharing suggestions so far has been instrumental in shaping VisualStudio.Extensibility. We need your help as we continue to develop VisualStudio.Extensibility! Please try out the features and APIs announced and let us know what you think. Check out the docs, browse the code samples, and build your first extension. You can send feedback and report issues through our issue tracker.
To request features, look at Developer Community to see if someone else made a similar request first. Create a new one if you can’t find a similar request. By checking for similar requests and upvoting and commenting on them, you help us better prioritize requests. Give VisualStudio.Extensibility a try today and share your thoughts with us!
We appreciate the time you’ve spent reporting issues/suggestions and hope you continue to give us feedback when using Visual Studio on what you like and what we can improve. Your feedback is critical to help us make Visual Studio the best tool it can be! You can share feedback with us via Developer Community: report any bugs or issues via report a problem and share your suggestions for new features or improvements to existing ones.
Stay connected with the Visual Studio team by following us on YouTube, Twitter, LinkedIn, Twitch and on Microsoft Learn.