Extension methods for switching BinaryReader/BinaryWriter endianness

Although very simple, I have published a new small portable class library that adds some extension methods to the BinaryReader and BinaryWriter classes. It consists of overloads to the Read* and Write methods to allow switching the endianness of the data being readen/written. Since almost all current .NET CLR platforms run on little endian (Windows Phone does too, thanks to the ability of ARM to switch between big and little endian), these functions are helpful when reading data exported from other platforms, or more commonly, JPEG files.

The library is available for download from GitHub, both in source code and compiled form. Or if you prefer, you can search for the BinaryEndiannessExtensions package on NuGet and add it directly to your project.

When being organized in Unity 3D is dangerous

While adding Prime31’s Android In-App Billing to an existing game I came across a weird behavior: the calls to the native plugin (made through the GoogleIAB class) were being registered but the callback events (the ones defined in GoogleIABManager) weren’t firing.

After half a day of looking at Android’s documentation, browsing the existing knowledge base and trying different things I found the problem: in a previous refactor I had modified the source files provided by the plugin to put the classes inside a custom namespace. Apparently the reflection methods internally used by the plugin don’t like this and it failed silently. No indication that the type couldn’t be found, failed instancing or the methods didn’t exist.

Morale of this story is to never modify the source code of existing Unity 3D plugins as they usually are quite weak and can break, so whenever you install something from the Asset Store make sure you don’t modify it. In case someone ever has the same problem I added it to the official knowledge base.

SharpDX samples updated

In the hope of resuming the series of SharpDX articles that I started writing nearly two years ago, the existing ones (Your first DirectX 11 Metro application using SharpDX and Basic Direct2D drawing with SharpDX) have been updated to Visual Studio 2012 and SharpDX 2.5.0. And as a bonus, the source code has been migrated from a single CodePlex project to separate GitHub repositories. You can find the basic SharpDX tutorial here and the Direct2D one here.