Mike Hadlow

C# .NET Developer

  • Book Review: D3 Start To Finish by Peter Cook
    Jul 13, 2022

    This is my review of D3 Start to Finish by Peter Cook. Peter is a well known author and educator in the world of data visualisation as well as being an in-demand software developer. This is his introductory tutorial to D3, a Javascript library used primarily for targetting SVG for browser native data visualisations. D3 is a very powerful tool, as a quick browse of the website will demonstrate. This book evolved from Peter’s courses on D3 and aims to teach you all you need to know to produce professional D3 based data visualisations.

    Read more...


  • Writing .NET Application Services for Kubernetes
    Jun 24, 2022

    In a traditional .NET distributed application, application services (not to be confused with the Kubernetes ‘service’ object) would either be written as IIS hosted web applications or Windows Services. When building .NET (micro)services to be deployed in a Kubernetes cluster pretty much every facet of the service needs to be reconsidered, not only the hosting environment but the way configuration is accessed, how logging and monitoring work, and the options for state management and memory considerations. In this post I’ll bring my experience of migrating .NET applications to Kubernetes to enumerate some of the main ways that you’ll need to change the way you write them.

    Read more...


  • Book Review: Team Topologies by Skelton and Pais
    Apr 29, 2022

    This is my book review of Team Topologies by Matthew Skelton and Manuel Pais.

    Conway’s Law, coined by computer scientist Melvin Conway states:

    Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization’s communication structure.

    This book is a distillation of Skelton and Pais’s experiences helping teams execute the “reverse Conway maneuver”; using the insight of Conway’s law to structure teams more effectively for software delivery. They present a framework and taxonomy for thinking about teams and their interactions that is immensely helpful for anyone tasked with creating a software organization.

    Read more...


  • C#: Add event handlers dynamically using reflection
    Apr 28, 2022

    Recently I had a situation where I needed to test a class with dozens of event handlers. Rather than manually write the repetitive code to attach the handlers I decided to cheat and use reflection. Since there wasn’t anything immediately available online that I could find, I’m sharing an example here to show how to do it.

    Read more...



  • How to use Google.Protobuf without code generation in C#
    Mar 18, 2022

    The Google.Protobuf NuGet package is the recommended protobuf serializer for .NET. The documented way of using it is to code gen both C# models and serializers from .proto files using the protoc tool. However, sometimes it’s more convenient to do serialization/deserialization on an ad-hoc basis without code generation. The Google.Protobuf NuGet package provides APIs to do this, but they are poorly documented. This post gives a code example for a simple “no-code-gen” serializer.

    Read more...


  • Blocking XREAD From A Redis Stream Using StackExchange.Redis
    Feb 18, 2022

    The StackExchange.Redis NuGet package is the most popular .NET client for Redis. It’s stable, high-performance, with a great community and wide usage. One of it’s most interesting features is the way it does network multiplexing. This allows multi-threaded applications to use a single TCP/IP connection without blocking. Unfortunately this also means that the library does not support blocking operations such as XREAD BLOCK, which is important if you want to leverage Redis Streams on .NET. This post offers a work-around for this.

    Read more...


  • Large Numbers of Bindings With RabbitMQ
    Aug 19, 2021

    RabbitMQ (or more specifically the AMQP protocol) provides a degree of flexibility over other message-queue solutions with its exchange-binding-queue model. Some possible solutions to scaling or business issues result in large numbers of bindings being created, perhaps thousands per queue. We tested RabbitMQ to find out what the binding performance limits were and present the results in this post. It seems that large numbers of bindings are not in themselves a performance issue, but on a RabbitMQ cluster, “binding churn” the rate at which they are created and destroyed can have a large impact on message delivery and because bindings can take time to propagate through the cluster there is the possibility of message loss.

    Read more...


  • Register a Microsoft.Extensions.Logging.ILoggerProvider with EasyNetQ
    Aug 13, 2021

    EasyNetQ is an opinionated fully featured client API for RabbitMQ. It provides extensive diagnostic logging capabilities via LibLog a logging abstraction that provides support for many common logging libraries. Unfortuntely LigLog doesn’t support Microsoft.Extensions.Logging, but this post provides an adaptor, EasyNetQMicrosoftExtensionsLogProvider that will allow EasyNetQ to log to a Microsoft.Extensions.Logging.ILoggerProvider.

    Read more...


  • How to create a standalone ConsoleLoggerProvider
    Jul 27, 2021

    If, for whatever reason you want to create a stand alone instance of ConsoleLoggerProvider without having to leverage dependency injection and the full Hosting framework, you’ll find that the ConsoleLoggerProvider’s constructor requires an instance of an IOptionsMonitor<T>, the only instance of which OptionsMonitor<T> in turn has a complex constructor with many dependencies. This all seems like a failure of design on Microsoft’s part. Here I give a simple no-op IOptionsMonitor<T> implementation to allow one to easily create a ConsoleLoggerProvider.

    Read more...


  • Microsoft.Extensions.DependencyInjection object graph writer
    Jul 20, 2021

    It’s very useful sometimes to be able to quickly view the object graph created by a dependency injection (or IoC) container, especially when you’re a new starter on an existing project. I was recently attempting to get up to speed on a .NET Core project, but I couldn’t find anything that would output an object graph from the Microsoft.Extensions.DependencyInjection IServiceCollection, so I wrote a simple class that reads the graph and outputs a basic representation. I’m sharing it here for my own benefit, but also as a starting point if anyone else needs something similar.

    Read more...


  • A Simple Console Periodic Loop in C#
    Jul 9, 2021

    I found myself writing the same code several times for a simple console periodic loop, so I’m posting the framework here mainly for my own benefit. This uses C# 7’s new async Main entry point and avoids the need to spawn a new thread for the loop. Worth noting though that each iteration after the Task.Delay will run on a threadpool thread.

    Read more...


  • Welcome To My New Blog
    Jul 6, 2021

    I’ve been blogging since 2005 and have written hundreds of posts in that time, but my blogging output has declined somewhat over the last few years. That’s partly laziness on my part, and partly because Twitter provides a much more convenient platform for the quick take, but it’s also because there’s too much friction in publishing a post on my long running Google Blogger site Code Rant. Google has done little to update the ancient Blogspot platform over the years and it’s showing its age. The effort required to upload and format a blog post is too high, and has effectively disincentivised me from blogging. In the last few years I’ve sometimes managed just a single post per year. So, long overdue, I’ve decided to start a new blog here at mikehadlow.com using modern developer platform technologies. This is the first post.

    Read more...


Hi, I’m Mike Hadlow. Software developer, architect, blogger and open source developer.

Find my old blog at Code Rant. This ran from 2005 to 2020 and has hundreds of posts.

All code on this blog is published under an MIT licence. You are free to copy it and use it for any purpose without attribution. There is no warranty whatsoever. All non-code text is copyright Mike Hadlow and cannot be reused without permission.

There are no cookies on this site

The GitHub repository for this site is here.