@@ -58,7 +58,7 @@ public SystemTextJsonSerializer(IElasticsearchClientSettings settings)
58
58
/// be used when serializing.
59
59
/// </summary>
60
60
/// <returns></returns>
61
- protected abstract JsonSerializerOptions CreateJsonSerializerOptions ( ) ;
61
+ protected abstract JsonSerializerOptions ? CreateJsonSerializerOptions ( ) ;
62
62
63
63
/// <inheritdoc />
64
64
public override T Deserialize < T > ( Stream stream )
@@ -72,7 +72,7 @@ public override T Deserialize<T>(Stream stream)
72
72
}
73
73
74
74
/// <inheritdoc />
75
- public override object Deserialize ( Type type , Stream stream )
75
+ public override object ? Deserialize ( Type type , Stream stream )
76
76
{
77
77
Initialize ( ) ;
78
78
@@ -90,7 +90,7 @@ public override ValueTask<T> DeserializeAsync<T>(Stream stream, CancellationToke
90
90
}
91
91
92
92
/// <inheritdoc />
93
- public override ValueTask < object > DeserializeAsync ( Type type , Stream stream , CancellationToken cancellationToken = default )
93
+ public override ValueTask < object ? > DeserializeAsync ( Type type , Stream stream , CancellationToken cancellationToken = default )
94
94
{
95
95
Initialize ( ) ;
96
96
return JsonSerializer . DeserializeAsync ( stream , type , Options , cancellationToken ) ;
@@ -101,8 +101,7 @@ public override void Serialize<T>(T data, Stream writableStream,
101
101
SerializationFormatting formatting = SerializationFormatting . None )
102
102
{
103
103
Initialize ( ) ;
104
- using var writer = new Utf8JsonWriter ( writableStream ) ;
105
- JsonSerializer . Serialize ( writer , data , typeof ( T ) , formatting == SerializationFormatting . Indented && IndentedOptions is not null ? IndentedOptions : Options ) ;
104
+ JsonSerializer . Serialize ( writableStream , data , formatting == SerializationFormatting . Indented && IndentedOptions is not null ? IndentedOptions : Options ) ;
106
105
}
107
106
108
107
/// <inheritdoc />
@@ -117,7 +116,7 @@ public override Task SerializeAsync<T>(T data, Stream stream,
117
116
private static bool TryReturnDefault < T > ( Stream stream , out T deserialize )
118
117
{
119
118
deserialize = default ;
120
- return stream == null || stream == Stream . Null || ( stream . CanSeek && stream . Length == 0 ) ;
119
+ return stream is null || stream == Stream . Null || ( stream . CanSeek && stream . Length == 0 ) ;
121
120
}
122
121
123
122
/// <summary>
@@ -152,12 +151,12 @@ protected void Initialize()
152
151
153
152
private void LinkOptionsAndSettings ( )
154
153
{
155
- if ( ! ElasticsearchClient . SettingsTable . TryGetValue ( Options , out _ ) )
154
+ if ( ! ElasticsearchClient . SettingsTable . TryGetValue ( Options ! , out _ ) )
156
155
{
157
156
ElasticsearchClient . SettingsTable . Add ( Options , Settings ) ;
158
157
}
159
158
160
- if ( ! ElasticsearchClient . SettingsTable . TryGetValue ( IndentedOptions , out _ ) )
159
+ if ( ! ElasticsearchClient . SettingsTable . TryGetValue ( IndentedOptions ! , out _ ) )
161
160
{
162
161
ElasticsearchClient . SettingsTable . Add ( IndentedOptions , Settings ) ;
163
162
}
0 commit comments