.NET: Make serialize methods sync and rename one to match others. (#946)

* Make serialize methods sync and rename one to match others.

* Remove unnecessary async postfixes.

* Remove nullability of ChatMessageStore.Serialize return type, since the default JsonElement already represents an undefined json element.

* Fix unit test
This commit is contained in:
westey
2025-09-29 09:32:01 +00:00
committed by GitHub
parent 7c5b553c7e
commit bf5931932e
21 changed files with 64 additions and 86 deletions
@@ -67,11 +67,10 @@ public abstract class InMemoryAgentThread : AgentThread
/// Serializes the current object's state to a <see cref="JsonElement"/> using the specified serialization options.
/// </summary>
/// <param name="jsonSerializerOptions">The JSON serialization options to use.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> to monitor for cancellation requests. The default is <see cref="CancellationToken.None"/>.</param>
/// <returns>A <see cref="JsonElement"/> representation of the object's state.</returns>
public override async Task<JsonElement> SerializeAsync(JsonSerializerOptions? jsonSerializerOptions = null, CancellationToken cancellationToken = default)
public override JsonElement Serialize(JsonSerializerOptions? jsonSerializerOptions = null)
{
var storeState = await this.MessageStore.SerializeStateAsync(jsonSerializerOptions, cancellationToken).ConfigureAwait(false);
var storeState = this.MessageStore.Serialize(jsonSerializerOptions);
var state = new InMemoryAgentThreadState
{