fix: Adds BitArray support with codegen (#888)

* Adds a custom BitArray class with the following added features:
  * ctor for creating BitArray against read only span
  * ctor for creating BitArray against BinaryReader
  * CopyTo to copy a BitArray to a Span
* Adds BitArray to UO Primitive serialization so it can be codegenned.
This commit is contained in:
Kamron Batman 2021-12-13 09:31:02 -08:00 committed by GitHub
parent 61e2177011
commit b125146b27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1489 additions and 19 deletions

View file

@ -19,6 +19,7 @@ using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using Server.Collections;
using Server.Text;
namespace Server
@ -156,6 +157,19 @@ namespace Server
return length;
}
public BitArray ReadBitArray()
{
var length = ((IGenericReader)this).ReadEncodedInt();
if (length > _buffer.Length - _position)
{
throw new OutOfMemoryException();
}
var bitArray = new BitArray(_buffer.AsSpan(_position, length));
_position += length;
return bitArray;
}
public virtual long Seek(long offset, SeekOrigin origin)
{
Debug.Assert(