Copy Code Reference in ReSharper and Rider 2021.3 EAP
Copy/paste is probably the most used action by anyone using a computer. But how do you copy the thing you want to copy? Say you are in a method in the editor – how do you copy a link to the current line on GitHub? Or copy the current namespace, class name, or method name to the clipboard?
ReSharper and Rider keep you in the flow of coding, without having to jump through hoops to copy this information. With the reworked Copy Code Reference action (previously Copy FQN), you can easily point your fellow teammates to the code you’re talking about and be more productive when writing XML documentation. Most importantly, the action now supports custom URI patterns to integrate with your services of choice. Let’s take a closer look!
Look and Feel
As already mentioned, the action is now available under a new name: Copy Code Reference. If you’re a shortcut person, you can re-apply your keyboard schema (ReSharper | Options | Environment | Keyboard | Shortcut Scheme) and use
Ctrl+Shift+Alt+C. Alternatively, you can trigger the action from the Edit menu or by searching the
Since changing muscle memory can be hard, you can still find it using ‘FQN’ in
The first item in the list is immediately copied to the clipboard, so you can confirm either by pressing Enter or Escape. More importantly, the items now have dedicated icons to reflect what information they represent. There are icons for namespaces, types, members, and files.
Now you have the choice to pick the format that works best for your use case. For instance, when you want to point your fellow developers to a symbol, you can pick either the fully-qualified name or File:Line item to allow them to navigate with Search Everywhere in ReSharper and Rider. If they should just take a quick look or are on their phone and don’t have their IDE available, the GitHub links based on the branch or commit SHA may also work. Last but not least, when you’re writing XML documentation, you can copy the fully-qualified XML-Doc ID and paste it where it belongs:
Also good to know for Rider users – you can start typing to filter the result set:
Adding Custom URI Patterns
Not all repositories are hosted on GitHub, so we have also added a new Source Browsing options page that allows you to add custom URIs to the list of targets to pick from. The options page can be opened via the last item from the Copy Code Reference action, or through the ReSharper options (Environment | Search & Navigation). The following image provides a few examples:
For custom URI patterns and their titles, you are free to use any number of macros that we provide, including:
|Path to file relative to the solution|
|Path to file relative to the project|
|Git: Path to file relative to the Git root|
|Filename with extension|
|First selected line|
|Last selected line|
|Output assembly name of the current project|
|JetBrains Upsource selection range|
Remember that it’s a good idea to save your custom URIs to the team-shared layer and commit them to the repository to let your whole team benefit from them!
We hope that you will make good use of the new Copy Code Reference action to be more flexible when sharing your context or writing any kind of documentation! Give it a go with the latest ReSharper or Rider EAP and let us know what you think!
Subscribe to Blog updates
Thanks, we've got you!
Recordings from JetBrains .NET Day Online ’23 are available
On September 26, we hosted a free virtual event – .NET Day Online ’23. This was the fifth annual edition of the conference, and we were absolutely amazed at how lively the conversation was! We’d like to extend a huge thank you to the wonderful speakers who joined us to share their passion for the wo…
A Second Set of Bug Fixes: ReSharper 2023.2.2 and Rider 2023.2.2 Are Here!
ReSharper and Rider have just received their second set of bug-fix updates for the 2023.2 release! Let’s take a look at the most important issues that have been resolved in this update. ReSharper For the full list of resolved issues, please refer to our issue tracker. …
ReSharper 2023.3 Early Access Program Begins!
Hello everyone, The Early Access Program for ReSharper 2023.3 has started! Before you download the first EAP build, let’s take a look at what is in store for you. Working with aliases With this first EAP build, we are introducing support for C# 12’s ability for alias directives to refer…
Rider Kicks Off the Early Access Program for the 2023.3 Release!
The Early Access Program for Rider 2023.3 has just begun with the release of the Rider 2023.3 EAP 1 build. There are several ways to get your hands on it: Download and install them from our website. Use the Toolbox App. Install this snap package from the SnapCraft store if you’re using a c…