From 0a570c1bc0675aba0d2a5f96447c9d65ab2351ed Mon Sep 17 00:00:00 2001 From: Joe Amenta Date: Wed, 24 Apr 2024 16:08:21 -0400 Subject: [PATCH] add a comment explaining why we do this instead of Skip() (IMO, Skip() really should have been implemented this way, but whatever) --- src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs b/src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs index 254915c..08c1b02 100644 --- a/src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs +++ b/src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs @@ -64,6 +64,12 @@ internal static void AssertToken(this ref Utf8JsonReader reader, JsonTokenType r [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void SkipOrThrow(this ref Utf8JsonReader reader) { + // #143: Even though JsonConverter always seems to see a Utf8JsonReader positioned on + // a full node, that node might be contained in a larger incomplete block. For whatever + // reason, reader.Skip() throws JsonException immediately if the reader is in a partial + // block, even if the current block has plenty of data to read past it. TrySkip will do + // the right thing, but we should still check the return value to make sure that we get + // a JsonException if the reader *does* terminate abruptly (airbreather 2024-04-24). if (!reader.TrySkip()) { ThrowForUnexpectedPartialJson();