Code generation improvements in ReSharper 2016.3

ReSharper’s code generation actions can create a lot of code for us. Why manually write a constructor that initializes type members? Why manually implement interface methods and properties? ReSharper can do those things for us!

Some say developers who use tools to generate code are lazy. Personally, I like to call that efficient. Instead of writing code that is, in essence, programming language ceremony, we can let ReSharper generate it for us and focus on implementing business value and solving our customer’s problem instead. In this post, we’ll go over some of the newly introduced and updated code generation actions in ReSharper 2016.3.

Generate relational members/comparer (implement IComparable<T>/IComparer<T>)

When we want to be able to compare or sort a class we’re implementing, we have to implement the IComparable interface on it. It features one method, CompareTo(other), which returns 0 when objects are equal, < 0 when the current object comes before the other, and > 0 when the current object comes after the other.

Here’s a ShoeSize class we want to be able to compare. After pressing Alt+Insert we can generate Relational members. As with any ReSharper generate action, we can then select the fields we want to use, optionally change their order and then let ReSharper generate the code for us – in this case the comparer.

Generate relational members

The IComparable interface is great to have for sorting collections and all that, but personally I prefer comparing objects in my code using operators. In other words, I prefer writing shoeSizeA >= shoeSizeB instead of shoeSizeA.CompareTo(shoeSizeB) >= 0. Again using Generate relational members we can enable overload relational operators and have ReSharper generate operator overloads for our class.

Generate relational operators

A cool thing is ReSharper also detects field types. For example if we have a class which contains string fields, ReSharper will let us pick a string comparison option, generate nullability checks and all that.

String comparison options for generated code

Generate dispose pattern (implement IDisposable)

When writing code that makes use of external resources, like a file stream, system handle or a database connection, it’s best to always release these resources when we no longer need them. The .NET runtime helps us with this by finalizing such objects, but that’s not ideal as it takes two rounds of garbage collection to remove the objects from memory – essentially keeping the object around in memory for too long.

The dispose pattern helps us release these external resources so that the garbage collector can do its job faster. And ReSharper helps us do our job faster – we can use the quick-fix by pressing Alt+Enter and let ReSharper generate and implement IDisposable for us.

Generate dispose pattern

The dispose pattern code generation lets us select several options where we can help code generation, for example by specifying fields can be null. We also can specify whether we plan to inherit from this class, or if the class owns unmanaged resources. These options are used to implement variations of dispose logic:

  • When the class only owns managed resources, a simple Dispose method will be generated which in turn calls the Dispose method on those resources.
  • When the class owns only unmanaged resources, ReSharper will generate a Dispose method, a destructor, and a method called ReleaseUnmanagedResources. We can add our own clean-up logic in this method.
  • When the class owns both managed and unmanaged resources, either directly or via inheritance, a Dispose(bool) method will be generated which can be overridden by inheritors.

Generate constructor

Have a class and added some fields and properties to it? Using the Alt+Insert keyboard shortcut, we can generate a constructor for our class. We can select fields, properties and optionally base constructors to call and then let ReSharper generate initialization code. The generated code will assign constructor parameter values to fields and properties. New in ReSharper 2016.3 is that we can (optionally) generate null checks, throwing ArgumentNullException when a parameter is null.

Generate constructor

Generate missing members/overrides that are async

In any codebase, we can start off by writing an interface or a base class and then let ReSharper generate a class that implements or inherits these. With ReSharper 2016.3 we’ve added the option to make generated methods async when returning a Task. This speeds up coding since we no longer have to add the async keyword manually and can just start implementing the method bodies.

Generate missing members

Several other improvements have been made, such as additional quick-fixes for C# and VB.NET that can invoke these code generation actions.

Posted in How-To's | Tagged , , , , | 5 Comments

ReSharper Ultimate 2016.3.2

We are starting the new year with a bugfix update for ReSharper Ultimate 2016.3. All in all, it addresses 50+ issues in ReSharper, dotCover, dotTrace and ReSharper C++.

