.NET Tools News ReSharper Platform

The API Verifier: A New Era for ReSharper Plugins

Read this post in other languages:

Despite being a plugin itself, ReSharper serves as an incredible platform for plugin creation. ReSharper’s development team uses the dependency injection approach to design every aspect of the product. That means that any component of ReSharper is like a building block that can be overridden with plugins, opening up virtually limitless possibilities for fine-tuning every aspect of ReSharper’s behavior. 

As a plugin author, you get to take advantage of each and every component that ReSharper developers themselves use. But there’s a flip side to such freedom.

Following the “each public component is an extension point” strategy limits our ability to refactor the existing code. It also makes huge refactorings like preparing ReSharper for the out-of-process mode or preparing our codebase for integration into Fleet much harder. For years, we’ve declared every new version of ReSharper as incompatible with the installed plugins, even if the set of APIs they reference hasn’t technically changed. Due to our internal refactorings, we could not guarantee seamless migration.  

Both ReSharper and Rider have major releases three times a year, which means that until recently, plugin developers were forced to recompile their plugins at least three times a year. It was not lost on us that sticking with this approach made the job of plugin writers maddening, and we knew things had to change. 

That is how we got started with the idea of getting ReSharper’s platform to automatically detect changes in the APIs its plugins reference.  

What is an API verifier? 

In ReSharper, we treat each plugin as an essential part of the product. During the installation process, all parts are combined to form one installation. It is at this stage that we now detect if a plugin uses an API that’s been altered or is no longer available in the latest version of ReSharper.

Should the API verifier raise any red flags, the plugin will be marked as Incompatible and won’t be included with the installed product. It will, however, remain on the list of installed plugins in the Extension manager inside ReSharper.

Those plugins that do pass the API verification will automatically migrate to the next version of the product. ReSharper 2023.1 is actually the second version of ReSharper to incorporate the API verifier, so all plugins that have been compatible prior to the 2023.1 release will be preserved. 

A new way to specify dependencies

With the introduction of the API verifier, we’re also changing our requirements for specifying dependencies pertaining to product version compatibility. This requires a bit of backstory.

Internally, we call our major releases “waves”. To name a wave, we take the last two digits of the year of the release and add a single digit indicating the number for the release in that year. For example, for the first major release of 2023, the wave name is “wave 231”, and the third one for 2022 is “wave 223”. 

Specifying the wave name as a dependency in your plugin can benefit you in two ways. First, it will help us verify that a package is indeed an extension for ReSharper. Secondly, specifying the range of compatible waves lets you indicate which versions of the products are compatible with the plugin. 

In the past, we recommended using interval notations for that. For example, if you were to specify the range in interval notation as [223-231) that would mean that the plugin was only compatible with the 2022.3 version. However, with the introduction of the API verifier, we now recommend specifying waves without using interval notation. You can now declare forward-compatibility just by specifying 231 as a wave dependency, like this:

<dependencies>
<dependency id="Wave" version="231.0.0"/>
</dependencies>

Marketplace integration

The code for the API verifier which executes during the installation was also implemented inside JetBrains Marketplace. This is particularly good news for plugin developers as the page for their plugin now displays detailed warnings whenever the APIs used are no longer present in the SDK. API verification is performed on all available plugins before each Early Access Preview or major release goes public. 

An example of how the API verification results look on the plugin web page of JetBrains Marketplace.

Plugin developers can also opt in to receive email notifications whenever their plugins fail to pass the verification process. The emails provide exhaustive information on which APIs became obsolete or were removed, altered, or updated, helping you zero in on the parts that won’t compile without having to open a project with the plugin code. 

Need help with writing a plugin for ReSharper or Rider? 

What’s next? 

The information on product compatibility that’s now visible in JetBrains Marketplace is only there for the publisher. It’s not possible for us to automatically unlist a plugin, even if we are sure that it is completely outdated and is definitely not compatible with the current version of ReSharper. At the moment, we’re showing those plugins as available in the Extension manager, even though any attempts to install them will fail because they cannot pass the embedded verification.

In the future, we are going to weed out such plugins from the feed. The feeds with the plugins are currently built based on wave versions, not the actual build number of the product. This means that the list of plugins for ReSharper 2023.1 EAP 1 is the same as for the release version. The Marketplace and ReSharper development teams are already working on making the switch from a wave-based feed to a build-based feed, so stay tuned for more updates. 

Kudos

We would like to thank Mike-E for his endless energy and for bringing the importance of implementing this functionality to our attention.

image description