https://github.com/dotnet/orleans/blob/86db32b40f3e5585267123a4704edad34df8b40b/src/Orleans.Core/Messaging/PrefixingBufferWriter.cs#L128C17-L128C55
There is technically an off-by-one error when the remaining buffer size is equal to the sizeHint. I don't think this code path is even referenced, but it's worth knowing.