Skip to content

Update NetDataReader, NetDataWriter & FastBitConverter + add docs#594

Merged
RevenantX merged 12 commits intoRevenantX:masterfrom
Lacyway:master
Mar 22, 2026
Merged

Update NetDataReader, NetDataWriter & FastBitConverter + add docs#594
RevenantX merged 12 commits intoRevenantX:masterfrom
Lacyway:master

Conversation

@Lacyway
Copy link
Copy Markdown
Contributor

@Lacyway Lacyway commented Mar 21, 2026

This PR does 3 things:

  • Update both NetDataReader & NetDataWriter to use faster methods of reading/writing data
  • Update FastBitConverter to use WriteUnaligned<T>()
  • Updates all methods/properties in each class with markup documentation

These methods have been used in Project Fika for a very long time without issue, and as such I have decided to PR them per our discussion on Discord.

No signatures should be changed, meaning users do not have to update anything on their end.

I have included conditional compilation directives where >.NET 8 uses the Unsafe class, and netstandard2.1 (mainly for Unity) uses fixed, which is slower, but does not require external libraries. The difference is so small that it does not warrant the requirement of importing this library:
image

I also changed to Unsafe.WriteUnaligned<T>() in FastBitConverter for >.NET 8 as it is faster when writing unaligned (see benchmark below)
image

I have ran all tests and they are all successful. I also updated the tests to include some of the new methods, e.g. for Unmanaged<T> and Enum. I am unsure how to test this for netstandard2.1 as there are no included tests for it.

Please let me know if you'd like any changes or if there are any questions.

Lacyway added 12 commits March 20, 2026 22:37
- Add documentation
- Update methods to be faster
- Add documentation
- Update methods to be faster
- Added new Get/PutUnmanaged() methods
- Added new GetEnum<T>() method
@RevenantX RevenantX merged commit cd89e7e into RevenantX:master Mar 22, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants