Better Programming

Advice for programmers.

Follow publication

Generating Class Diagrams for .Net Core

Use PlantUML directly in the Visual Studio Code

Edson Moisinho
Better Programming
Published in
4 min readApr 8, 2022

Class diagram generated in Visual Studio Code

UML Class Diagrams are a very great way to document your system, inspect and understand the relationships between the classes and plan refactorings and disseminate knowledge inside the team.

Although having class diagrams brings many benefits, generating them manually is a painful and arduous task, fortunately, we can use tools to generate them automatically

If you’re not a Medium paid member, you can read this story for free using the following link

Visual Studio Class Designer

The Visual Studio Class Designer is a great and very flexible tool to generate class diagrams, it allows drag and drops on a single or in multiple .cs files directly to the diagram, and it automatically syncs changes both in the .cs files or in the diagram.

As we can see, using the Class Designer has many advantages but unfortunately, it does not exist in the Visual Studio Code and even in the Visual Studio, it does not support .Net Core.

PlantUML

PlantUML is an open-source tool that allows generating many types of UML diagrams from plain text, it uses a specific language and you can learn and start creating your diagrams in many different editors.

Fortunately exists many extensions and add-ons that automatically generate PlantUML from source code, in the next section I will show how to generate the PlantUML and the diagrams using C#.Net Core directly in Visual Studio Code.

Creating the example classes

In order to generate the diagrams, I will create a few components like classes, interfaces, enum, public and private properties, constructors, and constants.

I am creating these components just to exemplify how the generating diagram tool works, so please do not pay attention to the classes and their content.

Base classes, interface, and enum:

Mammal, Dog, Cat classes and IHunt interface

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Edson Moisinho
Edson Moisinho

Written by Edson Moisinho

A Software Engineer writing about programming, technology, and lifestyle

Responses (2)

Write a response