Skip to content

Commit

Permalink
add a comment explaining why we do this instead of Skip()
Browse files Browse the repository at this point in the history
(IMO, Skip() really should have been implemented this way, but whatever)
  • Loading branch information
airbreather committed Apr 24, 2024
1 parent bbd3fa1 commit 0a570c1
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/NetTopologySuite.IO.GeoJSON4STJ/Converters/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> 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();
Expand Down

0 comments on commit 0a570c1

Please sign in to comment.