Dotnet logo

.NET Tools

Essential productivity kit for .NET and game developers


SourceLink, Consuming APIs, and NuGet Dependent Code in ReSharper and Rider 2019.3

Rider and ReSharper 2019.3 shipped last year already, but we still have a couple of features to tell you about! In this blog post, we will look at a few additions in the area of navigation. These include better support for SourceLink, a new Consuming APIs context navigation, and a Find Dependent Code action for NuGet packages. Without further ado, let’s see these new features in action.

Navigation and Debugging with SourceLink

The idea of SourceLink is to provide a first-class navigation and debugging experience for source code that doesn’t belong to our own codebase, such as NuGet package references. This is achieved by embedding additional information into so-called symbol packages. As a package author, here is a minimal example on how to support SourceLink for your packages:

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>


Each hosting provider usually has its own support package for making SourceLink integration smooth and easy. In this example, we are using Microsoft.SourceLink.GitHub. Probably, there will be one for JetBrains Space at some point, too :-) Also, there are a lot more configuration parameters to further tweak SourceLink support.

As a package consumer, life is much easier. Rider and ReSharper supported SourceLink v2 since version 2018.1, but we have now fixed a minor protocol bug to support browsing external source code with ease again. As a reminder, the endpoint is included by default, but the options Use sources from symbol files when available and Allow downloading symbols from remote locations should be enabled for symbols and SourceLink to work when navigating/debugging in external symbols:

Options for External Sources

We are still working on supporting SourceLink with private repositories that require authentication (RIDER-16260).

Finding Consuming APIs

We introduce a new member to the context navigation family: Consuming APIs. This search can be of great help while working with codebases that implement the CQRS pattern. Looking at the creation of an event, how can we efficiently navigate to all the message handlers that are handling this particular event? Invoke the Consuming APIs action:
Find consuming APIs

Thanks to Vladimir for bringing this use case to our attention!

Similar to its older brother Exposing APIs, the Consuming APIs search performs a Find Usage search, but excludes irrelevant symbols like type declarations (generics), constructors, or other new expressions.

Finding dependent code for NuGet references

Whenever feasible, we should consider swapping external library code with our own implementation. This has several benefits. Firstly, we are completely in charge. We can add new features or adapt to our own needs whenever we need. Also, we naturally avoid update issues and version conflicts and can introduce signing more easily. Secondly, and most importantly, we achieve the highest confidence in security, simply because we rely only on our own code!

ReSharper and Rider 2019.3 can help us to decide which NuGet package we may consider for removal. After browsing for a specific package in the Solution Explorer tool window, we can open the context menu for that item, and execute Find Dependent Code action in regards to the owning project:
Find dependent code for NuGet packages

In ReSharper we can even search for a package in context of the full solution by using Find Dependent Code in Solution. Subscribe to RIDER-35024 to stay up-to-date when this feature also gets supported in Rider.

Of course we can group search results in the usual manner. For instance, by project structure, namespace, type, file and combinations of those. However, even more importantly, we can filter results by various criteria, including direct and related usages:
Filter results by direct and related usages

Direct Usage includes code that will definitely break compilation if we remove the NuGet package reference. On the other hand, Related Usage covers code that is related to types from inspected package reference.

Jumping to relative and absolute locations

Last but not least, we addressed a small issue that allows jumping to directories and files by pasting their absolute or relative path into the Search Everywhere popup (RSRP-474817):
Goto relative and absolute paths

Windows users might want to watch RSRP-477646 for updates.

Download ReSharper 2019.3 or give Rider 2019.3 a try. Enjoy the new navigation features and tell us what you think. Every feedback is appreciated!

image description

Discover more