C#11preview: Type-safe interchangeable units

In a previous post, I discussed static abstracts in interfaces, and while it is quite a nice feature, it falls short in some corner cases – particularly in implicit type-conversions. I’m not sure if it should, but… it’s complicated. As an example, I will consider the concept of interchangeable units. Wouldn’t it be neat, if … Read more

C#11pre: static abstract interface members

C#10 was just released, but included in this years release is an early preview of C#11, and it contains quite an exciting change: static abstract members in interfaces. You might think, what’s the fuzz? Static members in interfaces is nothing new and was introduced in C#8! In this post I present a few more fruitful, … Read more

XUnit: Using TheoryData with Theory

In a previous post, we looked the newly introduced Assert.Multiple in the XUnit 2.4.2 assertion library. In this post, we will dive deeper into different ways of expressing tests and especially, test input. Facts are the simplest possible test-case in XUnit. They are self contained in that they contain the arrangement, act ,and assertion, but … Read more

Mimicking Delegates in C# with GOF Observers

How far could we get trying to implement our own delegate types? How are are delegates related the observer pattern? In this less serious but technically interesting post, we explore the relation between delegates and observers, look at how close we could and our ability to implement our own delegate type; or at least imitate … Read more

Are interfaces like contracts?

I have tought Object Oriented Programming for a number of years and in my time completed more than a thousand oral exams at bachelor level computer science and software engineering students. Overall, it seems object oriented programming can be difficult to comprehend, but clearly the concept of interfaces is one of the harder topics. Interfaces … Read more

Design your own language in C# 9: a tutorial series

Programming languages are some of our fundamental tools, and many different languages for many different purposes. In this tutorial series, you will learn how to design and implement your own language, starting out from simple expressions and their evaluation, later adding variables, functions and lambda expressions. You may ask yourself why… why would you create … Read more

Pruning recent projects in Start Page of Visual Studio 2019: Open recent

My recent projects list in Visual Studio is huge, so huge that it has become a annoying when I enter the Visual Studio Start Page.; it hangs and takes to respond. I create a lot of small projects in visual studio, and open a lot more. Every year I have around 300 C# projects from … Read more

Convenient member data sources with xUnit

In xUnit test cases can be parameterized using the attribute [InlineData] much like [Datarow] in MsTest. That is, instead of stating a [Fact], you can create a [Theory] and parameterize it, much like this example: Here we created four testcases using a general parameterized theory. This allows you to rapidly gain coverage without the boilerplate … Read more

Mapping deserialized objects to their JSON source using Json.NET

I am rewriting a part of an application written in python. It queries a json api, extracts relevant information and stores this information in an SQL database. It has served me well for a number of years now, and have changed quite a lot during its lifetime, and so has the relevant information. The data … Read more