Skip to content

Commit

Permalink
Fix nullability annotations in SystemTextJsonSerializer (#123)
Browse files Browse the repository at this point in the history
Fix nullability annotations in `SystemTextJsonSerializer`.
  • Loading branch information
flobernd authored Oct 16, 2024
1 parent 7c87cd8 commit e790d5e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
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
}

0 comments on commit e790d5e

Please sign in to comment.