ReSharper 2016.3.2 includes minor fixes in code analysis and highlighting, automatic code completion in TypeScript, and generation of Dispose pattern implementations. It speeds up the Inline Parameter refactoring and corrects parameter positions in the Change Signature refactoring. Find Usages receives an action to stop the current search. We’ve also fixed unfortunate bugs from the previous bugfix related to ReSharper Build and unit tests run from Unit Test Explorer.

In dotCover 2016.3.2 we fixed a critical issue with Hide auto-properties option that hid only properties’ accessors, but not the properties themselves. It caused incorrect totals displayed in the Coverage Tree.

In dotTrace 2016.3.2 we added .NET Core Application type to the central panel so that it’s easier for you to handle profiling for this kind of applications. We also fixed critical bugs in Timeline Viewer and Performance Viewer, and introduced several improvements to the snapshot comparison feature.

ReSharper C++ 2016.3.2 fixes a couple of code completion bugs and addresses several performance issues with code analysis and navigation. The Introduce Type refactoring gets a new option to use type aliases instead of typedef declarations.

Download this bugfix update to make your experience with ReSharper 2016.3 even smoother. As always, please share your feedback in the comments to this post, and submit any issues you encounter to our tracker.

Posted in How-To's | Tagged , , , , | 2 Comments

Subsystems in dotTrace Timeline Viewer

If you use dotTrace, you probably know it consists of two independent applications for performance analysis: Performance Viewer and Timeline Viewer. One of the greatest features that made Performance Viewer so helpful for quick performance evaluation was Subsystems. In dotTrace 2016.3, Subsystems have finally made it into dotTrace Timeline Viewer.

What are subsystems?

The mechanics of Subsystems are quite simple. In most cases, each subsystem just groups calls made within a certain namespace or assembly: WPF, LINQ, collections, strings, and so on. There are also certain special subsystems which are calculated based on other data (like ETW). These are garbage collection, file I/O, lock contention, and some others.

Subsystems in Timeline Viewer

Why would you care about subsystems when you profile?

The purpose of Subsystems is to quickly answer the main question “What the heck is going on in my app?”, along with more specific questions like “What causes the performance drop?” or “What allocates so much memory?” In dotTrace 2016.2 and earlier, you had to check different filters scattered around the UI to answer these questions. Now, the Subsystems filter is the single place* that shows you how time on the selected time interval is distributed among various activities.

*A group of filters previously known as Interval Filters is now also partly incorporated into Subsystems.

Quickly check what's going on in your app

 

UI freeze caused by user code

UI freeze caused by file operations

If you switch the Events filter to Memory Allocation, Subsystems will show you how much memory a particular subsystem allocates:

Memory allocation and subsystems

Subsystems are available not only as a filter but also as a bar in Call Stack | Methods and Subsystems. The bar shows exactly the same data as the Subsystems filter does. The reason for having it here is to visually evaluate the contribution of certain subsystems in a call subtree. If you enable Follow selection in call tree, the bar will show subsystems for the node currently selected in Call Tree.

Subsystems in call tree

Don’t forget that as everything in Timeline Viewer, Subsystems are able to work as a filter.
To turn on a filter by a certain subsystem, simply check the subsytem in Filters | Subsystems or click on it on the bar in Methods and Subsystems.

Filter by subsystem

Create your own subsystems

By default, all your code is calculated within the User Code subsystem. Of course this can be too vague in solutions containing multiple projects and/or using third-party frameworks. No worries! Subsystems are very flexible – you can create a new subsystem for any assembly, class or method you want to be shown separately in Subsystems.

For example, our app uses the Ionic zip library to handle zip files. We want to be able to quickly see how much time our application spends on zip processing. All we need to do is create a new subsystem that aggregates time spent in the Ionic assembly.

How to add your own subsystem

After you add the new subsystem, Subsystems will be instantly recalculated:

After adding a subsystem

As always, we suggest that you download ReSharper Ultimate and try subsystems in Timeline Viewer on your own!

Posted in How-To's | Tagged , , | Leave a comment

Navigation and search improvements in ReSharper 2016.3

