Skip to content

Commit

Permalink
Fixed stupid bug where I was printing null instead of the expected va…
Browse files Browse the repository at this point in the history
…lue.
  • Loading branch information
MeltyPlayer committed Oct 21, 2024
1 parent 6b0a33f commit 049a234
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
48 changes: 48 additions & 0 deletions Schema Tests/binary/generator/RAtPositionGeneratorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,54 @@ public void Write(IBinaryWriter bw) {
");
}

[Test]
public void TestArrayUntilEndOfStreamAtOffset() {
BinarySchemaTestUtil.AssertGenerated(@"
using schema.binary;
using schema.binary.attributes;
namespace foo.bar {
[BinarySchema]
public partial class OffsetWrapper : IBinaryConvertible {
public uint Offset { get; set; }
[RAtPosition(nameof(Offset))]
[RSequenceUntilEndOfStream]
public byte[] EndOfStreamArray { get; set; }
}
}",
@"using System;
using System.Collections.Generic;
using schema.binary;
namespace foo.bar {
public partial class OffsetWrapper {
public void Read(IBinaryReader br) {
this.Offset = br.ReadUInt32();
{
var tempLocation = br.Position;
br.Position = this.Offset;
this.EndOfStreamArray = br.ReadBytes(br.Length - br.Position);
br.Position = tempLocation;
}
}
}
}
",
@"using System;
using schema.binary;
namespace foo.bar {
public partial class OffsetWrapper {
public void Write(IBinaryWriter bw) {
bw.WriteUInt32(this.Offset);
bw.WriteBytes(this.EndOfStreamArray);
}
}
}
");
}

[Test]
public void TestOffsetFromParent() {
BinarySchemaTestUtil.AssertGenerated(@"
Expand Down
1 change: 0 additions & 1 deletion Schema/src/binary/text/BinarySchemaReaderGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,6 @@ private static void ReadArray_(
HandleAtPosition_(
sw,
member,
"null",
_ => {
var qualifiedElementName
= sourceSymbol.GetQualifiedNameFromCurrentSymbol(
Expand Down

0 comments on commit 049a234

Please sign in to comment.