Skip to content

Commit

Permalink
Allow array size 0 + add some string[] methods + array size validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Kermalis committed Sep 8, 2020
1 parent 6975508 commit eb152eb
Show file tree
Hide file tree
Showing 8 changed files with 509 additions and 231 deletions.
52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,32 +63,32 @@ class MyBasicObj
And assume these are our input bytes (in little endian):
### Input Bytes (Little Endian):
```cs
0x00, 0x08,
0xFF, 0x01,
0x00, 0x00, 0x4A, 0x7A, 0x9E, 0x01, 0xC0, 0x08,

0x00, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00,
0x03, 0x00, 0x00, 0x00,
0x04, 0x00, 0x00, 0x00,
0x05, 0x00, 0x00, 0x00,
0x06, 0x00, 0x00, 0x00,
0x07, 0x00, 0x00, 0x00,
0x08, 0x00, 0x00, 0x00,
0x09, 0x00, 0x00, 0x00,
0x0A, 0x00, 0x00, 0x00,
0x0B, 0x00, 0x00, 0x00,
0x0C, 0x00, 0x00, 0x00,
0x0D, 0x00, 0x00, 0x00,
0x0E, 0x00, 0x00, 0x00,
0x0F, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00,

0x45, 0x6E, 0x64, 0x69, 0x61, 0x6E, 0x42, 0x69, 0x6E, 0x61, 0x72, 0x79, 0x49, 0x4F, 0x00,

0x4B, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00
0x00, 0x08, // ShortSizedEnum.Val2
0xFF, 0x01, // (short)0x1FF
0x00, 0x00, 0x4A, 0x7A, 0x9E, 0x01, 0xC0, 0x08, // (DateTime)Dec. 30, 1998
0x00, 0x00, 0x00, 0x00, // (uint)0
0x01, 0x00, 0x00, 0x00, // (uint)1
0x02, 0x00, 0x00, 0x00, // (uint)2
0x03, 0x00, 0x00, 0x00, // (uint)3
0x04, 0x00, 0x00, 0x00, // (uint)4
0x05, 0x00, 0x00, 0x00, // (uint)5
0x06, 0x00, 0x00, 0x00, // (uint)6
0x07, 0x00, 0x00, 0x00, // (uint)7
0x08, 0x00, 0x00, 0x00, // (uint)8
0x09, 0x00, 0x00, 0x00, // (uint)9
0x0A, 0x00, 0x00, 0x00, // (uint)10
0x0B, 0x00, 0x00, 0x00, // (uint)11
0x0C, 0x00, 0x00, 0x00, // (uint)12
0x0D, 0x00, 0x00, 0x00, // (uint)13
0x0E, 0x00, 0x00, 0x00, // (uint)14
0x0F, 0x00, 0x00, 0x00, // (uint)15
0x00, 0x00, 0x00, 0x00, // (bool32)false
0x45, 0x6E, 0x64, 0x69, 0x61, 0x6E, 0x42, 0x69, 0x6E, 0x61, 0x72, 0x79, 0x49, 0x4F, 0x00, // "EndianBinaryIO\0"
0x4B, 0x00, 0x65, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x6C, 0x00, 0x69, 0x00, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, // "Kermalis\0\0"
```

We can read/write the object manually or automatically (with reflection):
Expand Down
2 changes: 1 addition & 1 deletion Source/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public sealed class BinaryArrayFixedLengthAttribute : Attribute

public BinaryArrayFixedLengthAttribute(int length)
{
if (length <= 0)
if (length < 0)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/EndianBinaryIO.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageId>EndianBinaryIO</PackageId>
<Product>EndianBinaryIO</Product>
<AssemblyName>EndianBinaryIO</AssemblyName>
<Version>1.0.2.0</Version>
<Version>1.0.3.0</Version>
<RepositoryUrl>https://github.com/Kermalis/EndianBinaryIO</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<NoWarn />
Expand Down

0 comments on commit eb152eb

Please sign in to comment.