Never mutate state in a Debug.Assert call

Yesterday I encountered a bug in a library I'm working on that only seemed to occur when compiled in release mode. I was scratching my head for a little while but suddenly it occured to me when I encountered the following line:

Debug.Assert(reader.Read() == '-'); // Consume token

The problem with the above statement is that calls to Debug.Assert are conditional, so when running under a non-debug build, the call won't be made and the expression won't be evaluated.

So what lessons can we learn from this?

Never mutate state in a Debug.Assert call.

Azure Web Apps and the certificate store

I was trying to load a certificate from the certificate store in an Azure Web App today, and for some reason I could not find it via it's thumbprint. Since I thought I was looking in the wrong certificate store, I went to Kudu to take a closer look via the PowerShell debug console.

My code (probably) wasn't wrong but the certificate simply wasn't there.

After some googling I found out that WebApps in Azure doesn't have access to uploaded certificates unless you add a special AppSetting variable called WEBSITE_LOAD_CERTIFICATES.

You can either set this setting to a comma separated list of the certificate thumbprint that you want to expose, or you can do what I did (YOLO™) and set it to * which exposes all available certificates to the application.

Also, if you're interested in Kudu (which is awesome), check out devlead's appearance on Azure Podcast where he spends 30 minutes or so talking about it: http://azpodcast.azurewebsites.net/post/Episode-147-Kudu?utmsource=twitterfeed&utmmedium=twitter

Cake and AppVeyor integration

In this blog post I will show you how to use Cake with your AppVeyor CI builds.

Read more...

Script aliases

Cake supports something called script aliases. Script aliases are convenience methods that are easily accessible directly from a Cake script. Every API method in Cake is implemented like this.

In this blog post I will show how to extend Cake with your own script aliases. It's really simple, I promise. ;-)

Read more...

It's not a party without Cake

I have during my nine years as a (professional) programmer used several different build automation systems such as Rake, psake, CMake, TFS Build and FAKE, but none of these have allowed me to write my build scripts using C# - the language I use the most.

About two months ago I decided to change that and now it's time to formally introduce Cake, which is short for C# Make.

Read more...

The singleton logger

It is widely accepted that you access logging frameworks via a static singleton instance, and most logging frameworks are designed to work like this. But why? Many people often refer to it as being a cross-cross cutting concern; and that it's therefore not important to do things by the book. Not only does most logging frameworks use the static singleton as a fa├žade, but they also store process-wide state.

Read more...

Introducing Lunt

Last summer, a friend and I started to write a little Paradroid clone. Since my only real experience as a game programmer was with XNA and MonoGame, I had grown fond of the XNA Content Pipeline, and naturally wanted something similar for this project.

The game was going to be cross platform (Windows and Linux) so the asset pipeline had to be cross platform as well. The natural step was therefore to see if the MonoGame Content Builder (MGCB for short) could be used for this.

Read more...

Displaying TeamCity build status on GitHub

Have you ever wanted to display the current CI build status for a TeamCity project in your GitHub README? I did but couldn't find any good, straight forward information about how to do it. Turns out it's quite simple.

Read more...

System.IO.BinaryWriter and C++

A while back I had to read string data written by .NET's BinaryWriter in C++. I was initially a little bit confused about how the data was written but after using Reflector it turned out that the write method prefixes the string with a 7-bit encoded integer.

Read more...

Culture agnostic string comparisons

Something I've seen a lot at different clients is naive string comparison. The most common case is to do something involving String.ToLower() on both strings that are being compared and then an equality comparison of the result.

Read more...

Next Page