ReSharper 2024.3 Help

Inlay hints

Inlay hints are configurable editor adornments that improve the readability of your code.

Push-to-Hint mode

Inlay hints can be helpful, but on the other hand, they take editor space and may seem redundant in some cases. To view inlay hints on demand, you can use the Push-to-Hint mode. It lets you keep the hints hidden and only view them when needed.

Show inlay hints on a key press

  1. Make sure that the application focus is in the editor.

  2. Press and hold the Ctrl key. Inlay hints will be shown as long as you are holding it.

    Inlay Hints appear with a delay to prevent them from showing unintentionally when Ctrl is used as part of a keyboard shortcut for other actions. By default, the delay is 500 milliseconds. You can configure this delay on the Environment | Inlay Hints | General page of ReSharper options Alt+R, O.

  3. Press Ctrl twice. Inlay hints will be toggled for the current editor tab. Press Ctrl twice again to hind them.

If you want inlay hints to be always shown or hidden in all editor tabs, use the Default visibility selector on the Environment | Inlay Hints | General page of ReSharper options Alt+R, O. Whatever you choose for the default visibility, you can override it for specific kind of hints on the corresponding settings pages under Environment | Inlay Hints.

If the press-and-hold or double-press of the Ctrl key is already bound to some other actions in your OS or other applications , ReSharper will override those mappings even if you don't use Push-to-Hint. To avoid that, clear the Reserve press-and-hold and double-tap of the Ctrl key for Push-To-Hint checkbox on the Environment | Inlay Hints | General page of ReSharper options Alt+R, O.

Parameter name hints

As an alternative to writing named arguments in method calls, you can make use of ReSharper's parameter name hints — editor adornments that show parameter names next to the corresponding arguments at method calls.

Consider the following method call:

AddCheckbox(true, true, "AutoFill", null);

When you read this code, you have to stop and study the method signature to understand what happens here (you can do it either with the parameter information tooltip or by navigating to method declaration). With parameter name hints, the same call becomes much clearer:

ReSharper: inline parameter name hints help understand arguments in a method call

The idea of the parameter name hints is to show parameter names for arguments whose intention may not be clear, but at the same time not to clutter the editor with hints where the argument purpose is obvious, and of course if there are named arguments in the call. To achieve this, ReSharper applies a number of configurable heuristics.

Type name hints

Type name hints help you understand types variables and expressions have in different contexts. For example:

  • anonymous types,

    ReSharper: Inlay hints. long type name
  • parameters of lambda expressions,

    ReSharper: Inlay hints. lambda expression parameter
  • return types of methods in a call chain,

    ReSharper: Inlay hints return type in call chain

and in many other cases.

If necessary, you can configure type name hints for each specific case.

Type conversion hints

Type conversion hints show implicit type conversions in your code.

In the example below, converting from Vector3D to Vector2D silently loses data (the Z value) and the hint helps us see where this happens.

ReSharper: Type conversion hints

If you see that a type conversion hint for a specific conversion is not very helpful, you can disable conversion hints for all conversions involving those specific types. To do so, place the caret next to the assignment operator, press Alt+Enter and choose Configure Inlay Hints | Type Conversion Hints | Hide for.... The change will be saved, and you will be able to review or revert it later on the Environment | Inlay Hints | C# | Type Conversion Hints page of ReSharper options Alt+R, O.

Code analysis hints

You can display missing returns in functions and missing breaks in switch statements using inlay hints. This lets you immediately understand what exactly is missing:

ReSharper Inlay hints: missing return

You can use inlay hints to see places where resource variables are disposed:

ReSharper Inlay hints: disposed resource variable

If you are using the [MustDisposeResourceAttribute] from JetBrains.Annotations to enforce resource disposal in the calling code, ReSharper helps you visually identify constructors and factory methods that return a disposable resource:

ReSharper Inlay hints: MustDisposeResourceAttribute

To configure visibility of these hints, use the corresponding selectors on the Environment | Inlay Hints | C# | Other page of ReSharper options Alt+R, O.

Inlay hints for C# interceptors

Inlay hints will help you spot intercepted calls, with the additional ability to navigate to the interceptor method with Alt+Enter or with Ctrl+click on the hint icon:

ReSharper: Inlay hint and navigation action for an intercepted method

The [InterceptsLocation] annotation on the interceptor method has a hint that allows you to navigate to the intercepted call:

ReSharper: Inlay hint and navigation action for an intercepted method

To configure visibility of these hints, use the corresponding selectors on the Environment | Inlay Hints | C# | Interceptor Hints page of ReSharper options Alt+R, O.

Inlay hints for unnamed constructs

You can see tuple component names as inlay hints when those names are not apparent from the component expression:

ReSharper: Inlay hints for tuple component names

Inlay hints can greatly improve the readability of a deconstruction pattern by showing the declared names of its components:

ReSharper: Inlay hints for deconstruction pattern component names

When a method returns more variables than needed, and some are discarded with _, inlay hints can help you see what is discarded. By default, hints for discards work with push-to-hint:

