Encode collections length depending on the protocol version CSHARP-149