Importing / Exporting Templates and Patterns in ReSharper 6.1
One of the changes introduced with the new settings in ReSharper 6.1 is how importing and exporting of templates and custom patterns are done (Custom Patterns were previously known as Structural Search and Replace). As part of the unification of settings, Templates and Patterns now fall under the same modus-operandi when it comes to importing and exporting as other settings do. This is very similar to how our IDEA based IDE’s such as IntelliJ, WebStorm et al. work. However, certain legacy functionality is also available depending on what needs to be done.
The de-facto choice
Be it Templates or Patterns, when you want to import or export them, the recommended approach is to use the Manage Options dialog
To export, we merely select Export to File. ReSharper prompts us with a dialog box of what we would like to export:
At this point we can select whether we want Live Templates, Patterns (StructuralSearch*) or both. It is important to note that if you do not have any user defined templates and/or patterns, then these options are not available, i.e., you would not see the LiveTemplates / StructuralSearch checkboxes.
The exported file format is only compatible with ReSharper 6.1 and higher (.DotSettings file).
When it comes to importing templates and patterns, if these are in .DotSettings format, then it is merely about adding another layer. We select the file to import, and are prompted on what settings we’d like imported:
The benefit of this approach is not only that it keeps all settings centralized, but it also allows us to mount and un-mount related templates.
* StructuralSearch comes from the old name giving to Custom Patterns which was Structural Search and Replace
Exporting Individual Templates
One option that is currently not available using the Manage Options dialog when dealing with the export of templates is to selectively choose which ones we’d like exported. If we want to only export specific templates, we need to use the Template Explorer (previously named Live Templates)
We can then select individual templates and choose the Export button. This is basically the old behavior prior to ReSharper 6.1. The difference however is that the file exported is in the new .DotSettings format. In this regard, there is no difference between this approach and the previous Manage Options one.
Dealing with legacy templates and patterns formats
The Templates Explorer window also has an option to import Templates
Although this allows the newer DotSettings file format, we usually should only use this when trying to import legacy templates (from version 6.0 and lower).
When it comes to Patterns, when trying to import older ones, we can use the Import from R# v6.0- button on the Custom Patterns options page
With the new settings we’ve hopefully made sharing of Patterns and Templates a little easier. There are still improvements to make but any/all feedback or changes you’d like to see are welcome. Please log them in our issue tracker so that they can be managed better.
Subscribe to Blog updates
Thanks, we've got you!
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…
OSS Power-Ups: bUnit – Webinar Recording
The recording of our webinar, OSS Power-Ups: bUnit, with Egil Hansen and Steven Giesel, is available. This was the twelfth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webi…
Accelerating Your Testing Workflow with Unit Test Creation and Navigation
Unit tests play an important role in our daily development workflow. They help us ensure our codebase's correctness when writing new functionality or performing refactorings to improve readability and maintainability. In the process, we often create new test files that accompany the p…
Introducing Predictive Debugging: A Game-Changing Look into the Future
With the introduction of debugging tools, software developers were empowered to interactively investigate the control flow of software programs to find bugs in live environments. At JetBrains, we've always strived to improve the art of debugging. Besides the more standard things you expect from a de…