What defines a hotfix?

April 15, 2010

This blog post was inspired by a recent post from Eric Lippert (Putting a base in the middle). In there, he describes a peculiarity of the C# compiler that is both completely logical and yet totally unexpected to the uninitiated.

In short (for the long version, please check out Eric’s blog post): Base-calls are always executed non-virtually. This means, if you have a class hierarchy spanning two assemblies and you replace the referenced assembly without recompiling the referencing assembly, you can miss a base-call if the referenced assembly added an override in the middle of your class hierarchy.

What makes this so interesting are two things.

Firstly, this behavior isn’t documented in CLR via C# by Jeffrey Richter. I checked, including the latest release for .NET 4.0. This surprised me, since he did warn about changing a non-virtual member to a virtual one in a referenced assembly and how this could result in a NullReferenceException if you don’t recompile the referencing assembly (see page 170 in the 3rd Edition).

The second and more important aspect is about what this means for versioning. These two types of change are not something that would normally get flagged as breaking changes, simply because your code will still compile with the new version.

The operative word being compile. But is there a reason not to recompile? Well, some people advocate not changing the assembly version for a hotfix. Doing this enables the developer to replace only one assembly in the production environment, with the express purpose of limiting the change and thus reducing the noise generated on the project management level.

And this is where things start to become interesting. What defines a hotfix? The simplest explanation is “A change that fixes only one bug and does not change to public API”. This means, a hotfix has to be contained within the private details of your types. And due to the CLR’s policy regarding overrides, this prohibits fixing the issue by adding an override with you hotfix, sometimes the most opportune way of doing it. And if it’s the only way to fix the problem, then you just have to bite the bullet and recompile/deploy the entire application.

BTW, for re-motion we’ve long since (actually, since its inception in 2004) decided to increment the version number for each build.

Michael

Leave a Reply