Welcome to the ReSharper SDK! The SDK has been designed to make ReSharper plug-in development and testing easy and enjoyable.
The following list describes all the items that are installed as part of the ReSharper SDK. Let’s start with the items installed into the ReSharper SDK folder.
- [Bin] — this folder contains all of ReSharper’s assemblies, including assemblies that ReSharper relies on. In addition, this folder contains the PDBs for the ReSharper’s assemblies, as well as the full ReSharper test infrastructure.
- [Samples] — this folder contains a sample implementation of a ReSharper plug-in, complete with corresponding tests.
In addition to the SDK folders, ReSharper also installs Visual Studio templates for quickly creating projects or individual plug-in items. These items are typically installed into Visual Studio’s own \ItemTemplates and \ProjectTemplates folders.
There’s just one more thing that gets installed: the target files for ReSharper plug-ins and corresponding test projects. Both exist under your <ProgramFiles>\MSBuild directory. These files are used by the project template to quickly add references to all ReSharper assemblies to your project.
To get a feel for the way in which plug-ins are developed, open up the sample project in the [Samples] folder. This project illustrates the following ReSharper features:
- A code cleanup module
- A context action
- A daemon stage
- An element problem analyzer
- A quick-fix
Of course, the SDK itself is not limited to just these items: there are many more available.
Once you’ve familiarized yourself with the sample project, go ahead and create one of your own! The project templates for ReSharper plug-ins are available for both Visual Basic and Visual C#. Corresponding test project templates are also available.
Hint: ReSharper plug-in development is a lot easier if you use the tools such as the Psi Viewer which are available in ReSharper’s Internal Mode. To enable Internal Mode, edit Visual Studio’s shortcut, adding the string /ReSharper.Internal to the end. Restart Visual Studio to see an additional Internal menu under the ReSharper top-level menu.
In some cases, you might not want to use a project template – for example, if you already have a plug-in project for ReSharper 5 and you want it to convert it to ReSharper 6. In this case, simply unload the corresponding project and edit it manually. Add the following lines to the end of the project file:
- For a plug-in project, add the following line:
<Import Project="$(MSBuildExtensionsPath)\JetBrains\ReSharper.SDK\v6.0\Plugin.Targets" />
- For a plug-in test project, add the following line:
<Import Project="$(MSBuildExtensionsPath)\JetBrains\ReSharper.SDK\v6.0\Plugin.Tests.Targets" />
Reload the project for the targets to take affect.
Important note: it is highly recommended that you remove all existing project references before adding one of these targets file. Visual Studio is very sensitive to duplicated references and is likely to freeze if those occur.
When you generate a Plug-in project using a wizard, the project is set to automatically run in a Debug version of Visual Studio. Please note that the project will run in the main hive. If you want to specify a debugging configuration manually, simply set Visual Studio (devenv.exe) as the debug target. In the parameter string, you will need to specify the key /ReSharper.Plugin "full_path_to_your_plugin", providing the full path to the location of your plug-in (if you have several plug-ins, you can specify a folder here instead).
ReSharper contains project templates to create test projects. Test projects differ from plug-in projects in that they reference a different target file, which in turn references the assemblies related to ReSharper’s test infrastructure.
ReSharper’s tests follow a ‘convention over configuration’ approach. The following assumptions are made:
- Tests are kept in a folder relative to the folder where the compiled test assembly resides. This location can be specified individually in different fixtures, but the default assumption is that, if the solution files (i.e., the .sln file itself as well as the corresponding projects) are kept in an \src folder, then the tests are kept in a nearby \test folder.
- Tests which require the ‘before’ and ‘after’ states are always named such that, if the initial state is named SomeName.cs, the final expected state is always named SomeName.gold.
Test files also support control identifiers. For example, to indicate the placement of the caret, one can use the caret indentifier right in the input/gold files.
Important note: in order for tests to run, the version of the SDK must be stricly less than the version of ReSharper that you have installed. This is a technical limitation that will be overcome in future versions of the SDK.
If you are interested in learning more about plug-in development, the first place you should check out is the ReSharper Plugin Development Confluence area. This area covers a large number of topics.
In addition, you might want to look at more in-depth sample projects that have been written for ReSharper. To do that, take a look at wither the ReSharper PowerToys, or some of the ReSharper Plugins (most of them are open-source).
Finally, if you have a problem, don’t hesitate to contact us – we are always happy to help! You can write a comment under one of the Confluence pages, write an SDK-related feature requires in our YouTrack tracker, tweet us @jetbrains or leave a message at the ReSharper Discussion Forums. The choice is yours!
Develop with Pleasure!
The ReSharper Team