in serde-generate/runtime/csharp/Bcs/BcsDeserializer.cs [14:36]
private int deserialize_uleb128_as_u32()
{
long value = 0;
for (int shift = 0; shift < 32; shift += 7)
{
byte x = reader.ReadByte();
byte digit = (byte)(x & 0x7F);
value |= ((long)digit << shift);
if ((value < 0) || (value > int.MaxValue))
{
throw new DeserializationException("Overflow while parsing uleb128-encoded uint32 value");
}
if (digit == x)
{
if (shift > 0 && digit == 0)
{
throw new DeserializationException("Invalid uleb128 number (unexpected zero digit)");
}
return (int)value;
}
}
throw new DeserializationException("Overflow while parsing uleb128-encoded uint32 value");
}