With the new SizeField and other dynamic length methods, do you think its worth adding a very basic auto generated span length check property for the entire packet? Something like the following could be a nice to have little feature, especially when packets have dynamic length fields:
public bool HasValidSpanLength () => _span.Length <= GetTotalSize();
Or maybe even a generated TryParsePacket static method, where you want to create a packet over an existing packet buffer:
public static bool TryParse(Span<byte> packetData, out MyPacketSpan packet)
{
var myPacket = new MyPacketSpan(packetData);
if (myPacket.HasValidSpanLength())
{
packet = myPacket;
return true;
}
packet = null;
return false;
}