From 2de82aab724ecbd571e9fed09a9dd7f202c54a50 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Thu, 19 Oct 2023 21:54:22 -0500 Subject: [PATCH] Switched "ISubBinaryWriter" to "IBinaryWriter", for consistency with "IBinaryReader". --- README.md | 2 +- Schema Build Tests/build/Types.cs | 2 +- Schema Tests/SchemaWriterGeneratorTests.cs | 24 +++++++++---------- .../attributes/align/AlignGeneratorTests.cs | 8 +++---- .../child_of/IChildOfGeneratorTests.cs | 8 +++---- .../endianness/EndiannessGeneratorTests.cs | 6 ++--- .../attributes/ignore/IgnoreGeneratorTests.cs | 2 +- .../attributes/memory/MemoryGeneratorTests.cs | 2 +- .../memory/PointerToGeneratorTests.cs | 8 +++---- .../method/ReadLogicAttributeTests.cs | 2 +- .../RSequenceLengthSourceAttributeTests.cs | 8 +++---- ...RSequenceUntilEndOfStreamAttributeTests.cs | 2 +- .../WLengthOfSequenceAttributeTests.cs | 6 ++--- .../size/SizeOfMemberInBytesGeneratorTests.cs | 8 +++---- ...codedNullTerminatedStringAttributeTests.cs | 6 ++--- .../NullTerminatedStringAttributeTests.cs | 6 ++--- .../RStringLengthSourceAttributeTests.cs | 10 ++++---- .../StringLengthSourceAttributeTests_Const.cs | 4 ++-- ...ingLengthSourceAttributeTests_Immediate.cs | 4 ++-- .../string/WLengthOfStringAttributeTests.cs | 4 ++-- .../binary/generator/BooleanGeneratorTests.cs | 8 +++---- .../binary/generator/CharGeneratorTests.cs | 4 ++-- .../binary/generator/EnumGeneratorTests.cs | 4 ++-- .../binary/generator/GenericGeneratorTests.cs | 12 +++++----- .../binary/generator/HalfGeneratorTests.cs | 2 +- .../generator/IfBooleanGeneratorTests.cs | 6 ++--- .../binary/generator/Int24GeneratorTests.cs | 4 ++-- .../generator/NamespaceGeneratorTests.cs | 8 +++---- .../generator/NullableGeneratorTests.cs | 2 +- .../generator/PositionGeneratorTests.cs | 2 +- .../generator/RAtOffsetGeneratorTests.cs | 4 ++-- .../SequenceLengthSourceGeneratorTests.cs | 4 ++-- Schema/src/binary/Interfaces.cs | 2 +- .../text/BinarySchemaWriterGenerator.cs | 2 +- ...naryWriter.cs => ITopLevelBinaryWriter.cs} | 6 ++--- .../src/binary/writer/SchemaBinaryWriter.cs | 2 +- .../SchemaEndianBinaryWriter_Delayed.cs | 2 +- 37 files changed, 98 insertions(+), 98 deletions(-) rename Schema/src/binary/writer/{IBinaryWriter.cs => ITopLevelBinaryWriter.cs} (96%) diff --git a/README.md b/README.md index 0272c78..fb50982 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Any readonly primitives will treated as assertions, which is useful for validati For complicated schema classes, such as ones that use decompression logic or pointers, you'll need to implement the read/write logic manually. -Specifically, you'll need to implement both a `Read(IBinaryReader br)` and `Write(ISubBinaryWriter bw)` method. +Specifically, you'll need to implement both a `Read(IBinaryReader br)` and `Write(IBinaryWriter bw)` method. The `SchemaBinaryReader` and `SchemaBinaryWriter` classes provide many helpful methods for reading/writing a number of different primitive formats, including basic ones such as `byte`/`int`/`float`, but also more complex/unique ones such as `Half` (two-byte float) and `un16` (unsigned normalized 16-bit float). Similar to the automatic process, you can nest schema classes and manually read/write them by calling their `Read()`/`Write()` methods. diff --git a/Schema Build Tests/build/Types.cs b/Schema Build Tests/build/Types.cs index 4b96046..bc809f2 100644 --- a/Schema Build Tests/build/Types.cs +++ b/Schema Build Tests/build/Types.cs @@ -76,7 +76,7 @@ public interface IMagicSection { public class MagicSectionStub : IMagicSection, IBinaryConvertible { public T Data { get; set; } - public void Write(ISubBinaryWriter ew) { } + public void Write(IBinaryWriter ew) { } public void Read(IBinaryReader br) { } } diff --git a/Schema Tests/SchemaWriterGeneratorTests.cs b/Schema Tests/SchemaWriterGeneratorTests.cs index cf893f1..87a52ed 100644 --- a/Schema Tests/SchemaWriterGeneratorTests.cs +++ b/Schema Tests/SchemaWriterGeneratorTests.cs @@ -22,7 +22,7 @@ public partial class ByteWrapper { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Field); } } @@ -46,7 +46,7 @@ public partial class SByteWrapper { namespace foo.bar { public partial class SByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteSByte(this.Field); } } @@ -70,7 +70,7 @@ public partial class ShortWrapper { namespace foo.bar { public partial class ShortWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt16(this.Field); } } @@ -94,7 +94,7 @@ public partial class ArrayWrapper { namespace foo.bar { public partial class ArrayWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32s(this.field); } } @@ -121,7 +121,7 @@ public partial class ArrayWrapper { namespace foo.bar { public partial class ArrayWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(this.length); bw.WriteInt32s(this.field); } @@ -158,7 +158,7 @@ namespace foo.bar { static internal partial class Parent { protected partial class Middle { private partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(this.length); bw.WriteInt32((int) this.value); } @@ -185,7 +185,7 @@ public partial class CharWrapper { namespace foo.bar { public partial class CharWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteChars(this.Array); } } @@ -209,7 +209,7 @@ public partial class ShortWrapper { namespace foo.bar { public partial class ShortWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt16(this.Field); } } @@ -233,7 +233,7 @@ public class ByteWrapper { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.field); } } @@ -257,7 +257,7 @@ public class ByteWrapper { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.field); } } @@ -281,7 +281,7 @@ public partial class ByteWrapper { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Field); } } @@ -341,7 +341,7 @@ public partial class Other : IBinaryConvertible { namespace foo.bar { public partial class EverythingWrapper { - public void Write(ISubBinaryWriter bw) {" + + public void Write(IBinaryWriter bw) {" + @" bw.WriteString(this.magicText);" + @" diff --git a/Schema Tests/binary/attributes/align/AlignGeneratorTests.cs b/Schema Tests/binary/attributes/align/AlignGeneratorTests.cs index e501506..5102beb 100644 --- a/Schema Tests/binary/attributes/align/AlignGeneratorTests.cs +++ b/Schema Tests/binary/attributes/align/AlignGeneratorTests.cs @@ -33,7 +33,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class AlignWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.Align(2); bw.WriteByte(this.Field); } @@ -75,7 +75,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class AlignWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Value); bw.Align(Value); bw.WriteByte(this.Field); @@ -122,7 +122,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class AlignWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Wrapper.Write(bw); bw.Align(Wrapper.Value); bw.WriteByte(this.Field); @@ -168,7 +168,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class AlignWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32((uint) this.Field.Length); bw.Align(2); bw.WriteInt32s(this.Field); diff --git a/Schema Tests/binary/attributes/child_of/IChildOfGeneratorTests.cs b/Schema Tests/binary/attributes/child_of/IChildOfGeneratorTests.cs index 8005734..9308c50 100644 --- a/Schema Tests/binary/attributes/child_of/IChildOfGeneratorTests.cs +++ b/Schema Tests/binary/attributes/child_of/IChildOfGeneratorTests.cs @@ -37,7 +37,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ChildOfWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Field); } } @@ -80,7 +80,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Parent { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Child.Write(bw); } } @@ -122,7 +122,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ChildOfWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { } } } @@ -170,7 +170,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Parent { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Length); foreach (var e in this.Child) { e.Write(bw); diff --git a/Schema Tests/binary/attributes/endianness/EndiannessGeneratorTests.cs b/Schema Tests/binary/attributes/endianness/EndiannessGeneratorTests.cs index 5f9ef5d..2864d09 100644 --- a/Schema Tests/binary/attributes/endianness/EndiannessGeneratorTests.cs +++ b/Schema Tests/binary/attributes/endianness/EndiannessGeneratorTests.cs @@ -30,7 +30,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class EndiannessWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Field); } } @@ -75,7 +75,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class EndiannessWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Field1); bw.PushMemberEndianness(Endianness.BigEndian); bw.WriteUInt32(this.Field2); @@ -121,7 +121,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class EndiannessWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.PushContainerEndianness(Endianness.BigEndian); bw.WriteUInt32(this.Field1); bw.WriteUInt32(this.Field2); diff --git a/Schema Tests/binary/attributes/ignore/IgnoreGeneratorTests.cs b/Schema Tests/binary/attributes/ignore/IgnoreGeneratorTests.cs index ea074db..6404024 100644 --- a/Schema Tests/binary/attributes/ignore/IgnoreGeneratorTests.cs +++ b/Schema Tests/binary/attributes/ignore/IgnoreGeneratorTests.cs @@ -31,7 +31,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class IgnoreWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { } } } diff --git a/Schema Tests/binary/attributes/memory/MemoryGeneratorTests.cs b/Schema Tests/binary/attributes/memory/MemoryGeneratorTests.cs index ee9e228..7097ba1 100644 --- a/Schema Tests/binary/attributes/memory/MemoryGeneratorTests.cs +++ b/Schema Tests/binary/attributes/memory/MemoryGeneratorTests.cs @@ -46,7 +46,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class BlockWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt64(this.Size); br.WriteInt64(this.Offset); this.Pointer.Write(bw); diff --git a/Schema Tests/binary/attributes/memory/PointerToGeneratorTests.cs b/Schema Tests/binary/attributes/memory/PointerToGeneratorTests.cs index 7d23288..5d51a61 100644 --- a/Schema Tests/binary/attributes/memory/PointerToGeneratorTests.cs +++ b/Schema Tests/binary/attributes/memory/PointerToGeneratorTests.cs @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result)); bw.MarkStartOfMember(""Foo""); bw.WriteByte(this.Foo); @@ -83,7 +83,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo.Bar"").ContinueWith(task => (uint) task.Result)); bw.MarkStartOfMember(""Foo""); this.Foo.Write(bw); @@ -133,7 +133,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetPointerToMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result)); } } @@ -158,7 +158,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ParentImpl { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Child.Write(bw); bw.MarkStartOfMember(""Foo""); bw.WriteByte(this.Foo); diff --git a/Schema Tests/binary/attributes/method/ReadLogicAttributeTests.cs b/Schema Tests/binary/attributes/method/ReadLogicAttributeTests.cs index 92c38b4..5d3fe8f 100644 --- a/Schema Tests/binary/attributes/method/ReadLogicAttributeTests.cs +++ b/Schema Tests/binary/attributes/method/ReadLogicAttributeTests.cs @@ -38,7 +38,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Field1); bw.WriteByte(this.Field2); } diff --git a/Schema Tests/binary/attributes/sequence/RSequenceLengthSourceAttributeTests.cs b/Schema Tests/binary/attributes/sequence/RSequenceLengthSourceAttributeTests.cs index 5aeb436..b8fdd02 100644 --- a/Schema Tests/binary/attributes/sequence/RSequenceLengthSourceAttributeTests.cs +++ b/Schema Tests/binary/attributes/sequence/RSequenceLengthSourceAttributeTests.cs @@ -33,7 +33,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteBytes(this.Field); } } @@ -78,7 +78,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { for (var i = 0; i < this.Field.Count; ++i) { bw.WriteByte(this.Field[i]); } @@ -118,7 +118,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32s(this.Field); } } @@ -163,7 +163,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { for (var i = 0; i < this.Field.Count; ++i) { bw.WriteInt32(this.Field[i]); } diff --git a/Schema Tests/binary/attributes/sequence/RSequenceUntilEndOfStreamAttributeTests.cs b/Schema Tests/binary/attributes/sequence/RSequenceUntilEndOfStreamAttributeTests.cs index 0390f25..e58c2d8 100644 --- a/Schema Tests/binary/attributes/sequence/RSequenceUntilEndOfStreamAttributeTests.cs +++ b/Schema Tests/binary/attributes/sequence/RSequenceUntilEndOfStreamAttributeTests.cs @@ -41,7 +41,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ReadonlyListClass { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32((uint) Values.Count); for (var i = 0; i < this.Values.Count; ++i) { bw.WriteInt32(this.Values[i]); diff --git a/Schema Tests/binary/attributes/sequence/WLengthOfSequenceAttributeTests.cs b/Schema Tests/binary/attributes/sequence/WLengthOfSequenceAttributeTests.cs index d230bbb..dda4d62 100644 --- a/Schema Tests/binary/attributes/sequence/WLengthOfSequenceAttributeTests.cs +++ b/Schema Tests/binary/attributes/sequence/WLengthOfSequenceAttributeTests.cs @@ -38,7 +38,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SequenceWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Sequence.Length); bw.WriteBytes(this.Sequence); } @@ -82,7 +82,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SequenceWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt16((ushort) Sequence.Length); bw.WriteBytes(this.Sequence); } @@ -136,7 +136,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SequenceWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { Asserts.AllEqual(Sequence1.Length, Sequence2.Count); bw.WriteInt32(Sequence1.Length); bw.WriteBytes(this.Sequence1); diff --git a/Schema Tests/binary/attributes/size/SizeOfMemberInBytesGeneratorTests.cs b/Schema Tests/binary/attributes/size/SizeOfMemberInBytesGeneratorTests.cs index 7739704..23ad0b3 100644 --- a/Schema Tests/binary/attributes/size/SizeOfMemberInBytesGeneratorTests.cs +++ b/Schema Tests/binary/attributes/size/SizeOfMemberInBytesGeneratorTests.cs @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result)); bw.MarkStartOfMember(""Foo""); bw.WriteByte(this.Foo); @@ -83,7 +83,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo.Bar"").ContinueWith(task => (uint) task.Result)); bw.MarkStartOfMember(""Foo""); this.Foo.Write(bw); @@ -133,7 +133,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class SizeWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32Delayed(bw.GetSizeOfMemberRelativeToScope(""Foo"").ContinueWith(task => (uint) task.Result)); } } @@ -158,7 +158,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ParentImpl { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Child.Write(bw); bw.MarkStartOfMember(""Foo""); bw.WriteByte(this.Foo); diff --git a/Schema Tests/binary/attributes/string/EncodedNullTerminatedStringAttributeTests.cs b/Schema Tests/binary/attributes/string/EncodedNullTerminatedStringAttributeTests.cs index 7619c94..ce01951 100644 --- a/Schema Tests/binary/attributes/string/EncodedNullTerminatedStringAttributeTests.cs +++ b/Schema Tests/binary/attributes/string/EncodedNullTerminatedStringAttributeTests.cs @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteStringNT(StringEncodingType.UTF8, this.Field); } } @@ -76,7 +76,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteStringWithExactLength(StringEncodingType.UTF8, this.Field, 16); } } @@ -120,7 +120,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Length); bw.WriteString(StringEncodingType.UTF8, this.Field); } diff --git a/Schema Tests/binary/attributes/string/NullTerminatedStringAttributeTests.cs b/Schema Tests/binary/attributes/string/NullTerminatedStringAttributeTests.cs index 591135b..f55f196 100644 --- a/Schema Tests/binary/attributes/string/NullTerminatedStringAttributeTests.cs +++ b/Schema Tests/binary/attributes/string/NullTerminatedStringAttributeTests.cs @@ -32,7 +32,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteStringNT(this.Field); } } @@ -70,7 +70,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteStringWithExactLength(this.Field, 16); } } @@ -111,7 +111,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Length); bw.WriteString(this.Field); } diff --git a/Schema Tests/binary/attributes/string/RStringLengthSourceAttributeTests.cs b/Schema Tests/binary/attributes/string/RStringLengthSourceAttributeTests.cs index 1528ffe..8b7ccc2 100644 --- a/Schema Tests/binary/attributes/string/RStringLengthSourceAttributeTests.cs +++ b/Schema Tests/binary/attributes/string/RStringLengthSourceAttributeTests.cs @@ -36,7 +36,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Field.Length); bw.WriteString(this.Field); } @@ -78,7 +78,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Field.Length); bw.WriteString(this.Field); } @@ -120,7 +120,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Field.Length); bw.WriteString(this.Field); } @@ -162,7 +162,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Field.Length); bw.WriteString(this.Field); } @@ -204,7 +204,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(Field.Length); bw.WriteString(this.Field); } diff --git a/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Const.cs b/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Const.cs index f718f88..7b61773 100644 --- a/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Const.cs +++ b/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Const.cs @@ -30,7 +30,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class StringWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteString(this.Field); } } @@ -67,7 +67,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class StringWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteStringWithExactLength(this.Field, 3); } } diff --git a/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Immediate.cs b/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Immediate.cs index d07a045..7caf61d 100644 --- a/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Immediate.cs +++ b/Schema Tests/binary/attributes/string/StringLengthSourceAttributeTests_Immediate.cs @@ -35,7 +35,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32((uint) this.Field.Length); bw.WriteString(this.Field); } @@ -76,7 +76,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ImmediateLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.Field.Length); bw.WriteString(this.Field); } diff --git a/Schema Tests/binary/attributes/string/WLengthOfStringAttributeTests.cs b/Schema Tests/binary/attributes/string/WLengthOfStringAttributeTests.cs index 082892c..ef4fb16 100644 --- a/Schema Tests/binary/attributes/string/WLengthOfStringAttributeTests.cs +++ b/Schema Tests/binary/attributes/string/WLengthOfStringAttributeTests.cs @@ -36,7 +36,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32((uint) Text.Length); bw.WriteString(this.Text); } @@ -84,7 +84,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NtsWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { Asserts.AllEqual(Text1.Length, Text2.Length); bw.WriteUInt32((uint) Text1.Length); bw.WriteString(this.Text1); diff --git a/Schema Tests/binary/generator/BooleanGeneratorTests.cs b/Schema Tests/binary/generator/BooleanGeneratorTests.cs index a9c1639..f2d6dc2 100644 --- a/Schema Tests/binary/generator/BooleanGeneratorTests.cs +++ b/Schema Tests/binary/generator/BooleanGeneratorTests.cs @@ -36,7 +36,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) (this.Field ? 1 : 0)); bw.WriteByte((byte) (this.ReadonlyField ? 1 : 0)); } @@ -79,7 +79,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt16((short) (this.Field ? 1 : 0)); bw.WriteInt16((short) (this.ReadonlyField ? 1 : 0)); } @@ -122,7 +122,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32(this.Field ? 1 : 0); bw.WriteInt32(this.ReadonlyField ? 1 : 0); } @@ -166,7 +166,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { for (var i = 0; i < this.Field.Length; ++i) { bw.WriteByte((byte) (this.Field[i] ? 1 : 0)); } diff --git a/Schema Tests/binary/generator/CharGeneratorTests.cs b/Schema Tests/binary/generator/CharGeneratorTests.cs index 6d74d1f..7e028ab 100644 --- a/Schema Tests/binary/generator/CharGeneratorTests.cs +++ b/Schema Tests/binary/generator/CharGeneratorTests.cs @@ -34,7 +34,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteChar(this.Field); bw.WriteChar(this.ReadonlyField); } @@ -75,7 +75,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteChars(this.Field); } } diff --git a/Schema Tests/binary/generator/EnumGeneratorTests.cs b/Schema Tests/binary/generator/EnumGeneratorTests.cs index 3c94702..23aa9d1 100644 --- a/Schema Tests/binary/generator/EnumGeneratorTests.cs +++ b/Schema Tests/binary/generator/EnumGeneratorTests.cs @@ -40,7 +40,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class EnumWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.fieldA); bw.WriteInt32((int) this.fieldB); } @@ -90,7 +90,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class EnumWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { for (var i = 0; i < this.fieldA.Length; ++i) { bw.WriteByte((byte) this.fieldA[i]); } diff --git a/Schema Tests/binary/generator/GenericGeneratorTests.cs b/Schema Tests/binary/generator/GenericGeneratorTests.cs index 134abb1..8c24de5 100644 --- a/Schema Tests/binary/generator/GenericGeneratorTests.cs +++ b/Schema Tests/binary/generator/GenericGeneratorTests.cs @@ -30,7 +30,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class GenericWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Data.Write(bw); } } @@ -69,7 +69,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class GenericWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Data1.Write(bw); this.Data2.Write(bw); } @@ -107,7 +107,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class GenericWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { foreach (var e in this.Data) { e.Write(bw); } @@ -145,7 +145,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class GenericWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { } } } @@ -164,7 +164,7 @@ public interface IMagicSection { public class MagicSectionStub : IMagicSection, IBinaryConvertible { public T Data { get; set; } - public void Write(ISubBinaryWriter bw) { } + public void Write(IBinaryWriter bw) { } public void Read(IBinaryReader br) { } } @@ -195,7 +195,7 @@ public void Read(IBinaryReader br) { using schema.binary; public partial class SwitchMagicStringUInt32SizedSection { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.impl_.Write(bw); } } diff --git a/Schema Tests/binary/generator/HalfGeneratorTests.cs b/Schema Tests/binary/generator/HalfGeneratorTests.cs index 0f5ba0e..45f4935 100644 --- a/Schema Tests/binary/generator/HalfGeneratorTests.cs +++ b/Schema Tests/binary/generator/HalfGeneratorTests.cs @@ -42,7 +42,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class HalfWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteHalf((float) this.field1); bw.WriteHalf((float) this.field2); for (var i = 0; i < this.field3.Length; ++i) { diff --git a/Schema Tests/binary/generator/IfBooleanGeneratorTests.cs b/Schema Tests/binary/generator/IfBooleanGeneratorTests.cs index e5d5505..81982d3 100644 --- a/Schema Tests/binary/generator/IfBooleanGeneratorTests.cs +++ b/Schema Tests/binary/generator/IfBooleanGeneratorTests.cs @@ -56,7 +56,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) (this.ImmediateValue != null ? 1 : 0)); if (this.ImmediateValue != null) { this.ImmediateValue.Write(bw); @@ -111,7 +111,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) (this.Field ? 1 : 0)); if (this.Field) { bw.WriteInt32(this.OtherValue.Value); @@ -163,7 +163,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ByteWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Field.Write(bw); if (this.Field.Bool) { bw.WriteInt32(this.OtherValue.Value); diff --git a/Schema Tests/binary/generator/Int24GeneratorTests.cs b/Schema Tests/binary/generator/Int24GeneratorTests.cs index 4868398..01ba24f 100644 --- a/Schema Tests/binary/generator/Int24GeneratorTests.cs +++ b/Schema Tests/binary/generator/Int24GeneratorTests.cs @@ -36,7 +36,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Int24Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt24(this.field1); bw.WriteInt24(this.field2); } @@ -78,7 +78,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class UInt24Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt24(this.field1); bw.WriteUInt24(this.field2); } diff --git a/Schema Tests/binary/generator/NamespaceGeneratorTests.cs b/Schema Tests/binary/generator/NamespaceGeneratorTests.cs index 123cf7c..5c202c9 100644 --- a/Schema Tests/binary/generator/NamespaceGeneratorTests.cs +++ b/Schema Tests/binary/generator/NamespaceGeneratorTests.cs @@ -33,7 +33,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.Field); } } @@ -73,7 +73,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.Field); } } @@ -113,7 +113,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.Field); } } @@ -155,7 +155,7 @@ public void Read(IBinaryReader br) { namespace foo.bar.gar { public partial class Wrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) this.Field); } } diff --git a/Schema Tests/binary/generator/NullableGeneratorTests.cs b/Schema Tests/binary/generator/NullableGeneratorTests.cs index dc32de9..dc600bf 100644 --- a/Schema Tests/binary/generator/NullableGeneratorTests.cs +++ b/Schema Tests/binary/generator/NullableGeneratorTests.cs @@ -34,7 +34,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class NullableWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte((byte) (this.Field1.Value ? 1 : 0)); bw.WriteInt32(this.Field2.Value); } diff --git a/Schema Tests/binary/generator/PositionGeneratorTests.cs b/Schema Tests/binary/generator/PositionGeneratorTests.cs index 2833acd..b4e7fdc 100644 --- a/Schema Tests/binary/generator/PositionGeneratorTests.cs +++ b/Schema Tests/binary/generator/PositionGeneratorTests.cs @@ -39,7 +39,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class PositionWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Value); } } diff --git a/Schema Tests/binary/generator/RAtOffsetGeneratorTests.cs b/Schema Tests/binary/generator/RAtOffsetGeneratorTests.cs index c2fa729..65b9cf1 100644 --- a/Schema Tests/binary/generator/RAtOffsetGeneratorTests.cs +++ b/Schema Tests/binary/generator/RAtOffsetGeneratorTests.cs @@ -39,7 +39,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class OffsetWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteUInt32(this.Offset); bw.WriteByte(this.Field); } @@ -90,7 +90,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class OffsetWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteByte(this.Field); } } diff --git a/Schema Tests/binary/generator/SequenceLengthSourceGeneratorTests.cs b/Schema Tests/binary/generator/SequenceLengthSourceGeneratorTests.cs index 3154fca..9583413 100644 --- a/Schema Tests/binary/generator/SequenceLengthSourceGeneratorTests.cs +++ b/Schema Tests/binary/generator/SequenceLengthSourceGeneratorTests.cs @@ -69,7 +69,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ConstLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { bw.WriteInt32s(this.Field); bw.WriteInt32s(this.NullableField); if (this.Toggle) { @@ -121,7 +121,7 @@ public void Read(IBinaryReader br) { namespace foo.bar { public partial class ConstLengthWrapper { - public void Write(ISubBinaryWriter bw) { + public void Write(IBinaryWriter bw) { this.Field.Write(bw); } } diff --git a/Schema/src/binary/Interfaces.cs b/Schema/src/binary/Interfaces.cs index 1b7331a..bf64db8 100644 --- a/Schema/src/binary/Interfaces.cs +++ b/Schema/src/binary/Interfaces.cs @@ -4,7 +4,7 @@ namespace schema.binary { public interface IBinary { } public interface IBinarySerializable : IBinary { - void Write(ISubBinaryWriter ew); + void Write(IBinaryWriter ew); } public interface IBinaryDeserializable : IBinary { diff --git a/Schema/src/binary/text/BinarySchemaWriterGenerator.cs b/Schema/src/binary/text/BinarySchemaWriterGenerator.cs index 804716c..e3c39d3 100644 --- a/Schema/src/binary/text/BinarySchemaWriterGenerator.cs +++ b/Schema/src/binary/text/BinarySchemaWriterGenerator.cs @@ -58,7 +58,7 @@ public string Generate(IBinarySchemaContainer container) { cbsb.EnterBlock(SymbolTypeUtil.GetQualifiersAndNameFor(typeSymbol)); - cbsb.EnterBlock($"public void Write(ISubBinaryWriter {WRITER})"); + cbsb.EnterBlock($"public void Write(IBinaryWriter {WRITER})"); { var hasLocalPositions = container.LocalPositions; if (hasLocalPositions) { diff --git a/Schema/src/binary/writer/IBinaryWriter.cs b/Schema/src/binary/writer/ITopLevelBinaryWriter.cs similarity index 96% rename from Schema/src/binary/writer/IBinaryWriter.cs rename to Schema/src/binary/writer/ITopLevelBinaryWriter.cs index be08f13..5618428 100644 --- a/Schema/src/binary/writer/IBinaryWriter.cs +++ b/Schema/src/binary/writer/ITopLevelBinaryWriter.cs @@ -6,12 +6,12 @@ using schema.util.streams; namespace schema.binary { - public interface IBinaryWriter : ISubBinaryWriter, IDisposable { + public interface ITopLevelBinaryWriter : IBinaryWriter, IDisposable { Task CompleteAndCopyToDelayed(Stream stream); Task CompleteAndCopyToDelayed(ISizedWritableStream stream); } - public interface ISubBinaryWriter + public interface IBinaryWriter : IDataWriter, IEndiannessStack, ILocalSpaceStack { void Align(uint amt); @@ -99,7 +99,7 @@ void WriteStringWithExactLength(StringEncodingType encodingType, // Delayed - ISubBinaryWriter EnterBlock(out Task delayedLength); + IBinaryWriter EnterBlock(out Task delayedLength); Task GetAbsolutePosition(); Task GetAbsoluteLength(); diff --git a/Schema/src/binary/writer/SchemaBinaryWriter.cs b/Schema/src/binary/writer/SchemaBinaryWriter.cs index 8f11892..112364a 100644 --- a/Schema/src/binary/writer/SchemaBinaryWriter.cs +++ b/Schema/src/binary/writer/SchemaBinaryWriter.cs @@ -12,7 +12,7 @@ namespace schema.binary { - public sealed partial class SchemaBinaryWriter : IBinaryWriter { + public sealed partial class SchemaBinaryWriter : ITopLevelBinaryWriter { private readonly IDelayedContentOutputStream impl_; private bool disposed_; diff --git a/Schema/src/binary/writer/SchemaEndianBinaryWriter_Delayed.cs b/Schema/src/binary/writer/SchemaEndianBinaryWriter_Delayed.cs index e94e78e..cc4e6a5 100644 --- a/Schema/src/binary/writer/SchemaEndianBinaryWriter_Delayed.cs +++ b/Schema/src/binary/writer/SchemaEndianBinaryWriter_Delayed.cs @@ -8,7 +8,7 @@ namespace schema.binary { public sealed partial class SchemaBinaryWriter { - public ISubBinaryWriter EnterBlock(out Task delayedLength) + public IBinaryWriter EnterBlock(out Task delayedLength) => new SchemaBinaryWriter(this.Endianness, this.impl_.EnterBlock(out delayedLength));