Skip to content

Commit e790d5e

Browse files
authored
Fix nullability annotations in SystemTextJsonSerializer (#123)
Fix nullability annotations in `SystemTextJsonSerializer`.
1 parent 7c87cd8 commit e790d5e

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/Elastic.Transport/Components/Serialization/SystemTextJsonSerializer.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33
// See the LICENSE file in the project root for more information
44

55
using System;
6-
using System.Collections.Generic;
76
using System.IO;
87
using System.Text.Json;
9-
using System.Text.Json.Serialization;
108
using System.Threading;
119
using System.Threading.Tasks;
1210

@@ -18,8 +16,8 @@ namespace Elastic.Transport;
1816
/// </summary>
1917
public abstract class SystemTextJsonSerializer : Serializer
2018
{
21-
private readonly JsonSerializerOptions? _options;
22-
private readonly JsonSerializerOptions? _indentedOptions;
19+
private readonly JsonSerializerOptions _options;
20+
private readonly JsonSerializerOptions _indentedOptions;
2321

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

9795
private static bool TryReturnDefault<T>(Stream? stream, out T deserialize)

src/Elastic.Transport/Components/Serialization/TransportSerializerExtensions.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ public static string SerializeToString(
185185
return ms.Utf8String();
186186
}
187187

188-
#region STJ Extensions
189-
190188
/// <summary>
191189
/// Extension method that writes the serialized representation of an instance of <typeparamref name="T"/> to a
192190
/// <see cref="Utf8JsonWriter"/>.
@@ -633,6 +631,4 @@ public static void Serialize(
633631

634632
return serializer.Deserialize(type, ms);
635633
}
636-
637-
#endregion STJ Extensions
638634
}

0 commit comments

Comments
 (0)