Inline parameter name hints for C# and VB.NET in ReSharper and Rider

Posted on by Maarten Balliauw

When editing code in the latest builds of ReSharper 2018.3 EAP and Rider 2018.3 EAP,  the inline parameter hints for C# and VB.NET are something you will notice immediately. Let’s see how this new feature makes code more readable, and how we can configure it.

What are inline parameter hints?

When using a literal in a method call, ReSharper and Rider will annotate those with the name of the parameter. This makes it much easier to understand what their value represents.

For example, we can see that the string literal "\\s" here, represents the pattern of a regular expression:

Example of inline parameter hints

When hovering an inline parameter hint in ReSharper, we’ll also display XML documentation when available:

Display XMLDoc on hover

One place where inline parameter hints become very useful, is when passing in null values or booleans. What do the null and false arguments represent here?

var people = peopleService.Find("Maarten", null, false);

The meaning of these becomes clear immediately when using inline parameter hints, without having to rely on using named arguments for readability:

Inline parameter hints for null and boolean values

When are inline parameter hints shown?

Generally speaking, ReSharper and Rider will display inline parameter hints for literals and null values, lambda and array expressions, anonymous methods and object creation expressions, constants and enumeration values.

ReSharper and Rider do not display inline parameter hints for all literals and null values, however. Many base class library (BCL) methods have an obvious name and functionality, and displaying inline parameter hints would not improve readability for these.

For example, in the following cases, the meaning of all parameters becomes clear from looking at their usage:

No parameter hints when obvious or natural

Showing (or not showing) inline parameter hints can be configured in ReSharper’s settings, under Environment | Editor | Parameter Name Hints. Similarly in Rider, we can configure these under Editor | Parameter Name Hints | C# and Visual Basic .NET.

Configuring inline parameter hints

Disable inline parameter hints can be done from the settings as well. A quick way to enable/disable parameter hints is by using the status indicator context menu:

Status indicator context menu

In some cases, it may be useful to disable inline parameter hints for a certain method call. This can be done using the Configure Parameter Name Hints action (Alt+Enter):

Configure Parameter Name Hitns - Hide for specific method

Once applied, the method will be added to the exclude list in the settings:

Do not show parameter hints for method - exclude list

If we want to re-enable parameter hints for the Regex.Split() method, we can drop the entry from this list. We could also expand the entry here, and add additional namespaces and methods where inline parameter hints should be disabled.

Download ReSharper 2018.3 EAP or Rider 2018.3 EAP and give it a try! We’d love to hear your feedback!

Comments below can no longer be edited.

