Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullability annotations in SystemTextJsonSerializer #123

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
// See the LICENSE file in the project root for more information

using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -18,8 +16,8 @@ namespace Elastic.Transport;
/// </summary>
public abstract class SystemTextJsonSerializer : Serializer
{
private readonly JsonSerializerOptions? _options;
private readonly JsonSerializerOptions? _indentedOptions;
private readonly JsonSerializerOptions _options;
private readonly JsonSerializerOptions _indentedOptions;

/// <summary>
/// An abstract implementation of a transport <see cref="Serializer"/> which serializes using the Microsoft
Expand Down Expand Up @@ -90,8 +88,8 @@ public override Task SerializeAsync<T>(T data, Stream stream,
/// Returns the <see cref="JsonSerializerOptions"/> for this serializer, based on the given <paramref name="formatting"/>.
/// </summary>
/// <param name="formatting">The serialization formatting.</param>
/// <returns>The requested <see cref="JsonSerializerOptions"/> or <c>null</c>, if the serializer is not initialized yet.</returns>
protected internal JsonSerializerOptions? GetJsonSerializerOptions(SerializationFormatting formatting = SerializationFormatting.None) =>
/// <returns>The requested <see cref="JsonSerializerOptions"/>.</returns>
protected internal JsonSerializerOptions GetJsonSerializerOptions(SerializationFormatting formatting = SerializationFormatting.None) =>
formatting is SerializationFormatting.None ? _options : _indentedOptions;

private static bool TryReturnDefault<T>(Stream? stream, out T deserialize)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ public static string SerializeToString(
return ms.Utf8String();
}

#region STJ Extensions

/// <summary>
/// Extension method that writes the serialized representation of an instance of <typeparamref name="T"/> to a
/// <see cref="Utf8JsonWriter"/>.
Expand Down Expand Up @@ -633,6 +631,4 @@ public static void Serialize(

return serializer.Deserialize(type, ms);
}

#endregion STJ Extensions
}
Loading