Skip to content

Commit 5c8d9d6

Browse files
committed
fix: add unsigned short write support
1 parent 1cd137d commit 5c8d9d6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

projects/RabbitMQ.Client/client/impl/WireFormatting.Write.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,10 @@ static int WriteFieldValueSlow(ref byte destination, ref byte fieldValue, object
200200
case BinaryTableValue val:
201201
destination = (byte)'x';
202202
return 1 + WriteLongstr(ref fieldValue, val.Bytes);
203+
case ushort val:
204+
destination = (byte)'u';
205+
NetworkOrderSerializer.WriteUInt16(ref fieldValue, val);
206+
return 3;
203207
default:
204208
return ThrowInvalidTableValue(value);
205209
}
@@ -235,6 +239,8 @@ public static int GetFieldValueByteCount(object value)
235239
return 2;
236240
case short _:
237241
return 3;
242+
case ushort _:
243+
return 3;
238244
case uint _:
239245
return 5;
240246
case decimal _:

projects/Unit/TestFieldTableFormatting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void TestQpidJmsTypes()
143143
["f"] = (float)123, // 2+5
144144
["l"] = (long)123, // 2+9
145145
["s"] = (short)123, // 2+2
146-
["u"] = (ushort)123
146+
["u"] = (ushort)123,
147147
["t"] = true // 2+2
148148
};
149149
byte[] xbytes = { 0xaa, 0x55 };

0 commit comments

Comments
 (0)