Today we’d like to recap the most important changes in navigation and search that were introduced in ReSharper 2016.3.

Find Results window is populated asynchronously

If your solution is large enough, finding references of heavily used symbols can take time, delaying work with your code. To address this issue, we updated the usage search mechanism to make it async. Both Usages of Symbol pop-up and Find Results window are filled asynchronously, allowing you to work with partial search results. If you invoke Usages of Symbol (Shift + Alt + F12) and notice that search is taking a long time, press + on the number pad to open the Find Results window: as a result, you will be able to continue working on the project while search is being completed.

Usages of Symbol pop-up

Remembering the last search

We enhanced the Go to… family of search actions with a setting to remember the last search. This behavior is turned off by default and can be enabled on the Environment | Search and Navigation page of the ReSharper options. When this option is selected, ReSharper will also use your selection in the editor as the search string.

Remember the last search

Redesigned Recent Files and Recent Edits

We made minor improvements to Recent Files (Ctrl + ,) and Recent Edits (Ctrl + Shift + ,) pop-up windows. They now show the path to the file so that you don’t confuse files with similar names. The list of opened files or recent edits is saved separately for each solution you open and is not cleared when you close it. This means that you can invoke these commands right after opening the solution to get the list of files you worked with or items you modified in your previous working sessions. Any unwanted item can be easily removed from the list by pressing the Delete key.

Recent Edits pop-up

Recent Edits displays each edit in the same method as a separate entry by default. If you want to merge locations, you can select Merge locations in recent edits on the Environment | Search & Navigation page of ReSharper options. In this case, the most recent edit in the method will be shown.

Advanced matching in SSR

Let’s take a look at a small but powerful update to the ReSharper’s structural search and replace (SSR) that helps you find and replace blocks of code matching a particular pattern. In C#, integer constants can now be matched by value regardless of how they are encoded:

Match a particular pattern

Go to Text supports more file types

Another navigation feature, Go to text, received support for additional file formats. On top of existing file types, it now supports finding text in .less, .hbs, .coffee, .scss, .dart, .as and .styl files. This navigation command works in global scope and you can invoke it by pressing Ctrl+T three times.

Go to text navigation

Structural navigation in more languages

We do hope that since ReSharper 2016.2 release you’ve been enjoying increased productivity with structural navigation when coding in C#, HTML, XML or XAML. This feature allows you to use Tab and Shift+Tab keys to quickly move between code elements you need to edit without using a mouse cursor. For example, when editing a for statement, Tab will select the initializer statement, then the terminating condition and then the iterator statement. Shift+Tab will do the same but in reverse.

In ReSharper 2016.3, we have made structural navigation available in more languages so that you can use it in JavaScript, TypeScript, and JSON files.

Structural navigation in JavaScript

Go to Implementation works in TypeScript

Go to Implementation now works for TypeScript types too: you can jump from a base type or member to any of its end implementations, bypassing intermediate steps in the inheritance chain. As usual for ReSharper’s contextual navigation actions, Go to Implementation is available from the Navigate To menu. Alternatively, you can invoke the action when you click a base type or member while holding Ctrl+Alt keys.

Get the latest ReSharper

This wraps up the list of most prominent updates to navigation and search in ReSharper 2016.3. Please download the latest ReSharper and try the new features yourself.

If you encounter any issues or have feature suggestions, please let us know!

Posted in How-To's | Tagged , , | Leave a comment

Analyzing native memory allocation with dotTrace 2016.3

With C#, we live in a comfortable managed world where everything is controlled by CLR. But sometimes, whether we like it or not, we have to work with ‘unmanaged’ objects, for example when we want to use some third-party DLL, a COM component, or a resource required for interoperability with the operating system (like a bitmap).

dotTrace 2016.2 and earlier had no way of showing you how your application worked with unmanaged memory. Version 2016.3 introduced a new event type you can analyze – Native Memory Allocation. It can be very helpful with all kinds of issues related to native memory: potential memory leaks, issues with unmanaged components used by your managed code, and more.

