-
Notifications
You must be signed in to change notification settings - Fork 529
Closed
Labels
Description
Some serializers (specifically MessagePack-CSharp) can't read from a Span, but they have no problem reading from Memory. This is already possible using this code:
Memory<byte> myData = reader.RawData.AsMemory(reader.Position, reader.AvailableBytes);
// "reader" is a NetDataReaderTherefore, adding in GetRemainingBytesMemory() is unnecessary, but it would be a nice addition just for completeness. I guess it would be added somewhere around here:
LiteNetLib/LiteNetLib/Utils/NetDataReader.cs
Lines 473 to 479 in d0a2f8d
| #if LITENETLIB_SPANS || NETCOREAPP2_1_OR_GREATER || NETSTANDARD2_1_OR_GREATER || NETCOREAPP2_1 || NETCOREAPP3_1 || NET5_0 || NETSTANDARD2_1 | |
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | |
| public ReadOnlySpan<byte> GetRemainingBytesSpan() | |
| { | |
| return new ReadOnlySpan<byte>(_data, _position, _dataSize - _position); | |
| } | |
| #endif |