Type Dependency Diagrams in ReSharper 9
In ReSharper 8, we introduced the concept of Architecture Tools as ways of visualizing the state of module dependencies in your solution. In ReSharper 9, we have augmented these tools with an ability to visualize class dependencies too.
Dependencies between types are shown on a Type Dependency Diagram. You can make one by selecting any node from the Solution Explorer (you can pick a file, folder, project or the whole solution) and choosing Show Type Dependency Diagram. You will see something similar to the following:
In addition, sometimes you need to investigate which external modules you depend on. In this case, you can once again open Solution Explorer, but this time pick a couple of references, right-click and choose Show Usages on Diagram in order to see how your code depends on the selected modules.
This yields the following diagram:
Just as with the project dependency diagram, arrows are used to indicate the dependence of one type on another, and the width of the line indicates the relative number of usages of one type from another. The diagram is capable of showing usages, aggregation, inheritance relationships, return type usage and even the use of constructor injections.
Both the types and the lines connecting them show additional navigation options if you hover the mouse over them. In the case of the types, you get to see the references and usages, with plenty of navigation hyperlinks:
Edge-related popups are similar, showing the usages:
It is also possible to collapse the groups in which the particular types are shown. If you do, the popup for the collapsed group will show how all the types inside this group depend on some external module.
It’s important to note that the diagram is very flexible in terms of content. Some of the things it supports are:
- Component removal: simply select a type and press Delete to get rid of it. The diagram will fluently readjust itself.
- Types can be added via simple drag-and-drop: grab an element on the Solution Explorer, drag it onto the diagram, and you’re done. Also, as an added bonus, you can select a class name right in the text editor and drop this onto the diagram canvas to add the desired class!
- Types can also be added if you simply start typing right on the diagram. This will result in a search (similar to Go to Type) and, after you pick a particular element, that element will be added to the diagram.
- You can also filter out particular types of elements:
- You can drag an element on the type diagram to a different folder or project. This will automatically invoke the Move refactoring.
The right side of the diagram also contains the controls for zooming and panning, but also has two large buttons for controlling the layouter that’s used for the diagram, and they both cause the graph to be laid out in a specific way.
The Inheritance Hierarchy Layouter is more suitable for one big inheritance hierarchy, whereas the Business Logic Layouter is better for a set of non-derived but dependent modules. ReSharper generally tries to automatically determine which layout is better, but you are always at liberty to change the setting.
We hope you enjoy this functionality. If you haven’t got yourself a copy of ReSharper 9 already, a 30-day trial awaits.
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…