The Native Memory Allocation filter simply shows all events where allocations to the native heap occur. Note that dotTrace currently shows you only allocations of native objects that were not de-allocated by the time you took the snapshot. Thus, unfortunately, at the current stage you cannot use this filter to analyze excessive native memory allocations (native memory traffic).

Native memory allocation point events

A couple of notes before we take a look at how it works:

  • You must have Windows Performance Toolkit installed on your machine.
  • dotTrace collects native allocation data only in the Timeline profiling mode.

How to use it

  1. First of all, when starting a profiling session, don’t forget to enable Collect native allocations in Advanced profiling options. (The option is disabled by default as it is a resource-consuming operation.)
    Advanced profiling options, Collect native allocations
  2. When you open a profiling snapshot in the viewer, select Native Memory Allocations in the Events list:
    Native memory allocation in Visual Studio
  3. Like nearly everything in dotTrace, Native Memory Allocation works as a filter. To identify calls that are responsible for native memory allocation, perform these two steps:
    1. Select the Native Memory Allocation event. Calls in the Methods window are now sorted by the size of native memory they allocate.
    2. Select a particular method and press Enter to navigate to its code.

Native allocations. Navigate to code

We hope you find this feature useful. To try it on your own, download ReSharper Ultimate 2016.3.

Posted in How-To's | Tagged | 2 Comments

Deep event analysis with dotTrace 2016.3

dotTrace 2016.3 introduces a new Events window which is available in both standalone dotTrace and dotTrace integrated in Visual Studio.

To open the window in the standalone Timeline Viewer, use the View | Events menu:

Open Events window in Timeline Viewer

In Visual Studio, click Show Events in the Performance Profiler window:

Open Events window in Visual Studio

What is the Events window?

It’s a tool window that shows the list of events that occurred in the profiled application, including file operations, HTTP requests, SQL queries, exceptions, and JIT compilation. By default, events are sorted by the time of their occurrence. Strictly speaking, it’s just an event log.

When would you want to use it?

Use the Events window like any other event log — for analyzing complex cases and bugs when the data provided by other filters is not enough.

First of all, the Events window may help you analyze situations when a particular sequence of actions (e.g., SQL requests, file I/O, and so on) in your application leads to an exception. Regular timeline filters show you only aggregated information for a selected time interval, and it’s not easy to identify a correlation between actions and exceptions. On the contrary, the Events tool window shows the list of events in exactly the same order they occurred, which means you can determine what events preceded a particular exception.

To do this, narrow the time interval using standard timeline filters (to eliminate any events you don’t need) and then find particular events in the Events tool window. Use the search field at the top to help with your search. The Events tool window shows call stack information for every event so you can determine the call that originated the event right in place.

Events tool window

The second scenario where the list of events can help is when you need to refine your analysis results. Let’s assume that you used filters to find out that your application writes to a particular file 10 times and these writing operations are taking too long. With the Events tool window, you can go even deeper and find out which of those 10 events took the longest. If some events lasted longer than the others (simply sort the log by Duration), then it’s a good reason to look at the call stack that’s behind them.

Events window sorted by duration

As ever, we invite you to download the latest ReSharper Ultimate to try this and other new dotTrace features in practice.

Posted in How-To's | Tagged , | 3 Comments

Exploring Intermediate Language (IL) with ReSharper and dotPeek

When compiling .NET languages, our source code is not translated into native code for the platform it will run on. Instead, code is translated into Intermediate Language (IL) which can then be executed on a variety of platforms and CPU types. On the target machine, the .NET runtime will translate this IL code to native code and execute it. Both ReSharper and dotPeek allow us to explore our source code and the (decompiled) IL instructions. We can use it to learn how the compiler translates our code into IL.

The IL viewer can be opened from a few places, like the ReSharper | Windows | IL Viewer menu or the context menu in the editor (Navigate | IL Code). In dotPeek, it can be opened from the Windows | IL Viewer menu. The tool window will display the decompiled IL for the class or method we currently have open in the editor. If no IL is displayed, make sure to compile the project first as the IL is read from the compiled assembly.

Intermediate Language (IL) viewer in ReSharper

