Azure / DotNetty

DotNetty project – a port of netty, event-driven asynchronous network application framework
Other
4.09k stars 977 forks source link

Why no WriteUnsignedInt/WriteUnsignedIntLE methods? #611

Open Himmelt opened 1 year ago

Himmelt commented 1 year ago

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

ScarletKuro commented 1 year ago

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.

Himmelt commented 1 year ago

@ScarletKuro Thanks, it works.