ReSharper 2020.1 Help

Inlay Hints

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

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 understanding arguments in a method call

The idea of the parameter name hints is to automatically 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.

Missing constructs hints

ReSharper 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 enable or disable these hints using the Show missing constructs as editor hints checkbox on the Code Inspection | Settings page of ReSharper options (Alt+R O).

Configure parameter name hints

You can toggle and configure parameter name hints on the Environment | Editor | Inlay Hints page of ReSharper options (Alt+R O). Use Show inlay hints to toggle the hints, and then optionally use other controls to specify where the hints should be shown or hidden:

Parameter Name Hints
Show parameter name hints Lets you enable or disable parameter name hints .
Hide for non-literals Hides parameter name hints for arguments that are variables, resources, expressions, or invocations allowing you to configure exceptions for specific kinds of non-literal arguments.
Hide for builder-like methods Hide parameter name hints for methods similar to methods of System.Text.StringBuilder, which return a modified object of their containing class. Names of such methods normally make clear the purpose of their parameters.
Hide if method parameters only differ by numbered suffix Hides parameter name hints when calling methods with signatures similar to
void DoSomething(int arg0, int arg1, int arg2, int arg3) {/*...*/}
Hide if intention of first parameter is clear from method name Hides parameter name hint on the first argument when calling methods with signatures similar to
void SetExtension(string extension, object next) {/*...*/}
Hide if intention of argument is clear from usage For methods with signatures similar to
void DoSomething(int value, object context) {/*...*/}
hides the value parameter name hint if the method is called like so
DoSomething(myValue, context: null);
You can configure a list of method patterns for which the parameter name hints will be always hidden, independently of other preferences.

Patterns are matched against fully qualified method name, parameter count, and parameter names. For example:

  • 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 key and value

Type Name Hints
Use compact type name presentation

Sometimes type names can be too long. For example, an anonymous type with a few fields will look like this:

ReSharper: Inlay hints. long type name

When this option is enabled, a shortened type name is displayed in the hint. You can hover the mouse over the hint to see the full type name.

ReSharper: Inlay hints. compact type name
Show method return type name hints

Use this option to enable or disable type name hints for return types of methods in a call chain. These hints will appear after methods if the next method in the chain is written in a new line:

ReSharper: Inlay hints return type in call chain

Use child options to configure exceptions and presentation for this kind of hints.

Show type name hints for implicitly typed variables

Use this option to show or hide type name hints for vars.

The child option Hide if type of variable is evident is enabled by default so that hints of this kind will not appear where they are not necessary for understanding the type. To learn more, which cases ReSharper considers evident, see Use 'var' when evident: what is considered evident?.

Show type name hints for pattern matching expressions

Use this option to show or hide type name hints for vars, recursive patterns, and tuples in C# pattern matching expressions. For example:

ReSharper: Inlay hints. pattern matching
Show type name hints for lambda expression parameters

This option enables type name hints after parameters of lambda expressions.

ReSharper: Inlay hints. lambda expression parameter

The child option Hide if types of parameters are evident is enabled by default so that hints of this kind will not appear where they are not necessary for understanding the type. To learn more, which cases ReSharper considers evident, see Use 'var' when evident: what is considered evident?.

Show type name hints for query range variables in LINQ queries

This option enables type name hints in LINQ expressions.

ReSharper: Inlay hints in LINQ expressions
Hide if type name is evident from variable name This option hides parameter hints in cases similar to the following one:
ReSharper: Inlay hints in evident cases

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),

  • disable inlay hints 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

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 of inlay hints 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.NETLanguage: C++Language: HTMLLanguage: ASP.NETLanguage: RazorLanguage: JavaScriptLanguage: TypeScriptLanguage: CSSLanguage: XMLLanguage: XAMLLanguage: ResxLanguage: Build ScriptsLanguage: ProtobufLanguage: JSON

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by Language section.

Last modified: 22 June 2020