When placing the caret on a symbol in the editor, the IL view is synchronized and matching code is highlighted. Synchronization also works in the other direction: when placing the caret on a block of IL code, the editor will jump to the corresponding code. This behaviour can be toggled using the Track Caret in Editor and Automatically Scroll to Source toolbar buttons. If we place the caret on a setter of an auto-property, we can see the IL view jump to that location. We can see the compiler magic in action: the IL code clearly shows the C# compiler generated a backing field for our property.

IL viewer displaying backing field for auto-property

The IL viewer helps us in understanding the IL code shown. There are comments in it, showing line and column numbers. For example, the set keyword in the editor is on line 10, columns 37-41. Types, members, type parameters, local variables, etc. are highlighted with distinct colors, and loops in our code are indented and decorated with comments:

Viewing a loop in intermediate language

But what do all these IL instructions mean? The IL viewer shows the description, taken from MSDN and the ECMA-335 standard (Partition III: CIL Instruction Set), when hovering the mouse over an instruction.

IL viewer displays explanation of intermediate language instructions

When using the IL viewer to optimize code, it’s always best to compile with the Release configuration. In Debug, the compiler optimizes our code debug-ability, while in Release the focus is on speed. Most of the optimization is done by the .NET runtime when the application is run, but there are differences in the IL as well.

For example, in Debug we can see there are a number of nop instructions in each method while in a Release build there are not. The nop instruction doesn’t do anything at runtime (except waste a CPU cycle), but it comes in handy when debugging as it allows the debugger to place a breakpoint on a line (instead of on a specific instruction). We can see this in action in a debug build: when placing the caret on the nop instruction, the editor jumps to the curly brace which is where we could place a breakpoint.

IL viewer nop instruction

(As an added bonus: there is more compiler magic in the above example. See that string “Hi there!” being concatenated from the original source code?)

When using the IL viewer in dotPeek, we can also configure it to display IL code as comments inside decompiled code. After enabling this in the options (under Decompiler | Show IL in comments), we can see this in action. Note that this only works for decompiled code – IL can not be displayed as a comment for code downloaded from external symbol servers.

Viewing IL code in comments (dotPeek)

The IL viewer in ReSharper and dotPeek can be used to learn about Intermediate Language and how our source code is compiled to it. When combined with a profiler, we can use it to optimize our code as well.

Check out our help for more information on the IL viewer and give it a try as part of ReSharper or dotPeek. We definitely want to hear your comments!

Posted in How-To's | Tagged , , , , , | 5 Comments

New code coverage highlighting in dotCover 2016.3

After we released the initial continuous testing support in dotCover, the most popular response was “Cool, but this could be a lot more useful if highlighting was able to indicate test results.” Indeed, before 2016.3, dotCover’s highlighting was used only to indicate code coverage:

Code coverage highlighting in dotCover 2016.2 and earlier

dotCover 2016.3 finally addresses the issue. First, we got rid of colored backgrounds. Now, we use a small colored marker in the left gutter. Second and most important, we’ve completely changed the highlighting logic. Now, it not only shows whether a statement is covered by tests but also indicates test results.

dotCover 2016.3 code highlighting

The new highlighting is especially useful for continuous testing. You no longer need to keep the Continuous Testing Session window open: you run tests and see results instantly, right in the code:

Code coverage highlighting in dotCover 2016.3

Each marker’s tooltip shows you details on the number of tests, their state, and coverage session. Note that as soon as you change the code in any way, test results become outdated. In this case, a marker keeps its color but it becomes lighter. The marker’s tooltip continues to show details about the previous state:

Tooltip shows info about previous coverage state

How to quickly navigate to covering tests?

Just use the Ctrl+Alt+K,T shortcut. Alternatively,

  1. Click on a marker to see tests. The list with covering tests will appear.
  2. Double click on a particular test to navigate.

Navigate to covering tests

How to quickly debug failed tests?

Using the same tests list that appears by click on a marker!

First, you can quickly get stack trace data for any failed test:

Stack trace for failed tests

You can also instantly set a breakpoint for any statement that is covered by a failing test and then launch debugging:

