DotNetty icon indicating copy to clipboard operation
DotNetty copied to clipboard

Why no WriteUnsignedInt/WriteUnsignedIntLE methods?

Open Himmelt opened this issue 2 years ago • 2 comments

There are ReadUnsignedInt/ReadUnsignedIntLE/GetUnsignedInt/GetUnsignedIntLE/SetUnsignedInt/SetUnsignedIntLE methods, but no WriteUnsignedInt/WriteUnsignedIntLE ? why? How should I do to write an uint with little-endian to the ByteBuf ? https://github.com/Azure/DotNetty/blob/00c23606cc8afb699ee17790c51a85c0abf6d296/src/DotNetty.Buffers/IByteBuffer.cs#L885-L899

Himmelt avatar Aug 17 '23 09:08 Himmelt

Try something like this:

public static IByteBuffer WriteUnsignedInt(this IByteBuffer buffer, uint value)
{
	unchecked
	{
		return buffer.WriteInt((int)value);
	}
}

public static IByteBuffer WriteUnsignedIntLE(this IByteBuffer buffer,uint value)
{
	unchecked
	{
		return buffer.WriteIntLE((int)value);
	}
}

why?

Probably missing by mistake, I would PR them, but this repository is dead.

ScarletKuro avatar Aug 28 '23 09:08 ScarletKuro

@ScarletKuro Thanks, it works.

Himmelt avatar Aug 28 '23 09:08 Himmelt