CHttp Visual Studio Code Extension

I have been recently working on CHttp which is a tool to send HTTP requests and to measure the performance of REST APIs.

The primary goal of the tool is the ability to measure GET HTTP requests using version HTTP/2 and HTTP/3. As the tool is based on .NET (currently version 8), it requires a reasonably up-to-date Windows installation or the libmsquic package in case of Linux.

The standalone tool can be installed from GitHub, as a dotnet tool by using the dotnet tool install -g LaDeak.CHttp command or by as a Visual Studio Code Extension.

Using CHttp Visual Studio Code Extension

Find out more


Sum with SIMD

One of my projects requires to calculate an average over about a hundred integer values. These values are available in an array, I used the Sum extension method from Linq to calculate the sum of them.

I have learned two things about this method:

  • With the current version of .NET, it does seem to use vectorization to calculate the sum of items.

  • It uses checked arithmetic, meaning that it throws an exception in case of an overflow.

This is the (optimized) assembly code generated by the JIT for the Sum method:

Find out more


AI for Unit Testing

I work in an environment where people seek opportunities for using AI such as GitHub Copilot to perform daily development tasks.

While there is a general agreement that such tools can accelerate the development process, there is still some uncertainty about how they achieve this. Some possible explanations include quick refactoring options, automatic unit test generation, CI/CD YAML file generation, and assistance with integration testing. The last point refers to UI testing or end-to-end testing, while the second point narrows the focus to unit testing specifically. Although AI can help with most of these points, unit testing seems like an anti-pattern when looking into the details.

My Unit Testing process

Writing unit tests is a well-understood and daily practiced process. In fact, I have seen multiple projects accumulating tens of thousands of tests over their lifetime and developers create unit tests daily. There are numerous generic posts detailing the testing best practices or focusing on special aspects such as Performance testing within Unit tests bad idea.

Find out more


Static Abstract in Practice

I recently encountered a problem where a class used a static method, and I had to provide a second implementation for this static method from one of the callsites. It looked like this case:

public class MyClass
{
    public void Foo(int input)
    {
        var value = MyStaticType.Calculate(input);
        // ...
    }
}

I needed to have a different implementation for Calculate in one place I have been invoking the Foo method. There are multiple ways to address the issue, but I have chosen one that is only available on C# 11 and above.

Alternative Solutions

Find out more


Await events

Some legacy API-s provide an event-based mechanism to achieve an asynchronous behavior. In this case typically a sync method starts a longer running async operation and an event notifies the consumer when the operation succeeds or fails.

For example, a hypothetical code below sends a message to queue and also subscribes an event for completion.

_queue.Completed += (sender, args) => // message is sent
_queue.Send(msg);

Code quickly gets complicated in case the caller wants to wait for the completion of the send operation. In more modern C# one would represent this operation with a Task. A Task could be then awaited at the call site:

Find out more