ReSharper: Inlay hints for discard names

To configure visibility of these hints, use the corresponding selectors on the Environment | Inlay Hints | C# | Other page of ReSharper options Alt+R, O.

'#pragma warning' hints

#pragma warning directives allow you to disable and restore specific warnings by their ID. It is hard to remember what each ID means, therefore ReSharper can add inlay hints with warning descriptions. Note that this kind of hints only work with compiler warnings, whose IDs start with CS.

ReSharper: Inlay hints for '#pragma warning' directives

To configure visibility of these hints, use the corresponding selectors on the Environment | Inlay Hints | C# | Other page of ReSharper options Alt+R, O.

Trailing local function hints

Having local functions at the end of a code block is a common practice, but when reading such blocks, you often need to scroll past local function definitions to make sure there is no executable code after them.

To improve readability in such cases, ReSharper offers inline hints that either visualize the implicit control flow markers such as return; and continue, or just show //Local Functions if there is no more executable code in the block.

ReSharper: Inlay hints for trailing local functions

To configure visibility of these hints, use the corresponding selectors on the Environment | Inlay Hints | C# | Other page of ReSharper options Alt+R, O.

Closing brace hints

When you are at the end of a large code block, it is often not clear what the closing brace represents: it can denote the end of a nested type, a method, or a complex statement. Inlay hints can quickly clarify the code structure by showing what exactly each closing brace is the end of:

ReSharper: Inlay hints for closing braces

To reduce the visual noise, these hints only appear for blocks that are longer than 10 lines, and only when your caret is set to a closing brace.

To enable or disable these hints, use the Use inlay hints to show matching blocks' headers... checkbox on the Environment | Editor | Appearance page of ReSharper options Alt+R, O.

Configure inlay hints

You can toggle and configure inlay hints on the corresponding settings pages under the Environment | Inlay Hints page of ReSharper options Alt+R, O.

If you do not use inlay hints, you can disable them by clearing the Enable Inlay Hints checkbox on the Environment | Inlay Hints | General settings page. ReSharper will stop calculating hints thus saving some resources.

However, if you want to see only a few specific kinds of hints, you can set the Default visibility selector on that page to Never Show and then override this with visibility selectors for the desired types of hints.

For parameter name hints, you can additionally hide hints in methods matching specific patterns. To do so, add these patterns at the bottom of the Environment | Inlay Hints | [language] | Parameter Name Hints page of ReSharper options Alt+R, O.

Here are some examples of patterns:

  • System.Math.* matches all methods whose FQN starts with System.Math

  • System.Math.*(*, *) matches all methods from System.Math namespace with two parameters

  • (*info) matches all single-parameter methods where the parameter name ends with info

  • (key, value) matches all methods with parameters key and value

  • Put(key, value) matches all Put methods with parameters key and value

When your caret is at a code item that has an inlay hint, you can press Alt+Enter, choose Configure Inlay Name Hints, or instead, right-click a parameter hint, and then pick one of the commands, which allow you to:

  • hide parameter hints for all calls of the method, or type name hints that apply for the current item (if you want to show hints that you disabled, you can find the corresponding item or exception pattern in the options page and remove it),

  • change visibility of this kind of hints,

  • disable inlay hints altogether (you can enable them later in the options page),

  • or open the options page for detailed configuration.

ReSharper: configuring parameter name hints from the Alt+Enter menu

If you right-click a paramter name, type name, or a type name hint, you can also navigate to the declaration of the corresponding type or parameter declaration:

ReSharper: configuring parameter name hints from the Alt+Enter menu

You can also toggle parameter name hints in the current solution with the Control+Alt+Shift+5 shortcut or from the context menu of the status indicator:

ReSharper; switching parameter name hints from the status indicator

You can configure the color and font size of inlay hints — the font size can be set on the Environment | Inlay Hints | General page of ReSharper options Alt+R, O, the font color — in Visual Studio options: go to Tools | Options | Environment | Fonts and Colors and find the ReSharper Inlay Hint in the list of display items.

Applicability in different languages

This feature is supported in the following languages and technologies:

Language: C#

Language: VB.NET

Language: C++

Language: HTML

Language: ASP.NET

Language: Razor

Language: JavaScript

Language: TypeScript

Language: CSS

Language: XML

Language: XAML

Language: Resx

Language: Build Scripts

Language: Protobuf

Language: JSON

Feature is available in C#

Feature is available in Visual Basic

Inlay hints in C++

Feature is not available in HTML

Feature is not available in ASP.NET

Feature is not available in Razor

Feature is not available in JavaScript

Feature is not available in TypeScript

Feature is not available in CSS

Feature is not available in XML

Inlay hints in XAML

Feature is not available in Resource files

Feature is not available in build script files

Feature is not available in Protobuf

Feature is not available in JSON

The instructions and examples given here address the use of the feature in C#. For more information about other languages, refer to corresponding topics in the ReSharper by language section.

Last modified: 19 November 2024