Unity 5 RC1 and il2cpp build

Soo, after a few hours BinaryReaderExtension looks this:

public static class BinaryReaderExtension

{
public static bool IsEndOfStream(this System.IO.BinaryReader reader)
{
return reader.BaseStream.Position == reader.BaseStream.Length;
}

public static int ReadInt32(this System.IO.BinaryReader reader)
{
	int result = 0;

	if (reader.IsEndOfStream())
		return result;

	byte[] intBytes = null;

	intBytes = reader.ReadBytes(4);
	if (intBytes.Length > 0)
		result = System.BitConverter.ToInt32(intBytes, 0);

	return result;

}

public static uint ReadUInt32(this System.IO.BinaryReader reader)
{
	uint result = 0;

	if (reader.IsEndOfStream())
		return result;

	byte[] intBytes = null;

	intBytes = reader.ReadBytes(4);
	if (intBytes.Length > 0)
		result = System.BitConverter.ToUInt32(intBytes, 0);

	return result;

}

public static ushort ReadUInt16(this System.IO.BinaryReader reader)
{
	ushort result = 0;

	if (reader.IsEndOfStream())
		return result;

	byte[] intBytes = null;

	intBytes = reader.ReadBytes(2);
	if (intBytes.Length > 0)
		result = System.BitConverter.ToUInt16(intBytes, 0);

	return result;
}

}

In A* PathFinding I replace any ReadUInt32 and ReadInt32 and ReadUint16 to appropriate method from BinaryReaderExtension class, and now it work (But I don’t know how correct or not, but I don’t see any exceptions in xCode). Also I think, while Unity not fix this bug, need write a wrapper for parsing BinaryReader stream like a BinaryReaderExtension.

Bug Description (Unity5.0.0f4 iOS 64Bit il2cpp): ReadInt32 and other bugged methods get read only ONE BYTE instead 4 byte for 32 bit methods, and 2 bit for 16 bit methods, from input sbyte stream (Aron correct me please, my English is very Bad for describe bug reason)

BuggedMethods (methods that return incorrect value): ReadInt32, ReadUInt32, ReadInt16, ReadUInt16

P.S.: methods ReadSingle work good (just in case I would have to override it in BinaryReaderExtension too)

Today I write bugReport to Unity (if Aron not create bugreport yet)!

Hope this helps to anyone :wink:

1 Like