33 Responses to Inline parameter name hints for C# and VB.NET in ReSharper and Rider

  1. Sc0tTy says:

    November 27, 2018

    Sounds like a great feature!

    Currently we use named parameter when calling a constructors.
    Could an option be added to show parameter names (or hints) regardless of the type of the argument but based on the type of call, like constructor or method?

  2. Dew Drop - November 28, 2018 (#2848) - Morning Dew says:

    November 28, 2018

    […] Inline parameter name hints for C# and VB.NET in ReSharper and Rider (Maarten Balliauw) […]

  3. Varun Sharma says:

    December 18, 2018

    This is a great feature, Kudos to the person/team who came up with this idea. Nice.

  4. Jan Duchacek says:

    December 19, 2018

    Hello,
    I found this very distractive, so I wanted to turn it off. However in Visual Studio 2018 Professional this option is not avalilable. In Options->Editor I have only Parameter Name Hints which does not have affect on Inline hits.

    Please point me to right direction how to turn it off.
    Thank you

    • Maarten Balliauw says:

      December 19, 2018

      Right-click a hint, then hide everywhere should do the trick

      • Jan Duchacek says:

        December 20, 2018

        Right-click did the trick. After that even Parameter Name Hints started to work. However you should fix the post since no Inline Hints exists in VS ReSharper options. It is very confusing.
        Thank you

        • Maarten Balliauw says:

          December 20, 2018

          The text was OK, now have updated the screenshots as well.

  5. Ben Page says:

    December 19, 2018

    These look pretty terrible on a dark theme.

    • Markus Jarderot says:

      December 20, 2018

      Changing the background in Tools -> Options -> Environment -> Fonts and Colors -> ReSharper Parameter Name Hint makes them more subtle, and blend into the background.

      • Filias says:

        January 7, 2019

        I found this. But what I didn’t found is text color in tooltip window. It is some dark blue 🙁

  6. Konrad says:

    December 27, 2018

    This is a great feature but now text-selecting parameter feels weird. When I try to select parameter from right to left and stop before hint then first character from parameter is not selected. I need to go with cursor to the middle of parameter name to select first letter.
    Also double clicking on parameter name could text-select whole parameter so it could be changed or copied.

    • Andrew Vasilyev says:

      December 28, 2018

      Hello, Konrad! Thanks for feedback.
      This is a known issue (https://youtrack.jetbrains.com/issue/RSRP-472756).
      It is already fixed and will be out in 2018.3.2 (mid-January).

    • Will says:

      January 4, 2019

      Thank god I’m not the only one who’s struggling with this. Right now I’ve disabled this feature because it’s insanely frustrating trying to text-select values with a parameter name hint on the left. You basically can’t do it with the mouse at all as the selection stops at the character before the hint (usually a double-quote if it’s a string literal).

      I don’t even think it’s a particularly useful feature but it won’t be getting enabled again until they sort this bug out (not sure how it made it out of testing like that, it cripples usability)

  7. Matt H says:

    January 8, 2019

    These are great, if you find the right set of options…. Where they don’t work so great are inside of .cshtml (Razor) files. Making changes to a single line causes all calls to @Html.Helper methods to re-synchronize. They “flash”–removing all hints for a few seconds and then adding them back in, which causes the display to sort of jump around. It gets pretty annoying, especially if there are a lot of @Html calls. Is there a way to turn off this feature by a specific file type?

    • Maarten Balliauw says:

      January 8, 2019

      You could try disabling them for the HtmlHelper class entirely? (blacklist much like the Regex example from this post)

  8. E says:

    January 8, 2019

    Interesting feature, but I am finding that the hints are killing VS 2018’s performance.

  9. SharpCoder says:

    January 15, 2019

    Horrible feature… just makes the code harder to read. Turned off immediately.

    • artyom says:

      February 4, 2019

      Fully agree. And I spent 15min to turn it off.

      • Maarten Balliauw says:

        February 4, 2019

        Right-click a hint, then “Turn off everywhere” should do the trick.

  10. Anang Satria says:

    February 1, 2019

    While it helps us to identify what is the parameter being passed but this feature makes my short method call looks very long and ugly. 🙁

    • Maarten Balliauw says:

      February 4, 2019

      You can right-click them and disable hints for that specific call.

  11. Tim Van Holder says:

    February 1, 2019

    Is there a way to turn them off for a particular block of code (like //@formatter: on/off for formatting)?

    In general they are nice, but when you have a large switch statement, with single-line cases, these hints kill any attempt at having nicely aligned, readable code.

    Also: configuring this in Rider (adding an exclusion pattern) does not put anything in the solution’s DotSettings file, despite the “For current solution” indicator on the settings pane. Not even when explicitly saving to the team-shared solution settings.

  12. Nick Gerrie says:

    August 7, 2019

    Thanks for showing how to turn this off, such an annoying feature. I spent hours trying to find the off switch.

  13. Sebastian says:

    November 17, 2019

    Where can I find the “status indicator context menu” or how to open it?

    • Maarten Balliauw says:

      November 18, 2019

      Hi Sebastian, that would be the icon in the top-right corner of the editor (an green square, an exclamation mark or a red circle, depending on the number of warnings and errors in the file)

  14. Anders says:

    January 23, 2020

    Who is passing null or flags to methods?

Subscribe

Subscribe to .NET Tools updates