Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers

How-To's

Code Completion Improvements in ReSharper 9

ReSharper 9.x continues to build on the radical improvements in ReSharper 8 with even more completion features and enhancements to existing ones.

Here’s what we’ve got:

  • Completion filters let you take control of your search results if they get too big. The new completion filters let you fine-tune the set of results by showing a set of options below the completion list. These buttons can be toggled either using the shortcut keys or the mouse (left button adds the element, right button removes it):
    Code completion filters
    The behavior of completion filters is configurable in ReSharper’s options. You can choose whether to enable or disable filters, whether to show the filter bar, and whether filter state should persist between successive invocations. It is also possible to add custom filters which can take care of special circumstances, such as collisions between identically named APIs:
    Custom completion filter configuration
  • Sorting by relevance, which is a ReSharper 9.1 feature, ensures that the set of completion items you are shown have the most relevant items listed first. Also, selection no longer jumps between items while populating the completion list.
  • Fuzzy matching ensures that, even if you make a mistake in an identifier, code completion results will still show the right item if it looks to be similar. Here’s an example:
    Fuzzy matching in code completion
  • Combo returns are a novel feature useful for situations where you have a method that has to do either a return or a yield return. When using smart completion in a return statement, ReSharper filters the list to only show the types that match the return value:
    Combo returns
    Return completion also detects the use of an enum member that is being returned:
    Enum members in return completion
  • Parameter info now includes ReSharper’s annotations:
    Annotations in Parameter Info
    This new behavior is configurable: you can elect to show all annotations, only NotNull/CanBeNull, or hide them altogether. You can also now limit the number of signatures that are shown in the Parameter Info list:
    Parameter Info configuration
  • Double completion improvements (read this for more info on double completion) now show potentially overridable methods after override, static members in non-static context, instance members in a static context, sealed types after typing : in a class declaration, abstract types after typing new, and non-partial classes after typing partial class.
  • Smart completion for strings determines situations where a parameter that takes a string actually takes a specific range of values available elsewhere. For example, here is how ReSharper shows smart completion for a WebRequest.Method property:
    Smart completion for strings

Finally, as always, we’ve made performance improvements to the way code completion works. The completion mechanism was partially rewritten so as to make the lookup items lazy, and to ensure that only the items in the current view are rendered. This makes this whole thing faster, just so you know.

Enjoy!

image description