Inline parameter name hints for C# and VB.NET in ReSharper and Rider
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:
When hovering an inline parameter hint in ReSharper, we’ll also display XML documentation when available:
One place where inline parameter hints become very useful, is when passing in
null values or booleans. What do the
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:
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:
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.
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:
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):
Once applied, the method will be added to the exclude list in the settings:
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.
Subscribe to Blog updates
Thanks, we've got you!
Eager, Lazy and Explicit Loading with Entity Framework Core
Entity Framework Core (EF Core) supports a number of ways to load related data. There’s eager loading, lazy loading, and explicit loading. Each of these approaches have their own advantages and drawbacks. In this post, let’s have a quick look at each of these ways to load data for navigational prope…
OSS Power-Ups: bUnit – Webinar Recording
The recording of our webinar, OSS Power-Ups: bUnit, with Egil Hansen and Steven Giesel, is available. This was the twelfth episode of our OSS Power-Ups series, where we put a spotlight on open-source .NET projects. Subscribe to our community newsletter to receive notifications about future webi…
Accelerating Your Testing Workflow with Unit Test Creation and Navigation
Unit tests play an important role in our daily development workflow. They help us ensure our codebase's correctness when writing new functionality or performing refactorings to improve readability and maintainability. In the process, we often create new test files that accompany the p…
Introducing Predictive Debugging: A Game-Changing Look into the Future
With the introduction of debugging tools, software developers were empowered to interactively investigate the control flow of software programs to find bugs in live environments. At JetBrains, we've always strived to improve the art of debugging. Besides the more standard things you expect from a de…