Johan Åhlgren

Generating class relationship diagrams

For a long time now, I have wanted an easy way to generate class relationship diagrams for my (far too many) hobby projects. I have created an application that looks at my source code – using the Syntax API in the Roslyn compiler platform – and emits a text file describing the structure in the PlantUML (www.plantuml.com) format.

The output file contains associations between classes and interfaces as well as inheritance hierarchies. It is easy to use – run the application, passing it a directory as the only parameter. The application will analyze all code found in that directory and its subdirectories and produce the resulting PlantUML file. The file will be named uml.plantuml and placed in the root directory. To view the files, I have installed the PlantUML Viewer plugin for Chrome. Now, I can open the resulting files in Chrome and immediately see the result:

diagramgenerator

More work will be done. I currently improve the solution so that the output becomes configurable. To see all classes in the same picture works for a small project such as this but not for larger projects.

The code can be downloaded here.

Leave a Reply

Your email address will not be published.