NDepend

Improve your .NET code quality with NDepend

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

Migrating Delegate.BeginInvoke Calls to .NET Core, .NET 5 and .NET 6

In this 2019 post, the .NET Base Class Library engineers announced that the good old Delegate.BeginInvoke .NET Framework syntax wasn’t supported in .NET Core and consequently in .NET 5, 6...
Patrick Smacchia May 26, 2021

Covariance and Contravariance in C# Explained

Introduction This article explains and demonstrates the concepts of Covariance and Contravariance in C# .NET. These concepts will be first introduced for generics, then for delegates and finally for arrays....
Patrick Smacchia May 4, 2021

Clean Architecture Refactoring: A Case Study

Introduction to Clean Architecture The recent post Clean Architecture for ASP.NET Core Solution: A Case Study explained that one of the most interesting property promoted by Clean Architecture is the...
Patrick Smacchia April 27, 2021

Hungarian Notation for Fields in C#

If there is one topic that divides the C# developers community, it is the Hungarian notation for fields. In our team we rely on Hungarian notation for fields, not just...
Patrick Smacchia April 21, 2021

8 Books to Improve as a .NET Developer

Nowadays all information a developer needs to know is available online for free. Blogposts and videos authored by experts, giant questions and answers websites, a quick search and you get...
Patrick Smacchia March 31, 2021

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

In this post I’ll explore the Jason Taylor’s CleanArchitecture .NET solution template available here on github. It constitutes a good template and it is based on several modern industry wide...
Patrick Smacchia March 24, 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 Exceptions in C#

The C# exception basics are generally well understood. However exceptions are often used as a way to sweep error handling duty under the carpet. As I did in The proper...
Patrick Smacchia December 16, 2020

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

C#9 records: immutable classes

Record is a long time awaited feature now proposed by C# 9. Finally we have a concise syntax to express this: [crayon-60cfdf1d0fb89685305305/] Isn’t it beautiful? In the NDepend code itself...
Patrick Smacchia October 12, 2020

New C#9 keywords ‘and’ ‘or’ ‘not’

HoweverThe C#9 language introduces new controversial keywords: and keyword: Conjunctive patterns. Require both patterns to match or keyword: Disjunctive patterns. Require either pattern to match not keyword: Negative patterns. Require...
Patrick Smacchia October 5, 2020
open