Microsoft has expanded the new model for writing extensions for Visual Studio that it launched a year ago. With the fresh update, extensions can be created with their own user interface. In addition, the extensions running in an independent process can now display tooltips and notifications about the progress of actions.
With the start of the second phase, the project for writing Visual Studio extensions changes its name from VSExtensibility to VisualStudio.Extensibility. However, the GitHub repository with the announcements and documentation still has the old name.
The motivation for introducing the new model in September 2021 was that, unlike the classic Visual Studio extensions, the extensions run in an independent process so as not to affect the stability of the development environment. After the first release was limited to functions for the editor, you can create your own user interfaces with the new variant.
VisualStudio.Extensibility comes with its own Remote UI framework for creating interfaces with WPF (Windows Presentation Foundation) components whose program logic runs in a separate process. Developers can use it, for example, to create independent tool windows. Remote UI relies on the Model-View-ViewModel (MVVM) design pattern to separate the presentation of the UI components from the associated logic.
The Visual Studio process takes care of the WPF elements, while the program logic runs in the extension host process.
The framework uses XAML (Extensible Application Markup Language) to describe the UI. The program logic of the extension runs in a separate extension process, while the Visual Studio process takes care of displaying the components. Communication between the processes is asynchronous.
The Remote UI framework brings features for displaying tool windows, including default positioning and rules to show and close the window contextually.
Tips and Notifications
The current release of VisualStudio.Extensibility also introduces commands for displaying tooltips and allows you to include your own images beyond those in the Visual Studio Image Catalog.
Finally, the extensions can now display notifications about the progress of actions running in the background, giving users the option to cancel a lengthy action.
An optional button stops processes that an extension is running in the background.
Extensions for the right context
The editor extensions also get a few additions after the first release focused on features like linters and formatting tools. Recently, the content type and associated file extensions can be defined, as the following example from the documentation shows:
using Microsoft.VisualStudio.Extensibility.Editor; [assembly: ContentTypeDefinition("markdown")] [assembly: ContentTypeBaseDefinition("markdown", baseContentTypeName: "text")] [assembly: FileExtensionMapping("markdown", fileExtension: ".md")] [assembly: FileExtensionMapping("markdown", fileExtension: ".mdk")] [assembly: FileExtensionMapping("markdown", fileExtension: ".markdown")]
Visual Studio merges the new context type definitions with those of the classic Visual Studio Extensions.
AppliesTo() and AppliesToPattern() also determine which document types or file paths and types an extension applies to:
[AppliesTo(ContentType = "CSharp")] [AppliesToPattern(Pattern = "**/tests/*.cs")]
More details about VisualStudio.Extensibility can be found on the Visual Studio blog. Development details and documentation can be found in the associated GitHub repository.
To home page