Using batch files as the task runner in Visual Studio Code

July 9, 2015vsvscodebatch

Visual Studio Code allows you specify tasks which can be in a task runner. Most examples I've seen show how to integrate with Javascript task runners such as Gulp. There is no reason why you can't simpley use batch files though.

Read More

LINQ calls IEqualityComparer<T>.GetHashCode() before Equals()

November 24, 2014.netlinq

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.

Read More

My Experience with OpenGL vs Direct3D

November 18, 2014graphicsopengldirect3D

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.

Read More

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

June 18, 2014old-codec++

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.

Read More

Adding assembly references in Roslyn

April 15, 2014.netc#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(MetadataReference.CreateAssemblyReference("mscorlib"))
    .AddReferences(MetadataReference.CreateAssemblyReference("System"))
    .AddReferences(MetadataReference.CreateAssemblyReference("System.Core"))
    .AddReferences(new MetadataFileReference(this.GetType().Assembly.Location))
    .AddSyntaxTrees(syntaxTree);

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))
    .AddSyntaxTrees(syntaxTree);