Pretty Good UML

Diagrams of what your C# code actually does.

Pretty Good UML reads your solution with the compiler and draws it: the path of a request through your code, what it can throw, and what a change did to that path. In VS Code while you work, and on every pull request.

Sequence diagram of an endpoint PUT /workspaces/{workspaceId}/tickets/{ticketId}
CallerTicketsControllerValidationBehaviourAuthorizationBehaviourUpdateTicketCommandHandlerApplicationDbContextTicketUpdateTicketAsync()Send UpdateTicketCommandvalidate Title NotEmpty, MaximumLength(200)validate Description NotEmpty, MaximumLength(2000)break[failures.Count != 0]400 ValidationExceptionnext()break[!currentUserContext.IsAuthenticated]401 UnauthorizedAccessExceptionWorkspaceMember.FirstOrDefaultAsync()break[membership is null]403 ForbiddenExceptionHandle()Ticket.FirstOrDefaultAsync()break[ticket is null]404 NotFoundExceptionbreak[!isCreator && !isPrivileged]403 ForbiddenExceptionUpdate()break[Status == TicketStatus.Closed]409 DomainStateExceptionSaveChangesAsync()
Drawn from a real solution, shortened here: the logging and permission steps and two validation rules are left out. Each break is a way the request can fail, with its condition and the HTTP status the exception middleware gives it.

In your editor, for any part of the solution

Open the Pretty Good UML view in VS Code, click an endpoint, class, method or changed file, and the diagram opens in a tab. Mermaid or PlantUML, with export to PNG, SVG and PDF.

The Pretty Good UML view in VS Code: overview diagrams, then the classes, APIs, methods and usecases of the solution grouped by project.
The Pretty Good UML view, on a real solution.
Sequence diagram of an endpoint
The path of a request from the controller to the database, with validation rules, every failure path and the response.
What an uncommitted change did
The difference between your working tree and HEAD, as a sequence, class or activity diagram.
Class diagram
A class with its properties, methods and neighbours: what it uses, what it holds, what it inherits.
Database diagram
An entity-relationship diagram from your DbSets, and a component diagram of the projects.
Activity diagram of a method
Its control flow: conditions, loops, calls and exits.
Usecase view
A handler with its actor, database and external systems.

Install Pretty Good UML for VS Code. It is free and works without an account.

On a pull request: what the change did

A diff shows which lines changed, not which endpoints now behave differently. In this pull request, two guards were added to the Ticket entity. Four endpoints pass through it. For two of them no controller and no handler was touched, so nothing in the diff points at them.

Pretty Good UML commented on this pull request PATCH /workspaces/{workspaceId}/tickets/{ticketId}/assign
  • New call AssignTicketCommandHandler → ApplicationDbContext: AnyAsync
  • New failure 404 NotFoundException when !isWorkspaceMember
  • New call AssignTicketCommandHandler → ApplicationDbContext: CountAsync
  • New failure 409 ConflictException when activeTickets >= MaxActiveTicketsPerAssignee
  • New failure 409 DomainStateException when IsArchived, in Ticket
CallerTicketsControllerAssignTicketCommandHandlerApplicationDbContextTicketAssignTicketAsync()Send AssignTicketCommandTicket.FirstOrDefaultAsync()break[ticket is null]404 NotFoundExceptionadded AnyAsync()break[!isWorkspaceMember]added 404 NotFoundExceptionadded CountAsync()break[activeTickets >= MaxActiveTicketsPerAssignee]added 409 ConflictExceptionAssign()break[IsArchived]added 409 DomainStateExceptionSaveChangesAsync()
The comment for one endpoint, shortened here: the full diagram also draws the validation and authorization steps in front of the handler. Green is what the pull request added; removed calls are red and changed ones yellow.

The same change, across the solution

