C# Records Compare Private Members

Turns out private members of C# records affect value-based equality.

July 15, 2022 · 1 min

Constrained Types without Exceptions

Representing constrained values with types greatly reduces defensive programming. However, constraints make some values invalid, and constructors don’t allow for flexible return types like a failure state. Here’s an approach to constructing constrained values without relying on exceptions.

July 8, 2022 · 3 min

Union-based Result Types in C#

I previously wrote about result types and union types in C#. I got to wondering if a union-based approach would allow nicer result types. In short, it works, but not as nicely as I’d hope.

May 29, 2022 · 3 min

TestApi and Test Reuse in C#

The TestApi pattern helps decouple tests from our system and enables more stable and reusable tests. I’ve shown how I use the pattern in F#. Now here’s a similar example in C#.

May 16, 2022 · 5 min

Case for Static Class Extension in C#

Working on System.CommandLine.PropertyMapBinder has led me to believe C# is missing a powerful feature: static class extensions. This post explains my usecase, and balances some of the tradeoffs.

February 3, 2022 · 3 min

Union Types in C#

Union types are common in functional languages, but have yet to make it to C# and similar. These types solve a simple and very common problem, data that is one of a finite set of possibilities. Here’s we’ll look at how to accomplish the same in C#.

March 26, 2021 · 4 min