I had been using System.Drawing.Point as my means of storage for game coordinates until now. During my time catching up with unit tests I had a horrific realisation. Against all best practice information on structs in C# I found that Point is in fact a mutable struct.
I think I need to write that one more time so it can sink in…. Point is a MUTABLE struct.
Having a value type that is mutable is an oxymoron so all I can figure is that Point has been around since .NET V1 days when the advice was different and changing it now would break loads of existing code.
Given that I am aiming for fully immutable state this is catastrophic. I am just glad that I have caught this at this stage in development and not later down the line when a refactor to a different type would have been far more ugly and time consuming in nature. Even at this state without my friend ReSharper this could have been far worse than it needed to be.
So now I have a new Coordinate struct that is nice and safe and immutable. Shame that I was forced into this extra work because of the mess Microsoft had caused in their own core library but that is life at the code face 🙂