Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/HotChocolate/Json/src/Json/JsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@ public JsonWriter(
_maxDepth = options.MaxDepth == 0 ? 64 : options.MaxDepth;
}

/// <summary>
/// Resets the writer so it can be reused with a new buffer,
/// avoiding allocations when the writer is pooled.
/// </summary>
/// <param name="writer">The new buffer writer to write to.</param>
public void Reset(IBufferWriter<byte> writer)
{
ArgumentNullException.ThrowIfNull(writer);

_writer = writer;
_currentDepth = 0;
_tokenType = default;
_containerTypeStack = 0;
_realWriter = null;
_savedCurrentDepth = 0;
_savedTokenType = default;
}

/// <summary>
/// Gets the custom behavior when writing JSON using
/// the <see cref="Utf8JsonWriter"/> which indicates whether to format the output
Expand All @@ -77,7 +95,7 @@ public JsonWriter(
public JsonNullIgnoreCondition NullIgnoreCondition { get; set; }

/// <summary>
/// Getswha a value indicating whether null fields should be omitted
/// Gets a value indicating whether null fields should be omitted
/// when writing JSON objects.
/// </summary>
public bool IgnoreNullFields
Expand Down
Loading