From acd7765074ceb9e652e68c74288aa556c9e94d66 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Fri, 27 Sep 2024 11:45:02 +0200 Subject: [PATCH] Fix (de-)serialization of `Fields` in custom converters (#8360) --- .../Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs | 2 +- .../_Generated/Api/SearchRequest.g.cs | 2 +- .../_Generated/Types/Core/MSearch/MultisearchBody.g.cs | 5 +++-- .../_Generated/Types/Core/Search/SourceFilter.g.cs | 10 ++++++---- .../Core/Infer/Field/Field.cs | 2 +- .../Core/Infer/Fields/Fields.cs | 2 +- .../Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs | 2 +- .../_Generated/Api/SearchRequest.g.cs | 2 +- .../_Generated/Types/Core/MSearch/MultisearchBody.g.cs | 5 +++-- .../_Generated/Types/Core/Search/SourceFilter.g.cs | 10 ++++++---- 10 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs index eaa612fb23a..3619775104c 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs @@ -606,7 +606,7 @@ public override void Write(Utf8JsonWriter writer, SubmitAsyncSearchRequest value if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs index a117fb67133..43b83d2d913 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Api/SearchRequest.g.cs @@ -660,7 +660,7 @@ public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSeria if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index 7d80571faa9..e3593c503c5 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -185,7 +185,8 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve if (property == "stored_fields") { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.StoredFields = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } @@ -380,7 +381,7 @@ public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSer if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs index 6a454e55072..476fc65d917 100644 --- a/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch.Serverless/_Generated/Types/Core/Search/SourceFilter.g.cs @@ -41,13 +41,15 @@ public override SourceFilter Read(ref Utf8JsonReader reader, Type typeToConvert, var property = reader.GetString(); if (property == "excludes" || property == "exclude") { - variant.Excludes = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.Excludes = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } if (property == "includes" || property == "include") { - variant.Includes = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.Includes = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } } @@ -62,13 +64,13 @@ public override void Write(Utf8JsonWriter writer, SourceFilter value, JsonSerial if (value.Excludes is not null) { writer.WritePropertyName("excludes"); - JsonSerializer.Serialize(writer, value.Excludes, options); + new FieldsConverter().Write(writer, value.Excludes, options); } if (value.Includes is not null) { writer.WritePropertyName("includes"); - JsonSerializer.Serialize(writer, value.Includes, options); + new FieldsConverter().Write(writer, value.Includes, options); } writer.WriteEndObject(); diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Field/Field.cs b/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Field/Field.cs index 6ecff34ef00..2b0aef9bd91 100644 --- a/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Field/Field.cs +++ b/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Field/Field.cs @@ -20,7 +20,7 @@ namespace Elastic.Clients.Elasticsearch; #endif [JsonConverter(typeof(FieldConverter))] -[DebuggerDisplay($"{nameof(DebuggerDisplay)},nq")] +[DebuggerDisplay($"{{{nameof(DebuggerDisplay)},nq}}")] public sealed class Field : IEquatable, IUrlParameter diff --git a/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Fields/Fields.cs b/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Fields/Fields.cs index 0112a9e2f2b..cf610735c72 100644 --- a/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Fields/Fields.cs +++ b/src/Elastic.Clients.Elasticsearch.Shared/Core/Infer/Fields/Fields.cs @@ -18,7 +18,7 @@ namespace Elastic.Clients.Elasticsearch.Serverless; namespace Elastic.Clients.Elasticsearch; #endif -[DebuggerDisplay($"{nameof(DebuggerDisplay)},nq")] +[DebuggerDisplay($"{{{nameof(DebuggerDisplay)},nq}}")] public sealed class Fields : IEquatable, IEnumerable, diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs index 9b8f681bf1b..aa79a1aaf15 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/SubmitAsyncSearchRequest.g.cs @@ -606,7 +606,7 @@ public override void Write(Utf8JsonWriter writer, SubmitAsyncSearchRequest value if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs index c0126e9aec1..2f7583f26a0 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Api/SearchRequest.g.cs @@ -669,7 +669,7 @@ public override void Write(Utf8JsonWriter writer, SearchRequest value, JsonSeria if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs index eba508a1054..1cac0049899 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/MSearch/MultisearchBody.g.cs @@ -185,7 +185,8 @@ public override MultisearchBody Read(ref Utf8JsonReader reader, Type typeToConve if (property == "stored_fields") { - variant.StoredFields = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.StoredFields = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } @@ -380,7 +381,7 @@ public override void Write(Utf8JsonWriter writer, MultisearchBody value, JsonSer if (value.StoredFields is not null) { writer.WritePropertyName("stored_fields"); - JsonSerializer.Serialize(writer, value.StoredFields, options); + new FieldsConverter().Write(writer, value.StoredFields, options); } if (value.Suggest is not null) diff --git a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs index 64dbc8a8257..ecf27ebf675 100644 --- a/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs +++ b/src/Elastic.Clients.Elasticsearch/_Generated/Types/Core/Search/SourceFilter.g.cs @@ -41,13 +41,15 @@ public override SourceFilter Read(ref Utf8JsonReader reader, Type typeToConvert, var property = reader.GetString(); if (property == "excludes" || property == "exclude") { - variant.Excludes = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.Excludes = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } if (property == "includes" || property == "include") { - variant.Includes = JsonSerializer.Deserialize(ref reader, options); + reader.Read(); + variant.Includes = new FieldsConverter().Read(ref reader, typeToConvert, options); continue; } } @@ -62,13 +64,13 @@ public override void Write(Utf8JsonWriter writer, SourceFilter value, JsonSerial if (value.Excludes is not null) { writer.WritePropertyName("excludes"); - JsonSerializer.Serialize(writer, value.Excludes, options); + new FieldsConverter().Write(writer, value.Excludes, options); } if (value.Includes is not null) { writer.WritePropertyName("includes"); - JsonSerializer.Serialize(writer, value.Includes, options); + new FieldsConverter().Write(writer, value.Includes, options); } writer.WriteEndObject();