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.
PUT /workspaces/{workspaceId}/tickets/{ticketId}
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.
- 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.
PATCH /workspaces/{workspaceId}/tickets/{ticketId}/assign
- New call AssignTicketCommandHandler → ApplicationDbContext:
AnyAsync - New failure
404 NotFoundExceptionwhen!isWorkspaceMember - New call AssignTicketCommandHandler → ApplicationDbContext:
CountAsync - New failure
409 ConflictExceptionwhenactiveTickets >= MaxActiveTicketsPerAssignee - New failure
409 DomainStateExceptionwhenIsArchived, in Ticket
The same change, across the solution
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.
Add one workflow file
Paste the snippet below into
.github/workflows/uml.ymland put in the path to your solution.Open a pull request
The tool compares the branch with its base and follows every endpoint through your code, before and after.
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
Sendis 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
- The VS Code extension, every diagram
- The command-line tool on your own machine
- Pull request reports on public repositories
One private repository
- The full report on every pull request
- One private repository
- GitHub Actions or Azure Pipelines
Organization
- The full report on every pull request
- Every private repository of one GitHub organization or user
- GitHub Actions or Azure Pipelines
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.