Debug failed tests

What if there are multiple statements in a line?

If a line of code includes several statements with different coverage results, dotCover will highlight the line taking into account only the ‘worst’ result. For example, if tests pass for the first statement, but fail for the second, dotCover will highlight the line with red. If one statement is covered by some failing tests and another statement is not covered at all, the highlighting will be gray:

Multiple statements in a line

How to enable code coverage highlighting?

Nothing has changed in this regard. As usual, you can enable/disable the highlighting in the Unit Test Sessions window (Coverage tab) using the Highlight code button or the Ctrl+Alt+K,H shortcut.

Turn on code coverage highlighting

As usual, we invite you to try this new feature on your own. Download ReSharper Ultimate 2016.3 and let us know how it works for you.

Posted in How-To's | Tagged , , , | 6 Comments

Language injections in ReSharper Ultimate 2016.3

ReSharper Ultimate 2016.3 introduces a new infrastructure for language injections in string literals, which enables ReSharper to treat particular string literal contents as a piece of code written in one of the supported programming languages: C# or ECMAScript regular expressions language, CSS, HTML, JSON or JavaScript.

You can inject a language into a string literal in one of the following ways.

Method 1: “Mark as injected language” context action

When you open the Alt+Enter menu on a string literal, you’ll see a “Mark as injected language” item. In the submenu, choose one of the supported languages. The contents of this string literal will be recognized as a piece of code in that language:

Mark as injected language

Even though this kind of injection tracks code changes and persists in many ordinary cases, it can disappear if you perform huge code reorganization, such as moving to another file or performing Extract method refactoring. Please take into account that tracking code changes has a performance penalty, so if you have many items injected using “Mark as” in the same file, in some cases you may notice a slowdown.

If you need to remove language injection inserted using the “Mark as injected language” context action, you can press Alt+Enter and select “Remove <language> injection mark” there:

Remove injection mark

Method 2: injection comment

You can use a comment to inject a language into a string literal.

The syntax is mostly compatible with the syntax used by IntelliJ IDEA for the same feature. That means that if your team members use both IntelliJ-based products and ReSharper, all of them will have the same experience for injected languages.

A language injection comment has the following form:

where language specifies a language ID to inject. It is case-insensitive. The following language IDs are currently supported:

  • CSS – CSS language injection
  • HTML – HTML language injection
  • JSON – JSON language injection
  • JSREGEXP – ECMAScript regular expression language injection
  • REGEXP – .NET regular expression language injection
  • JAVASCRIPT – JavaScript language injection

Please note that some of language injections are available only for particular target languages.

Availability of language injections using code comments is shown in the following table:

Injected language In C# strings In JavaScript strings
CSS Yes Yes
HTML Yes Yes
JSON Yes Yes
ECMAScript regular expression No Yes (prefix/postfix unsupported)
.NET regular expression Yes (prefix/postfix unsupported) No
JavaScript Yes Yes

prefix= and postfix= options provide a way to specify a string that “precedes” your string and a string that “follows” your string, respectively. This is very helpful if you want to have language assistance only for a code fragment. For example, you can inject a CSS color value into a string by using the following comment:

HTML injected into JavaScript

It is important to know that prefix= and postfix= are matched textually, so that all the leading and trailing whitespaces specified in these options will be included in the target string. For example, if you want to have a prefix { and a postfix } without any whitespaces, then you need to specify the following options:

Language injections using code comments don’t have the problems of the “Mark as” action described in Method 1. They are stable as long as your comments are there, and they don’t cause any visible performance impact.

There are, however, several differences in how IntelliJ Platform implements the same feature (which is used in IntelliJ IDEA, WebStorm, and other IntelliJ-based products):

  1. In ReSharper implementation, quotes are not trimmed, neither from language=, nor from prefix= and postfix=. This is done intentionally, because you may want to have prefix/postfix with quotes, and also this is done to encourage using simple injected language IDs.
  2. Comment positioning in ReSharper is more relaxed than in IntelliJ implementation. In IntelliJ, the injection comment always matches the nearest following literal, so you’ll locate it as close as possible to the target literal. In ReSharper, language specifics are taken into account, and the comment may be located after the literal itself, or after some simple construct embracing the literal, or even at the end of the line.

