I needed to understand a large legacy .NET codebase — so I built a tool for it
Source: Dev.to
Background
I’m a .NET developer, and lately I’ve been slowly open‑sourcing some of the small tools I built for myself over time. One of those tools was created to help understand a large legacy .NET 4.6 application (~15 years old, 1 M+ LOC).
The Problem
I needed a way to grasp the architecture beyond just reading the code:
- What depends on what
- Where things are going in the wrong direction
- If there are hidden cycles
Navigating the code is possible, but getting a real picture of how everything is wired together isn’t easy. Existing powerful tools are expensive, and the free ones felt limited for my needs.
Early Attempts
I considered building my own solution, experimented a bit, then set it aside. When I revisited the idea, I ran into several practical issues:
- SDK differences
- MSBuild resolution problems
- Projects not loading properly
- Missing references
Eventually I realized I was debugging the solution loading process rather than my code. After getting the loading step stable, the rest became the fun part.
Solution Overview
The tool performs the following steps:
- Load a solution
- Map dependencies
- Show them as an interactive graph in the browser
- Highlight circular dependencies
Additional Analyses
While digging deeper I added a few quick‑signal checks:
- Cyclomatic complexity
- Dead code detection (unused public members)
- Basic coupling metrics
A simple quality gate allows the tool to fail in CI if thresholds are exceeded.
Implementation Details
- Target framework: .NET 8
- Core libraries: Roslyn (MSBuild workspace), MSBuildLocator
- Web server: ASP.NET Core (embedded)
- Visualization: D3.js
Since I’m a .NET developer, I packaged it as a .NET global tool.
dotnet tool install -g KiwiDepend
kiwi-dep analyze --solution MyApp.sln
Usage
Running kiwi-dep analyze against a solution generates an interactive HTML page that visualizes the dependency graph, highlights cycles, and reports the additional metrics mentioned above.
Conclusion
Navigating a codebase of this size without a clear overview is painful. This tool provides a lightweight, extensible way to get that overview and catch architectural issues early.
If you find it useful or want to try it out, the repository is available here:
https://github.com/KiwiDevelopment/KiwiDepend
A ⭐ on the repo is always appreciated! 🙂