Using the .NET Reflector Power Commands
Published 15 January 2021
If you've tried the .NET Reflector 7.7 release, you'll notice some new commands have appeared across the program. These are the remains of the Power Commands we integrated into the tool in an earlier release. These commands could previously be enabled from the options menu, but they hadn't been worked on in a long time and had run into disrepair. Some were confusing and others were broken.
Here's a rundown of the updated commands and how to access them from within Reflector.
Collapse All Assemblies
There is now a command to Collapse All Assemblies in the File menu. Since we don't have a root node in the assembly browser (like a solution in Visual Studio has) this doesn't make sense in a context menu, so it's in the File menu for now. As Jason Haley put it when he originally wrote the Power Commands add-in: "This exposes the underlying tree view's CollapseAll method functionality which means it will collapse all expanded nodes that are currently open." It's great for when you have a ton of assemblies and you need to go back to the default state before you expanded them all.
Copy As
When viewing code for a class, type, property or field, you can now use the right-click context menu in the code window to copy all the code to the clipboard in a format of your choice. Note that for a class this will expand all the methods automatically, so in the picture above selecting "Text" will copy the entire ConcurrentBag <T> class to the clipboard.
Hopefully this will fix some of the issues where you need to quickly reproduce the code generated by Reflector, but were having problems with those pesky code hyperlinks. The original copy function is still there if you still want to copy a selection as well, and becomes available when you highlight a section of code.
Import/Export Assembly List
We're still looking at ways to improve our assembly list management functionality, but for now there's a way to save your assembly list setup by using the Export Assembly List command, and then load it back using Import. Perhaps you might want to do this as part of backing up your Reflector configuration, or to move between different computers with the same setup. Exporting opens another dialog where you can choose which assemblies from the lists to export, and save this as an XML file for later importing.
It's not immediately clear that importing won't make changes to the assemblies which are currently loaded into Reflector, only the assembly lists. So once you've imported your assembly lists you will still need to Open Assembly List and select the list you want to load into Reflector.
Open File Location
This opens an explorer window at the location on disk where the assembly can be found. Useful for when you quickly need to get to the DLL or EXE so you can manipulate the file outside of Reflector.
Open With
At several levels in the assembly browser there's an option to open the selected item with an application of your choice. Separate commands for common applications formed a large proportion of the original Power Commands add-in, so we've distilled these into default applications for one larger Open With command.
This means slightly different functionality for different levels in the tree. Notably, code snippets are written to a temporary file (using the Copy As function described earlier, but writing to a file instead of the clipboard) so they can be opened, and resources are extracted before they open normally. Resource tables are opened in Visual Studio as .RESX files so they can be viewed more easily. And assemblies open as expected.
Selecting Choose Application will bring up a dialog where you can add your own applications. Adding an application to the list will save it so that next time you select Choose Application you will be able to select the desired application faster.
Open Zip
Did you know you can drag a .ZIP archive into Reflector and it will decompile the compressed assemblies without you having to extract them yourself? This was originally a Power Command, but while looking for ways to merge the code I discovered native functionality in Reflector for opening Silverlight applications (XAP files) which could be easily extended to handle .ZIP archives as well. You can also select .ZIP archives now from the drop down menu in the Open Assembly dialog, and open them through the menu.
Referenced By
The analyzer now contains the functionality to show which of the assemblies loaded into Reflector depend on the selected assembly or module. This means you can now check dependencies both ways: from the assembly browser for references of the current assembly, and from the analyzer for assemblies referencing the current assembly.
At the moment the analyzer will only show the list of assemblies. But if it's useful, it might be an exciting possible improvement for the future to attempt to show the code which calls into the current assembly by making the analyzer tree expandable to show the classes and methods which do this! That way you will be able to see not only where your assembly is being used, but also how it is being used by other assemblies.
Other Power Commands
If you were previously familiar with the Power Commands in the options menu and there was one you frequently used which I haven't detailed here (for example the Query Editor) then don't panic. We've packaged up a few of the other useful commands and plan on releasing a new Power Commands add-in with the final release of 7.7. This will put the option to enable the extra commands back into the options menu so you can select them from there.
The reason we opted for this approach was to streamline the application to remove those commands which would only be used in niche cases. We really wanted to get rid of the option to enable/disable the Power Commands, as discoverability was really low while they were turned off by default. These commands didn't seem valuable enough to be always enabled in Reflector, but still worked to the point where people might use them, so a separate add-in seemed best.
As always, we're constantly looking for feedback and feature requests! If there are any new commands you'd really like to see in the next version of Reflector then there are the usual channels: the forums or info@reflector.net