Method 3: automatic injections

This kind of injection is performed by ReSharper itself, so in most cases you will work with injections without even noticing it. For example, if you set the innerHTML property of a JavaScript object, you’ll get HTML assistance in your assigned string value. Also, HTML and CSS injections are automatically provided for Angular templates in JavaScript code:

Automatic injection in AngularJS

ReSharper has a dedicated Options page where you can see all the available automatic injections and disable or re-enable them as needed.

Language injection settings

This mechanism is extensible, and it’s easy to provide your own places for language injections for supported languages in your ReSharper plugin. You’ll need to implement the interface called IInjectionNodeProvider as a SolutionComponent.

  • In the Check() method, provide your logic for checking the particular syntax tree node. If it returns true, the target language will be injected in this node. You can save some intermediate computation results into “data”, to use them for prefix and postfix computation.
  • GetPrefix()/GetPostfix() provide an ability to specify prefix and postfix for language injection (check ‘Comment’ section of this article to learn more about prefixes and postfixes). You can use a previously computed state “data” here.
  • ProvidedLanguageID should be one of the IDs described in the section ‘Method 2: Injection Comment’ above (using InjectedLanguageIDs static class properties is recommended).

As your plugin is loaded by ReSharper, you’ll see your own injections implementing IInjectionNodeProvider in the same options page where built-in injections are shown.

Current limitations and plans

Currently you can inject a language only into a single proper string literal. That means that you can’t inject a language into a string concatenation. Also currently you can’t inject a language into a C# 6 interpolated string or a ECMAScript 2015 template string if they have template arguments (for argument-less template strings, injection works). Note that even though injection works with C# string.Format string, the string content is treated literally, without substituting the arguments. So, depending on your target language, it may or may not be a syntax error.

Currently there is no mechanism to provide language injections using ReSharper external annotations. One of the upcoming ReSharper releases will introduce a [Language] external annotation for C# to provide you with one more way to manage language injections.

Please note that using prefix= and postfix= for language injections can cause some features to behave unexpectedly in certain situations. This may happen if you have significant constructs (such as variable declarations) in prefix/postfix code, or if some parts of the same syntax element are split between prefix/postfix and the real string contents. Use this possibility with care.

All the symbols defined inside language injections (for example, JavaScript variables or CSS classes defined inside string literals) are local to the injected piece of code, and are not guaranteed to be reachable from code external to the inject.

Language injections can be implemented only for the languages that are natively supported by ReSharper. For example, that means that until SQL is natively supported by ReSharper, it’s impossible to have injected SQL, despite the fact that it is a highly requested feature. But for any language natively supported by ReSharper language injections are doable. Please create a feature request if you’re missing one.

We’re going to address many of these limitations in our further releases. Stay tuned!

Posted in How-To's | Tagged , , , , , , | 16 Comments

ReSharper Ultimate 2016.3.1

Looking for a bugfix release? We have one! ReSharper Ultimate 2016.3.1 is now available for download. This update addresses a selection of issues in ReSharper and ReSharper C++.

ReSharper 2016.3.1 is mostly about integrating into Visual Studio 2017 RC. We’ve received a lot of complaints about 2016.3 not detecting a Visual Studio 2017 RC installation. In all cases, repairing the Visual Studio installation would fix the issue, and based on this experience, we’ve updated the installer to detect (and warn about) incomplete Visual Studio installations.

Other than that, the new ReSharper fixes a couple of code analysis regressions, issues with discovering .NET tests in certain scenarios and running Jasmine tests, and addresses some false red code reports in PCL projects and elsewhere. Here’s the full list of ReSharper fixes for your reference.

ReSharper C++ 2016.3.1 improves an assortment of code inspections, quick-fixes, unit testing, IntelliSense and XML documentation usage scenarios. Here’s the full list of ReSharper C++ fixes.

Posted in How-To's | Tagged , , , | 6 Comments