DEV Community

Cover image for I needed to understand a large legacy .NET codebase — so I built a tool for it
Dmytro
Dmytro

Posted on

I needed to understand a large legacy .NET codebase — so I built a tool for it

I’m a .NET dev, and lately I’ve been slowly open-sourcing some of the small things I built for myself over time. This is one of them.


The context

I’ve been working on an old .NET 4.6 app recently (~15 years old, 1M+ LOC).

At some point I needed a way to understand the architecture better.

Not in a “read the code” sense, but like:

  • what depends on what
  • where things are going in the wrong direction
  • if there are cycles hiding somewhere

You can navigate the code, sure.

But getting a real picture of how everything is wired together is… not that easy.


What I tried

I know there are some pretty powerful tools for this, but they’re expensive. And the free ones I tried felt a bit limited for what I needed. At some point I started thinking it might be easier to just build something for myself. So I played around with that idea for a bit. Then dropped it for a while.


The annoying part

Recently I picked it up again and started pushing it further. Turned out that’s not as straightforward as it sounds.
Loading a solution reliably is already half the problem:

  • SDK differences
  • MSBuild resolution
  • projects not loading properly
  • missing references

At some point I realized I wasn’t even debugging my code anymore — I was debugging how the solution gets loaded. Eventually got it to a state where it works consistently enough.
That alone felt like a small win.


What I ended up with

Once I had that, the rest was actually the fun part.
Right now it can:

  • load a solution
  • map dependencies
  • show them as a graph in the browser
  • highlight circular dependencies

While digging into it I also added a few extra things:

  • cyclomatic complexity checks
  • dead code detection (unused public stuff)
  • basic coupling metrics

Nothing super deep — more like quick signals than full analysis.

There’s also a simple quality gate, so it can fail in CI if thresholds are exceeded.


Tech behind it

  • .NET 8
  • Roslyn (MSBuild workspace)
  • MSBuildLocator
  • ASP.NET Core (embedded server)
  • D3.js for visualization

Since I’m a .NET dev anyway, it felt natural to just build it as a dotnet tool.


How to use it

dotnet tool install -g KiwiDepend
kiwi-dep analyze --solution MyApp.sln
Enter fullscreen mode Exit fullscreen mode


Final thoughts

Maybe I’m overthinking this, but navigating something this big without a good overview feels pretty painful. I’ll keep working on this and see where it goes.
There’s still a lot I’d like to explore — deeper analysis, better signals, maybe tracking things over time. For now I’m mostly adding things as I run into problems myself.
I’ll try to share progress here as I go.

If this sounds useful or you want to try it out, here’s the repo:
👉 https://github.com/KiwiDevelopment/KiwiDepend

And if it helps you catch something in your own codebase, a ⭐ is always appreciated 🙂

Top comments (0)