NDepend

Improve your .NET code quality with NDepend

C# async await explained (2023)

In 2012, C#5 was released. This version introduced two new keywords async and await. At that time CPU clock speed reached an upper limit imposed by physical laws. But chip...
Patrick Smacchia August 16, 2023

Improve Visual Studio Build Performance

Time is your most precious asset and slow build is high in the list of developer’s productivity killers. With slow build the penalty is twofold: not only the time taken...
Patrick Smacchia August 11, 2023

.NET Decompilers Compared: A Comprehensive Guide (2023)

Looking to reverse engineer or disassemble some .NET code? Then learning how to decompile .NET assemblies is a an essential skill for any .NET developer or security engineer. Fortunately, there...
Patrick Smacchia March 14, 2023

Clean Architecture for ASP.NET Core Solution: A Case Study

In this post we’ll explore the Jason Taylor’s CleanArchitecture .NET solution template available here on github recently updated to support .NET 7. It illustrates well how an ASP.NET Core application...
Patrick Smacchia March 9, 2023

C# 11 required members

C# 11 proposes the new keyword required that can apply to an instance property or an instance field declaration within a class, a record or a struct. [crayon-651039d6250c6463222718/] This keyword...
Patrick Smacchia November 15, 2022

.NET Build Improvement: Stop Wasting Resources

I am working on .NET development full-time since 2002 and there is a point that still annoys me after all these years: the default .NET build behavior leads to a...
Patrick Smacchia October 4, 2022

Architecture of a .NET Application: Case Studies

Recently the question Number of projects per solution has been asked on reddit which led to interesting debates. Of course the answer depends largely on the overall size and business...
Patrick Smacchia September 13, 2022

Visual Studio vs. Jetbrains Rider Performance

I work daily with Visual Studio since 1997 but still use Rider from time to time to keep up with progresses since we plan to also integrate our NDepend extension...
Patrick Smacchia June 28, 2022

C# 11 static abstract members

C# 11 proposed interface members declared as static abstract. This is useful to handle both: Polymorphism at the type level, for example when abstracting the concept of zero accross numeric...
Patrick Smacchia June 14, 2022

WPF / Winforms UI Refactoring: A Case Study

WPF and Winforms are still so massively used that Microsoft fully supports those technologies in .NET Core, .NET 5, 6 , 7 and so on. However WPF and Winforms are...
Patrick Smacchia May 11, 2022

How to collect return values from Parallel.ForEach?

Today I took 10 minutes to answer the 9 years old stackoverflow’s question: How do I collect return values from Parallel.ForEach? I though the improved solution deserved a quick blog...
Patrick Smacchia January 26, 2022

Modern C# Hello World

With Visual Studio 2022 when you create a new console project based on .NET 6, the Hello World source code generated is now as simple as that: [crayon-651039d626134128963556/] Nice and...
Patrick Smacchia November 23, 2021

Solution to Visual Studio 2022 messing up Visual Studio 2019

As all .NET developers I am quite excited by Visual Studio 2022 and .NET 6 going RTM. However I noticed that Visual Studio 2022 RTM install messed up Visual Studio...
Patrick Smacchia November 10, 2021

Debugging a .NET App on Linux from Windows Visual Studio with WSL

NDepend analysis, reporting, API and Power-Tools will run on Linux and MacOS with the next version 2021.2. To achieve that, a major refactoring session has been achieved to isolate code...
Patrick Smacchia September 15, 2021

Code Testability: A Case Study

[crayon-651039d626ff6640001185/] This method is untestable because its logic depends on NdpOperatingSystem.Kind which returns an OSPlatform object. Notice the usage of the attribute UncoverableByTest that lets code reviewers and tools like...
Patrick Smacchia September 1, 2021

3 productivity Resharper features missing in Visual Studio

Resharper is a great Visual Studio productivity extension but on the other hand it slows down significantly the IDE, especially when working with large solutions. However there are real hopes...
Patrick Smacchia August 10, 2021

Top 10 New .NET 6.0 API

.NET 6 introduces new handy APIs that will make our development journey easier. Let’s go through the top 10 new API in terms of usage likelyhood. Then in the conclusion,...
Patrick Smacchia July 7, 2021

How to Logically Name Embedded Resources in .csproj?

You can work with .NET for two decades and still discover some useful stuff.  One thing that bothered me till now is that an embedded resource name is “the project...
Patrick Smacchia June 16, 2021

On replacing Thread.Abort() in .NET 6, .NET 5 and .NET Core

Thread.Abort() is not supported in .NET 5 / .NET Core We are actually migrating the NDepend analysis and reporting to .NET 5 and figured out that there is no equivalent...
Patrick Smacchia May 19, 2021

Visual Studio 2022 64 bits: Elements of history

Finally after all these years of waiting Visual Studio 2022 will run in a 64 bits process on 64 bits machines! As a consequence the effective process address space of the...
Patrick Smacchia May 11, 2021

Covariance and Contravariance in C# Explained

Introduction Covariance and contravariance allow more flexibility when dealing with C# class hierarchy. This article explains and demonstrates the concepts of Covariance and Contravariance in C# .NET. These concepts will...
Patrick Smacchia May 4, 2021

6 Reasons Visual Studio Theme Affects Productivity

Themes can be fascinating. Humans are vulnerable to attachments. It could be anything – person, thing, color, food, etc. some people are attracted to unique colors that make them feel...
Patrick Smacchia April 14, 2021

Visual Studio IntelliCode : AI Assisted Coding

We are all amazed by recent progresses made possible thanks to Artificial Intelligence (AI). In 2017 Microsoft announced Visual Studio IntelliCode which used Machine Learning (ML) to predict code completions,...
Patrick Smacchia January 19, 2021

How we quickly refactored with Resharper more than 23.000 calls to Debug.Assert() into more meaningful assertions

Since the NDepend inception more than 15 years ago, we stuffed our code with calls to Debug.Assert(). This results today in more than 23.000 assertions calls. Few developers realize that...
Patrick Smacchia January 11, 2021

The proper usages of the keyword ‘static’ in C#

The keyword static is somewhat awkward in a pure Oriented-Object world. I would like to explain here what are the right usages of static I came up after 25 years of...
Patrick Smacchia December 8, 2020

Using C#9 record and init property in your .NET Framework 4.x, .NET Standard and .NET Core projects

C#9 record and C#9 init property are really nice addition to the language. As explained in C#9 records: immutable classes, both are syntactic sugar that don’t require any change at...
Patrick Smacchia November 25, 2020

C# Index and Range Operators Explained

C#8 added the index ^ and range .. operators. In this post I am attempting to demystify both in the most comprehensive way. The index operator ^ Let’s start with...
Patrick Smacchia November 16, 2020

Visualize Code with Software Architecture Diagrams

The source code is the design. This famous motto means that no matter how many diagrams you draw and discuss with your colleagues, the important point is how the existing...
Patrick Smacchia November 10, 2020

Strategies to Catch Regression Bugs before Production: A Case Study

That’s quite a coincidence that a few days after promoting the joy of immutability in the post C#9 records: immutable classes we stumbled on a bug due to a mutable...
Patrick Smacchia October 19, 2020

C#9 records: immutable classes

Record is a long time awaited feature now proposed by C# 9. With record we have a concise syntax to define immutable types this way: [crayon-651039d628fb3779056499/] Isn’t it beautiful? In...
Patrick Smacchia October 12, 2020