A C# library that can read and write primitives, enums, arrays, and strings to streams and byte arrays with specified endianness, string encoding, and boolean sizes.
For example, if using BytesToInt16s<ushort>(), and a negative short value is read, the crash will occur because a ushort will not hold the value. I thought it'd cast to a ushort.
Every property is checked for attributes even if the types will not use the attributes. This is very slow.
String null termination checking should be better; currently it will default to null termination unless there's a string length attribute. Attributes should be enforced.
The char counts used are for C# strings, which are UTF16 by default. Therefore, a surrogate pair in a UTF16 C# string is 2 chars, but 1 char in UTF32. Writing will write 2 chars technically, and you'd want to read 1 UTF32 char. However, it will only be the first half of the surrogate pair when converted to a string, since the char array will be shrunk down to 1
Reading should throw an error on EndianBinaryIO's side because the underlying type would be unknown.
Writing should not throw; it instead should use value.GetType() instead of typeof(TEnum) to fetch the correct type rather than Enum itself in this case
Should String and char[] be flipped with endianness (note BigEndianUnicode)?
Will the current implementation always work? Encoding sizes for each char might be different depending on the char, so I think PeekChar and ReadChar will be broken under some circumstances.
UTF requires variable length chars for some (except for UTF-32)
I knew this when I started the library, but I was never sure how to tackle this properly with streams.
What license of this library under? It would be good to add a license file to the project - either publish it under a permissive license, or, alternately, under LGPL license (the library is being used by https://github.com/Kermalis/VGMusicStudio project, whose source code is under LGPL license).