src/Domain/Tickets/Ticket.cs
  public void ChangePriority(TicketPriority priority, Guid by)  {      EnsureTicketIsEditable();+     EnsureNotArchived(); + private void EnsureNotArchived()+ {+     if (IsArchived)+         throw new DomainStateException(...);+ }
  • PUT/tickets/{ticketId}Handler unchanged. New failure: 409 when the ticket is archived.
  • PATCH/tickets/{ticketId}/priorityHandler unchanged. New failure: 409 when the ticket is archived.
  • PATCH/tickets/{ticketId}/assignHandler changed too. Both changes are in one diagram: the comment above.
  • POST/tickets/{ticketId}/commentsHandler changed too. New failure: 409 when the ticket is closed.

Add it to your pull requests

One comment per pull request: the endpoints whose behaviour changed, and a diagram for each. It runs in the pipeline you already have. Your code is analysed on your own runner and is never uploaded.

  1. Add one workflow file

    Paste the snippet below into .github/workflows/uml.yml and put in the path to your solution.

  2. Open a pull request

    The tool compares the branch with its base and follows every endpoint through your code, before and after.

  3. Read the comment

    Endpoints whose behaviour changed, what changed in each, and a diagram. Later pushes update the same comment.

name: UML diff
on:
  pull_request:
permissions:
  contents: read
  pull-requests: write
jobs:
  uml-diff:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
      - uses: actions/setup-dotnet@v5
        with:
          dotnet-version: 10.0.x
      - run: dotnet restore MySolution.sln
      - uses: gaumengangster/pretty-good-uml@v1
        with:
          solution: MySolution.sln
          license: ${{ secrets.UML_LICENSE }}   # private repositories only

Building with Azure Pipelines, or something else? The same tool is a .NET tool on NuGet: dotnet tool install PrettyGood.Uml. Steps for Azure Pipelines are in the GitHub repository.

It reads your code the way the compiler does

No AI and no tokens. The same code always gives the same diagram, and a call it draws is a call that exists.

Endpoints
Controllers, minimal APIs (including lambda handlers and route groups) and FastEndpoints.
MediatR and Mediator
Send is followed through the pipeline behaviours, in the order they are registered, to the handler.
Validation
The FluentValidation rules of the request, such as Name NotEmpty, MaximumLength(100).
Failure paths
Every throw, with its condition and the HTTP status your exception middleware maps it to.
Database calls
Entity Framework queries, drawn as one call on your DbContext.
Domain events
An event is followed to its notification handlers.

Free in the editor and in the open. A licence for private pull requests.

Only pull request reports on private repositories need a licence: a key you store as the secret UML_LICENSE. Without one, the report still lists the affected endpoints and shows the first in full.

Editor and public repositories

€0
No key, no sign-up
  • The VS Code extension, every diagram
  • The command-line tool on your own machine
  • Pull request reports on public repositories
Install for VS Code

One private repository

€39
per year
  • The full report on every pull request
  • One private repository
  • GitHub Actions or Azure Pipelines
Buy a repository licence

Organization

€149
per year
  • The full report on every pull request
  • Every private repository of one GitHub organization or user
  • GitHub Actions or Azure Pipelines
Buy an organization licence

It never blocks a pull request. If the tool fails, or a licence is missing or has expired, the step still succeeds and the pull request stays mergeable.

Questions

Does my code leave my machine?

No. The analysis runs in your editor or on your own runner. When a pipeline presents a licence key, the tool makes one request to our licence server with the licence id, the repository owner's name and the tool version. Public repositories and local runs make no request.

Which code does it understand?

C# on .NET 8 or later. It is tested mostly on solutions that use MediatR or Mediator with Entity Framework Core; patterns it has not seen may give a shorter diagram.

What does it not draw?

Authentication and authorization attributes, middleware and Entity Framework interceptors. A change inside a pipeline behaviour does not mark the endpoints behind it as changed, and deleted endpoints are not reported.

Is this what happens at run time?

It is static analysis: it shows what the code can do, not what happened in one request. When an interface has several implementations, it picks the one it finds.

Can I try it without a pull request?

Yes: pretty-good-uml diff --project MySolution.sln --base origin/main writes the same report to a file on your machine.

Mermaid or PlantUML?

Both in the editor. Mermaid renders inside VS Code with nothing to install; PlantUML needs a PlantUML server for the preview. Pull request reports use Mermaid, which GitHub draws in comments.