Analysing .NET Core applications using NDepend

- 2 mins

I previously blogged about NDepend and its capabilities to perform static code analysis and obtain in-depth information about code metrics via its CQLinq features.

I have used in the past NDepend to analyse codebases of .NET apps with great results, always obtaining advanced suggestions on how to improve the code and often highlighting issues that could have prevented maintainability.

Recently, I was contacted by Patrick Smacchia, creator of NDepend, for providing some feedback about the last release, so I thought it was a good opportunity to dig more in-depth about the latest features available in the v2018.1 public release https://www.ndepend.com/whatsnew.

I was very pleased to verify the support available for .NET Core, including .NET Core 2.1 Preview.

To test it, I downloaded a trial of NDepend from here and installed on my system running Windows 10 April 2018 update with Visual Studio 2017 Version 15.7.0: all worked well and got the NDepend menu appearing when launching the IDE.

Exploring new .NET Core 2.1 APIs

Since I tried recently .NET Core 2.1.0 preview 2, I explored the differences between this version and version 2.0.7 available on my machine under the folder C:\Program Files\dotnet\shared\Microsoft.NETCore.App: using the NDEPEND->Diff menu I selected the assemblies related to the two versions

And I was able to obtain a list of the new public methods available in the latest release:

Then a detailed view of other metrics using the NDepend dashboard including a complex dependency map:

It’s possible to extract numerous information related to the differences between the two .NET Core versions including assemblies, public methods, types, fields added/removed plus more.

A useful article available on the NDepend blog explains the different options available and additional in-depth articles are referenced below:

As a next step, I created a new blank ASP.NET Core Web Application and ran a code analysis and obtained a list of queries and rules starting from the NDepend dashboard:

It is possible to discover a variety of rules, object-oriented design, breaking changes, naming conventions, source file organisation, architecture improvements and more to enhance the codebase of the .NET Core app: this is a real time saver when exploring new codebases or performing code reviews.

A comprehensive list of the new features available in NDepend v2018.1 is available here, including support for .NET Core and  DDD ubiquitous language check as explained in depth on the official blog.

Happy coding!

Davide Zordan

Davide Zordan

Senior Software Engineer

rss facebook twitter github gitlab youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora mastodon