The Blog of Zachary Snow

LINQ calls IEqualityComparer.GetHashCode() before Equals()

This is a problem that has bitten me more than a few times so I thought it was about time to write a blog post about it. It’s one of those problems that makes you scratch your head for a bit and then the light bulb goes on and you remember you’ve solved this one before. It occurs whenever you use a LINQ extension method which takes an instance of IEqualityComaparer.

My Experience with OpenGL vs Direct3D

I’ve struggled a lot with myself over whether I should use OpenGL or Direct3D. There is no blanket answer to this question that anyone can tell you. Both APIs have a very different feel and which one you prefer can only be decided on your own.

Code from when I was young and stupid and needed the money

We have had 2 interns at work for the past few weeks and one of the tasks we gave them was to implement Quicksort. This got me to thinking about my youth and some of the code I wrote back then. I’ve decided to post it.

Programming is my hobby as well as my job

Shortly after moving to Germany in 2007, one of the first things I did was to get myself a new computer. I had moved in with my then girlfriend (now wife) and one of the things she had to trouble adjusting to was the fact that I could work on code for 8 hours a day and then come home and want to do the same thing.

This is a sentiment that not only comes from her but also from many other people I’ve met. I tried to explain to them with an analogy and I think I’ve finally found one that fits and people seem to accept.

The analogy is a car mechanic. How many car mechanics do you know that don’t have their own personal hobby project going on at home? As a matter of fact, I think I would find it strange if I asked a mechanic what he does for his hobbies and he proceeded to tell me that he works 9 to 5 and after that he doesn’t want to have anything to do with cars.

For some reason the world doesn’t see computer programmers as being similar to car mechanics in this regard. Wanting to tinker with computers after working for 8 hours with them seems foreign to most people. I love what I do and I just happen to get paid to do something that I love. Why is that so hard to understand?

This is the reason why I and a few of my colleagues started the SOLP .NET User Group. We have our day jobs but we still want more. If you feel similar and live in the Soest / Lippstadt area, please feel free to join us.

Adding assembly references in Roslyn

In the Roslyn preview that was released at Build 2014 the way references to global assmeblies are added was changed. Before the preview I could use code like this:

var compilation = Compilation.Create(assemblyName, new CompilationOptions(OutputKind.DynamicallyLinkedLibrary))
    .AddReferences(new MetadataFileReference(this.GetType().Assembly.Location))

The static factory method “MetadataReference.CreateAssemblyReference” added a reference to global assemblies such as “mscorlib.dll” or “System.dll”. In the Roslyn preview, the same be achieved like so:

var assemblyPath = Path.GetDirectoryName(typeof(object).Assembly.Location);

var compilation = CSharpCompilation.Create(assemblyName)
    .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary))
    .AddReferences(new MetadataFileReference(Path.Combine(assemblyPath, “mscorlib.dll”)))
    .AddReferences(new MetadataFileReference(Path.Combine(assemblyPath, “System.dll”)))
    .AddReferences(new MetadataFileReference(Path.Combine(assemblyPath, “System.Core.dll”)))
    .AddReferences(new MetadataFileReference(Assembly.GetEntryAssembly().Location))

All the cool kids are static

Seems like all the cool kids these days have converted their websites to completely static ones. I’m looking at you Mr. Haacked. I thought this was a pretty cool idea and a chance to really refresh my website so I decided to take a stab at it. It’s currently a work in progress.

I ended up writing my own tool I call Gatsby to do it. I also set up the whole deploy process myself involving pushing to Github which then informs my website to pull from the Github repository. Hopefully that will be a blog post in the not too distance future.

Sorry for any inconvenience.

Using Component Glue to build your object graphs automatically

Component Glue is an IoC container and you use it of course to wire up your object graphs for you. Component Glue can also build your object graphs for you automatically if there are no interfaces involved. Take this example:

In After.cs, you can see that Component Glue is able to build the entire object graph for us. This will include all future dependencies as well so long as interfaces don’t come into play. Should an interface be needed, you can just bind that single component.

This is a very powerful thing. If one component needs to take on a dependency, just ask for it in the constructor and Component Glue will handle it for you.

Component Glue v1.0

I finally brought Component Glue up to a state where I felt like the product was finished. You can get it via NuGet:

PM> Install-Package ComponentGlue

or you can get the source from GitHub. The documentation is definitely sparse I know but I recommend taking a look at the unit tests to get a feel for what you can do with Component Glue.

Credit for the NuGet CSS here.

GLDotNet Version 0.6.0

I just released GLDotNet Version 0.6.0.


  • **GLDotNet.Toolkit**: Assembly containing simple app framework.
  • **GLDotNet.Objects**: Assembly containing higher level objects such as Texture2D and VertexBuffer.
  • More overloads added to GLContext class.
  • byte and sbyte are now mapped correctly in generated code.
  • Fixed the naming of some functions so as not to include type notation, i.e. Color4u.
  • Decreased the number of enum values output.

Introducing GLDotNet

Today I released a project I’ve been playing around with for a year or so on Codeplex. It’s called GLDotNet. From the project description:

C# wrapper for OpenGL. Partially generated from the OpenGL spec and partially written by hand, the aim is to have a flexible and native feeling C# binding.

I have generated functions from the OpenGL spec excluding 1 or 2 but unfortunately of the generated code is untested. There is a demo project included in the source code. The Github repository is located here:


« Older posts