Sightline

A live map of your .NET solution

Sightline reads your code and draws how it fits together: projects, dependency injection, endpoints, and the path each request takes down to the database. Change the code and the map changes with it.

dnx Co.Revington.Sightline

Run it in a folder with a .sln and the map opens. Nothing gets installed. Needs the .NET 10 SDK. Version 0.2.0 on NuGet, free and open source under the MIT license.

Try it here, nothing to install

This is the real interface, running in your browser on a recording of the sample shop solution from the repository.

Loading the demo. Open it full screen

Three questions it answers

What is in this solution?

Map. Every project is a zone. Lines between zones show which project uses which, and how often. Open a zone to see its namespaces and types.

What happens when this endpoint is hit?

Flow. Pick an endpoint and read the request as numbered steps: handler, services, repositories, then the database or an outbound HTTP call. A call on an interface continues in the class registered for it.

What breaks if I change this class?

Focus. One type in the middle, between everything that uses it and everything it uses. That includes callers that only reach it through an interface.

What it finds in your code

The map uses one line style per kind of relationship. This is the legend, and also the list of what Sightline detects.

Calls
One method calls another, inside a project or across projects.
Injects
A constructor asks for a service. Primary constructors and minimal API handlers count too.
Resolves to
The class your dependency injection setup gives for an interface, with its lifetime.
Sends a message to
A Send or Publish reaches the handler for that message, MediatR style.
Database access
Entity Framework Core sets that are read or written, and where changes are saved.
Outbound HTTP call
Requests your code makes with HttpClient.
Project reference
Labelled with how many real uses stand behind it. A reference that nothing uses is flagged.
GET
Endpoints
Controller actions, minimal APIs with the route prefixes of their groups, SignalR hubs and gRPC services.
CIR
Types
Classes, interfaces, records, structs and enums, listed per namespace inside their project.
scoped
Service lifetimes
Scoped, singleton and transient registrations, hosted services, typed HTTP clients and options classes.
handler
Roles
Controllers, message handlers, database contexts, background services, hubs and middleware are marked as such.
10.0.15
Packages
The NuGet packages each project references, with the versions that were actually restored.

It follows your edits

Type in the code panel and the map updates before you save. The unsaved text is analyzed in memory, and nothing touches your file until you choose Save file.

Prefer your own editor? Keep it. Save a file in Visual Studio, Rider or VS Code and the map follows. With auto-save on, it follows as you type.

A strip at the bottom of the page reports what each edit changed. For example:

GetOrder.cs + GetOrderHandler.Handle calls IOrderRepository.SaveAsync

On the sample solution an edit reaches the map in well under a tenth of a second. Larger solutions have not been measured yet.

Set it up for your team

Do it once in your repository. Everyone who clones it then gets the same version and the same settings, with nothing to install by hand.

  1. Set up the solution

    dnx Co.Revington.Sightline init

    Run it in the folder with your .sln. It pins Sightline in dotnet-tools.json, writes sightline.json, and adds a VS Code task when the folder uses VS Code.

  2. Open the map

    dotnet sightline

    Works from any folder in the repository. Packages are restored first when needed. Press / in the map to find a class, method or endpoint.

  3. Share it

    Commit dotnet-tools.json and sightline.json. Teammates run dotnet tool restore once, then dotnet sightline.

Settings live in the repository

sightline.json names the solution to open and the projects to leave off the map, such as tests or samples that would crowd it. Editors that read JSON schemas suggest the settings as you type.

Just for yourself? dotnet tool install --global Co.Revington.Sightline, then run sightline in any solution folder.

sightline.json{
  "$schema": "https://sightline.revington.co/sightline.schema.json",
  "solution": "Shop.sln",
  "exclude": ["*.Tests", "samples"]
}

What it does not do yet

  • It reads C# in SDK-style projects only.
  • The analysis is static. Reflection, assembly scanning such as Scrutor, and generated code are not followed.
  • FastEndpoints, Carter and Razor Pages endpoints are not recognised.
  • Property reads and writes are not counted as calls.
  • It has been tested on small solutions. Speed on large ones has not been measured.

Your code stays on your machine

Sightline runs locally and sends nothing anywhere. Its page is served on localhost only, every request needs a token created at start, and only files that belong to the loaded solution can be read or saved.

Read the source on GitHub