-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* DoubleWithFractionalPortionConverter and FloatWithFractionalPortionConverter should not fall through to always throw a JSONException for non NETCore builds (#7753) * Complted buckets JSON converter (#7738) * Boosted non-exhaustive enum deserialization (#7737) * Optimized `FieldConverter` (#7736) * Removed unused JsonIgnore (#7735) * Fixed the equality contract on Metrics type (#7733) * No allocations in ResponseItem IsValid prop (#7731) * Refactoring and tiny behavior fix for Ids (#7730) --------- Co-authored-by: Florian Bernd <git@flobernd.de> Co-authored-by: Karl-Johan Sjögren <karl.sjogren@gmail.com> Co-authored-by: Yoh Deadfall <yoh.deadfall@hotmail.com>
- Loading branch information
1 parent
1bd2994
commit 8a9f285
Showing
25 changed files
with
156 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
namespace Elastic.Clients.Elasticsearch.Core; | ||
|
||
internal interface IEnumStruct<TSelf> where TSelf : struct, IEnumStruct<TSelf> | ||
{ | ||
// TODO: Can be made static when targeting .NET 7 and higher | ||
TSelf Create(string value); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
src/Elastic.Clients.Elasticsearch/Core/Infer/Id/IdsConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Licensed to Elasticsearch B.V under one or more agreements. | ||
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Elastic.Clients.Elasticsearch; | ||
|
||
internal sealed class IdsConverter : JsonConverter<Ids> | ||
{ | ||
public override Ids? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) | ||
{ | ||
if (reader.TokenType != JsonTokenType.StartArray) | ||
throw new JsonException($"Unexpected JSON token. Expected {JsonTokenType.StartArray} but read {reader.TokenType}"); | ||
|
||
var ids = new List<Id>(); | ||
|
||
while (reader.Read() && reader.TokenType != JsonTokenType.EndArray) | ||
{ | ||
var id = JsonSerializer.Deserialize<Id>(ref reader, options); | ||
|
||
if (id is not null) | ||
ids.Add(id); | ||
} | ||
|
||
return new Ids(ids); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, Ids value, JsonSerializerOptions options) | ||
{ | ||
if (value is null) | ||
{ | ||
writer.WriteNullValue(); | ||
return; | ||
} | ||
|
||
writer.WriteStartArray(); | ||
|
||
foreach (var id in value.IdsToSerialize) | ||
{ | ||
JsonSerializer.Serialize<Id>(writer, id, options); | ||
} | ||
|
||
writer.WriteEndArray(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.