void CheckType(DebugSerializeType expectedType, int expectedBitCount) { var type = (DebugSerializeType)bitStream.ReadBits(4); var bitCount = bitStream.ReadBits(7); if (bitCount != expectedBitCount) { throw new Exception($"Expected type {expectedType} bitcount {expectedBitCount} received type {type} {bitCount}"); } if (type != expectedType) { throw new Exception($"Expected type {expectedType} received {type}"); } }