From 37723a52825d0880af7cc20339021a3789b987cd Mon Sep 17 00:00:00 2001 From: Eric Freed Date: Sat, 26 Aug 2023 20:08:20 -0400 Subject: [PATCH] Fixed nullability --- SharpNBT/TagReader.cs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/SharpNBT/TagReader.cs b/SharpNBT/TagReader.cs index dc2837a..d6206ff 100644 --- a/SharpNBT/TagReader.cs +++ b/SharpNBT/TagReader.cs @@ -16,12 +16,12 @@ public class TagReader : TagIO /// /// Occurs when a tag has been fully deserialized from the stream. /// - public event TagReaderCallback TagRead; + public event TagReaderCallback? TagRead; /// /// Occurs when a tag has been encountered in the stream, after reading the first byte to determine its . /// - public event TagReaderCallback TagEncountered; + public event TagReaderCallback? TagEncountered; private readonly bool leaveOpen; @@ -189,8 +189,6 @@ public class TagReader : TagIO /// The deserialized instance. public IntArrayTag ReadIntArray(bool named = true) { - const int INT_SIZE = sizeof(int); - var name = named ? ReadUTF8String() : null; var count = ReadCount(); @@ -202,8 +200,8 @@ public class TagReader : TagIO return new IntArrayTag(name, array); } - var buffer = new byte[count * INT_SIZE]; - ReadToFixSizedBuffer(buffer, 0, count * INT_SIZE); + var buffer = new byte[count * sizeof(int)]; + ReadToFixSizedBuffer(buffer, 0, count * sizeof(int)); Span values = MemoryMarshal.Cast(buffer); if (SwapEndian) @@ -222,8 +220,6 @@ public class TagReader : TagIO /// The deserialized instance. public LongArrayTag ReadLongArray(bool named = true) { - const int LONG_SIZE = sizeof(long); - var name = named ? ReadUTF8String() : null; var count = ReadCount(); @@ -235,8 +231,8 @@ public class TagReader : TagIO return new LongArrayTag(name, array); } - var buffer = new byte[count * LONG_SIZE]; - ReadToFixSizedBuffer(buffer, 0, count * LONG_SIZE); + var buffer = new byte[count * sizeof(long)]; + ReadToFixSizedBuffer(buffer, 0, count * sizeof(long)); Span values = MemoryMarshal.Cast(buffer); if (SwapEndian)