Visual Studio Extensibility

From HandWiki - Reading time: 4 min

Visual Studio eXtensibility (VSX) is a feature of software supplier Microsoft's Integrated Development Environment, Visual Studio. Visual Studio is a tool that can be used to develop applications for the .NET Framework and for the Win32 platform, also Microsoft products. The Visual Studio software development kit, first released by Microsoft together with the 2005 version of Visual Studio, included documentation, samples, and code to help develop products integrate with the Visual Studio product family.[1]

Visual Studio as an extensible platform

When running the Visual Studio IDE the devenv.exe file is started. However, the IDE is not just a simple monolithic .exe file or an executable divided into a few .dll files. It is a shell that provides a graphical environment to host functional units, called packages. What is perceived by users of Visual Studio is a cooperation of the shell and hosted packages. The core functions of the IDE are also implemented in packages including the C# or VB project types, testing features and many more. Most third-party extensions loaded into Visual Studio are also implemented in packages. After installing Visual Studio, about a hundred packages are installed with the shell, depending on the version of Visual Studio.

Methods to extend Visual Studio

Visual Studio can be extended in many ways. Books, articles and references generally mix the different aspects and just mention them as extensibility options. Here, the different aspects of extensibility are treated separately.

Extension by configuration

The simplest method of extending Visual Studio or third-party packages is customizing it with the configuration features built in. In this case you do not have to write “traditional” code and build it. You actually extend Visual Studio behavior with changing the existing configuration or adding a new set of files.

Automation

Many developers use macros since those were introduced in Microsoft Office. Macros make a developer's life easier by automating repetitive tasks. Macros are also available in Visual Studio. They have their own UI within Visual Studio called Macros IDE. Visual Studio provides an automation interface where a great number of core services features are accessible through properties and methods of COM objects. These automation objects form a hierarchy in which it is possible to navigate from one object to another, for example, from the object representing a project to its project items.

Extension by contract implementation

For developers, the most common extension point is an interface representing a contract. To comply with that, a service object implementing the contract must be created, which is the required method in Visual Studio. The integrated development environment and the underlying packages define hundreds of extension points in the form of contract interfaces.

Extension artifacts

When extending Visual Studio by creating, code developers have the following options to create development artifacts:

Macros

Macros provide the easiest way to extend Visual Studio, there is even no need for the Visual Studio SDK. Visual Studio has got functions to record macros, and so we can automate repetitive tasks in a few minutes. Macros access the Visual Studio automation object model and easily combine Visual Studio commands with useful automation property values to get the desired behavior. To become a professional, macro developers have to know the object model behind the macros and a few dozen of patterns about using those objects. Visual Studio 2008 comes with a few macro samples to get started. The best way to learn macro programming is to record macros and view recording results. Although macros are useful for task automation, they are not the right tools to create totally new functionality. When using macros, anyone can see the source code of them. Macros use a VB-like script language; C#-like syntax cannot be used.

Visual Studio add-ins

Add-ins are much more powerful to develop Visual Studio extensions, since they can access the Visual Studio object model and add new user interface elements to the IDE just like tool windows, option pages, menu and toolbar commands, etc. Functions added with an add-in look like if they were a part of the IDE. Add-ins can access services provided by not only the IDE itself but also by other add-ins or packages. Branding is also available, add-in product information can be displayed in the About dialog. Add-ins are compiled .NET binaries, so the same intellectual property guarding techniques can be used as for any other .NET binaries.

Visual Studio packages

There is no doubt developing Visual Studio packages is the most powerful way to add functionality to Visual Studio. The clear evidence for this is the fact that the whole Visual Studio functionality is built from packages integrated into the shell. All the languages, editors, the debugger, the project system and many more components are packages.

From the developer point of view it actually means that adding a new package to Visual Studio is just like adding core functionality to the Visual Studio IDE as if it were developed by Microsoft. The IDE does not make any distinction between Microsoft-created and third-party components; developers see all packages as part of the Visual Studio IDE. Packages are binaries developed with the preferred language (C#, VB,.NET or C++), so from intellectual property guarding aspect they can be as safe as other .NET binaries. Installing packages is a more complex task for developers than setting up add-ins. Registration of packages affects a broader part of the Visual Studio registry entries and is helped by a utility called RegPkg.exe. Visual Studio checks if it can trust a package by a signing mechanism that uses a so-called Package Load Key. This PLK can be obtained from Microsoft and is a kind of digital hash for the package. When the package is installed into a production environment, its PLK is verified. Visual Studio SDK ships a few extensibility project templates that make the creation of package frames as easy as an add-in.

References

External links





Licensed under CC BY-SA 3.0 | Source: https://handwiki.org/wiki/Software:Visual_Studio_Extensibility
5 views | Status: cached on July 24 2024 06:55:07
↧ Download this article as ZWI file
Encyclosphere.org EncycloReader is supported by the EncyclosphereKSF