DEV Community

Bervianto Leo Pratama
Bervianto Leo Pratama

Posted on

How NDepend Improves Your C# Code Quality?

Preparation

You will need to download NDepend before we are getting started. You may download here. You can choose the trial version or Pro (if you have bought the license).

NDepend Download

NDepend has many documentations on how to setup, also use cases that might fit with your use case.

Let's Get Started

Anyway, I will use the Linux version. Don't forget to install .NET 5, but I hope they will support .NET 6. :) Why? Since .NET 5 it's already end of support and may risk us because don't have security updates, etc. Because I use Manjaro, I decide to use snap, you can visit how to setup the .NET 5 here. Anyway, don't forget to register your license!

Now, I will try to generate NDepend project for my old project.

GitHub logo bervProject / NETCoreAPIBoilerplate

Net Core Web API Boilerplate for My Project

NET Core API Boilerplate (BervProject.WebApi.Boilerplate)

Net Core Web API Boilerplate for My Project

Build Status

Github Action Azure Pipelines Codecov
Build&Dockerize Build Status codecov

LICENSE

MIT

MIT License
Copyright (c) 2019 Bervianto Leo Pratama's Personal Projects

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
Enter fullscreen mode Exit fullscreen mode

I use this command dotnet ~/ndepend/net5.0/NDepend.Console.MultiOS.dll -cp BervProject.WebApi.Boilerplate.ndproj BervProject.WebApi.Boilerplate.sln. Please update the name with your own project and make sure you've moved to your project directory.

I know if I want to run the NDepend, I will need .NET 5. The wonderful thing, I still can generate the report for my .NET 6 project.

Result 1

Result 2

Result 3

I can see my bad code from my old project. But, not only that, you can see the rule, customize the rule, and why that rule is important. Is that all? No, I will continue in another part. So stay tuned!

Dance

Discussion (0)