Using NDepend to improve my Application Code

NDepend is a .NET code quality tool that performs static code analysis. It can help to detect code smells and dependency issues. In this post I will take a quick look at using the Dependency Graph feature to clean up one of my open-source applications. NDepend has a desktop application (as well as Visual Studio extension) that can be used by developers in a tight development cycle to address dependency and code quality issues during development:

  • change code

  • build application

  • run analysis (or configure automatic analysis in NDepend for every build)

The tool also comes with a handy console application that can be leveraged for enforce quality rules on CI/CD agents. Later in this post I look at generating reports with the NDepend Console on build agents.

Dependency Graph

Find out more


Exploring Inline Arrays

Inline arrays have been introduced as new feature in C# 12. As the feature is preview at the time of writing, it may change before the .NET team releases the final version of C#.

A type attributed with inline array can be used to represent a fixed-size, contiguous sequence of primitives. The runtime and language provide type and overrun safe indexing operations to the underlying primitives.

At the time of writing one can define an inline array by applying the [InlineArray] attribute on a struct, that has a single field.

[System.Runtime.CompilerServices.InlineArray(8)]
struct Octet
{
    private int _element0;
}

Find out more


IDE0005 as Build Error

I recently set up the IDE0005 .editorconfig file rule to break the CLI build. This is an IDE rule, that normally is not emitted as warnings / errors in the CLI build.

IDE0005 rule flags unnecessary using directives. It wraps CS8019 that also does the same.

Setup

Add an .editorconfig file containing the rule and set the severity as a warning. It may be also set as an error if one prefers to get a build error without setting warnings to break builds.

Find out more


An approach to pseudo-Median with SIMD

In a previous posts I looked into using Single instruction, multiple data, SIMD to find the Median value in a sample of integer values as well as I looked into generating pairwise averages.

The definition of median in case of

  • an odd sample size, find 'middle' element of the ordered samples.

  • an even sample size, find the 2 elements in the middle of an ordered sample size, and calculate the average of those.

I have recently came across a blog post from Andrey Akinshin proposing to benefits of using Hodges-Lehmann location estimator to calculate a pseudo-median value.

Find out more


An approach to Walsh pais with SIMD

In a previous posts I looked into using Single instruction, multiple data, SIMD to find the Median value in a sample integers.

The definition of median in case of

  • an odd sample size, find 'middle' element of the ordered samples.

  • an even sample size, find the 2 elements in the middle of an ordered sample size, and calculate the average of those.

I have recently came across a blog post from Andrey Akinshin proposing to benefits of using Hodges-Lehmann location estimator to calculate a pseudo median.

Find out more