NDepend

Improve your .NET code quality with NDepend

Unveiling the Impressive Features of Upcoming C# 12

Microsoft unveils new features in C# 12 Preview. C# 12 along with .NET 8 will be officially released in November 2023. Let’s explore the latest impressive enhancements in this post....
Patrick Smacchia August 17, 2023

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

Improved .NET Debugging Experience with Source Link

Source Link is a Microsoft technology that lets .NET developers debug the source code of NuGet packages referenced by their applications. I underlined source code because at debugging time the...
Patrick Smacchia June 20, 2023

.NET Micro-Optimization and Refactoring Trick

Recently, I made an interesting observation regarding Dictionary<string,T>: the method TryGetValue() is faster when building  with new Dictionary<string,T>(StringComparer.Ordinal). This performance difference can be attributed to the fact that StringComparer.Ordinal performs...
Patrick Smacchia May 31, 2023

C#12 class and struct Primary Constructors

Since C#9 we have the convenient primary constructor syntax for class record (or just record) and struct record: [crayon-6514c8f98b7db388827056/] C#12 introduces primary constructor for non-record class and struct but beware,...
Patrick Smacchia April 13, 2023

In the Jungle of .NET Obfuscator Tools

In this article I will explain our genuine experience with various .NET Obfuscator Tools. We end up explaining that .NET Reactor is the one we choose to obfuscate our code...
Patrick Smacchia April 10, 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

C# ValueTuple

C# 7.0 introduced Value Tuples which represent both a set of structures in the .NET Base Class Library (BCL) and some convenient C# syntax. Value tuples are available in all...
Patrick Smacchia January 31, 2023

The new .NET 7.0 IParsable<TSelf> interface

As I explained in the post C# 11 static abstract members, C# 11 let’s write static abstract members in interface. This feature was mostly introduced to implement the new .NET...
Patrick Smacchia November 21, 2022

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-6514c8f98c59b491985588/] This keyword...
Patrick Smacchia November 15, 2022

C# 11 File Scoped Types

C#11 added the file scoped types feature: a new file modifier that can be applied to any type definition to restrict its usage to the current file. This way we...
Patrick Smacchia October 27, 2022

Managed pointers, Span, ref struct, C#11 ref fields and the scoped keyword

The concept of managed pointer exists in the NET runtime and C# since the inception of the platform in the early 2000. Managed pointers belong mostly to the pointer world,...
Patrick Smacchia October 25, 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

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

C# Pattern Matching Explained

Since the C# version 7, C# has support for pattern matching. C# pattern matching is here to simplify complex if-else statements into more compact and readable code. Pattern matching does...
Patrick Smacchia April 4, 2022

Improve C# code performance with Span<T>

C# 7.2 introduced the structure System.Span<T>. First we’ll present a concrete example where Span<T> helps achieve better performance. Then we’ll explain what makes Span<T> so special. Span<T> primary goal is...
Patrick Smacchia February 21, 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

C# Binary Search: Fast find of a free slot between 0 and uint.MaxValue

When a user is exporting a result to a document with NDepend, the tool needs to find a file name not taken in the temporary dir. Generating a GUID for...
Patrick Smacchia January 3, 2022

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

5x Lessons Learned from Migrating a Large Legacy to .NET 5/6

In January 2020 I wrote the post Not planning now to migrate your .NET 4.8 legacy, is certainly a mistake. Hopefully we followed our own advice and have been migrated...
Patrick Smacchia October 26, 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-6514c8f98f6da616782399/] 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

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

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