Skip to content

Commit b5c10aa

Browse files
committed
Improve serialization
1 parent 5245d06 commit b5c10aa

File tree

1,133 files changed

+64866
-21997
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,133 files changed

+64866
-21997
lines changed

src/Elastic.Clients.Elasticsearch/Elastic.Clients.Elasticsearch.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,14 @@
1616
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
1717
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1818
<Nullable>annotations</Nullable>
19+
<PolySharpIncludeRuntimeSupportedAttributes>true</PolySharpIncludeRuntimeSupportedAttributes>
1920
</PropertyGroup>
2021
<ItemGroup>
2122
<PackageReference Include="Elastic.Transport" Version="0.5.7" />
23+
<PackageReference Include="PolySharp" Version="1.15.0">
24+
<PrivateAssets>all</PrivateAssets>
25+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
26+
</PackageReference>
2227
</ItemGroup>
2328
<ItemGroup>
2429
<InternalsVisibleTo Include="Tests" Key="$(ExposedPublicKey)" />

src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusRequest.g.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ public AsyncSearchStatusRequest(Elastic.Clients.Elasticsearch.Id id) : base(r =>
6464

6565
internal override string OperationName => "async_search.status";
6666

67+
/// <summary>
68+
/// <para>
69+
/// A unique identifier for the async search.
70+
/// </para>
71+
/// </summary>
72+
[JsonIgnore]
73+
public Elastic.Clients.Elasticsearch.Id Id { get => P<Elastic.Clients.Elasticsearch.Id>("id"); set => PR("id", value); }
74+
6775
/// <summary>
6876
/// <para>
6977
/// Specifies how long the async search needs to be available.

src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/AsyncSearchStatusResponse.g.cs

Lines changed: 146 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,156 @@
2222
using Elastic.Transport.Products.Elasticsearch;
2323
using System;
2424
using System.Collections.Generic;
25+
using System.Linq.Expressions;
26+
using System.Text.Json;
2527
using System.Text.Json.Serialization;
2628

2729
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
2830

31+
internal sealed partial class AsyncSearchStatusResponseConverter : System.Text.Json.Serialization.JsonConverter<AsyncSearchStatusResponse>
32+
{
33+
private static readonly System.Text.Json.JsonEncodedText PropClusters = System.Text.Json.JsonEncodedText.Encode("_clusters");
34+
private static readonly System.Text.Json.JsonEncodedText PropCompletionStatus = System.Text.Json.JsonEncodedText.Encode("completion_status");
35+
private static readonly System.Text.Json.JsonEncodedText PropCompletionTime = System.Text.Json.JsonEncodedText.Encode("completion_time");
36+
private static readonly System.Text.Json.JsonEncodedText PropCompletionTimeInMillis = System.Text.Json.JsonEncodedText.Encode("completion_time_in_millis");
37+
private static readonly System.Text.Json.JsonEncodedText PropExpirationTime = System.Text.Json.JsonEncodedText.Encode("expiration_time");
38+
private static readonly System.Text.Json.JsonEncodedText PropExpirationTimeInMillis = System.Text.Json.JsonEncodedText.Encode("expiration_time_in_millis");
39+
private static readonly System.Text.Json.JsonEncodedText PropId = System.Text.Json.JsonEncodedText.Encode("id");
40+
private static readonly System.Text.Json.JsonEncodedText PropIsPartial = System.Text.Json.JsonEncodedText.Encode("is_partial");
41+
private static readonly System.Text.Json.JsonEncodedText PropIsRunning = System.Text.Json.JsonEncodedText.Encode("is_running");
42+
private static readonly System.Text.Json.JsonEncodedText PropShards = System.Text.Json.JsonEncodedText.Encode("_shards");
43+
private static readonly System.Text.Json.JsonEncodedText PropStartTime = System.Text.Json.JsonEncodedText.Encode("start_time");
44+
private static readonly System.Text.Json.JsonEncodedText PropStartTimeInMillis = System.Text.Json.JsonEncodedText.Encode("start_time_in_millis");
45+
46+
public override AsyncSearchStatusResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
47+
{
48+
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
49+
LocalJsonValue<Elastic.Clients.Elasticsearch.ClusterStatistics?> propClusters = default;
50+
LocalJsonValue<int?> propCompletionStatus = default;
51+
LocalJsonValue<DateTimeOffset?> propCompletionTime = default;
52+
LocalJsonValue<long?> propCompletionTimeInMillis = default;
53+
LocalJsonValue<DateTimeOffset?> propExpirationTime = default;
54+
LocalJsonValue<long> propExpirationTimeInMillis = default;
55+
LocalJsonValue<string?> propId = default;
56+
LocalJsonValue<bool> propIsPartial = default;
57+
LocalJsonValue<bool> propIsRunning = default;
58+
LocalJsonValue<Elastic.Clients.Elasticsearch.ShardStatistics> propShards = default;
59+
LocalJsonValue<DateTimeOffset?> propStartTime = default;
60+
LocalJsonValue<long> propStartTimeInMillis = default;
61+
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
62+
{
63+
if (propClusters.TryRead(ref reader, options, PropClusters))
64+
{
65+
continue;
66+
}
67+
68+
if (propCompletionStatus.TryRead(ref reader, options, PropCompletionStatus))
69+
{
70+
continue;
71+
}
72+
73+
if (propCompletionTime.TryRead(ref reader, options, PropCompletionTime))
74+
{
75+
continue;
76+
}
77+
78+
if (propCompletionTimeInMillis.TryRead(ref reader, options, PropCompletionTimeInMillis))
79+
{
80+
continue;
81+
}
82+
83+
if (propExpirationTime.TryRead(ref reader, options, PropExpirationTime))
84+
{
85+
continue;
86+
}
87+
88+
if (propExpirationTimeInMillis.TryRead(ref reader, options, PropExpirationTimeInMillis))
89+
{
90+
continue;
91+
}
92+
93+
if (propId.TryRead(ref reader, options, PropId))
94+
{
95+
continue;
96+
}
97+
98+
if (propIsPartial.TryRead(ref reader, options, PropIsPartial))
99+
{
100+
continue;
101+
}
102+
103+
if (propIsRunning.TryRead(ref reader, options, PropIsRunning))
104+
{
105+
continue;
106+
}
107+
108+
if (propShards.TryRead(ref reader, options, PropShards))
109+
{
110+
continue;
111+
}
112+
113+
if (propStartTime.TryRead(ref reader, options, PropStartTime))
114+
{
115+
continue;
116+
}
117+
118+
if (propStartTimeInMillis.TryRead(ref reader, options, PropStartTimeInMillis))
119+
{
120+
continue;
121+
}
122+
123+
throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'.");
124+
}
125+
126+
reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject);
127+
return new AsyncSearchStatusResponse
128+
{
129+
Clusters = propClusters.Value
130+
,
131+
CompletionStatus = propCompletionStatus.Value
132+
,
133+
CompletionTime = propCompletionTime.Value
134+
,
135+
CompletionTimeInMillis = propCompletionTimeInMillis.Value
136+
,
137+
ExpirationTime = propExpirationTime.Value
138+
,
139+
ExpirationTimeInMillis = propExpirationTimeInMillis.Value
140+
,
141+
Id = propId.Value
142+
,
143+
IsPartial = propIsPartial.Value
144+
,
145+
IsRunning = propIsRunning.Value
146+
,
147+
Shards = propShards.Value
148+
,
149+
StartTime = propStartTime.Value
150+
,
151+
StartTimeInMillis = propStartTimeInMillis.Value
152+
};
153+
}
154+
155+
public override void Write(System.Text.Json.Utf8JsonWriter writer, AsyncSearchStatusResponse value, System.Text.Json.JsonSerializerOptions options)
156+
{
157+
writer.WriteStartObject();
158+
writer.WriteProperty(options, PropClusters, value.Clusters);
159+
writer.WriteProperty(options, PropCompletionStatus, value.CompletionStatus);
160+
writer.WriteProperty(options, PropCompletionTime, value.CompletionTime);
161+
writer.WriteProperty(options, PropCompletionTimeInMillis, value.CompletionTimeInMillis);
162+
writer.WriteProperty(options, PropExpirationTime, value.ExpirationTime);
163+
writer.WriteProperty(options, PropExpirationTimeInMillis, value.ExpirationTimeInMillis);
164+
writer.WriteProperty(options, PropId, value.Id);
165+
writer.WriteProperty(options, PropIsPartial, value.IsPartial);
166+
writer.WriteProperty(options, PropIsRunning, value.IsRunning);
167+
writer.WriteProperty(options, PropShards, value.Shards);
168+
writer.WriteProperty(options, PropStartTime, value.StartTime);
169+
writer.WriteProperty(options, PropStartTimeInMillis, value.StartTimeInMillis);
170+
writer.WriteEndObject();
171+
}
172+
}
173+
174+
[JsonConverter(typeof(AsyncSearchStatusResponseConverter))]
29175
public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
30176
{
31177
/// <summary>
@@ -34,7 +180,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
34180
/// Not shown for local-only searches.
35181
/// </para>
36182
/// </summary>
37-
[JsonInclude, JsonPropertyName("_clusters")]
38183
public Elastic.Clients.Elasticsearch.ClusterStatistics? Clusters { get; init; }
39184

40185
/// <summary>
@@ -44,7 +189,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
44189
/// 503 indicates that the async search was completed with an error.
45190
/// </para>
46191
/// </summary>
47-
[JsonInclude, JsonPropertyName("completion_status")]
48192
public int? CompletionStatus { get; init; }
49193

50194
/// <summary>
@@ -53,21 +197,16 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
53197
/// when the search has completed.
54198
/// </para>
55199
/// </summary>
56-
[JsonInclude, JsonPropertyName("completion_time")]
57200
public DateTimeOffset? CompletionTime { get; init; }
58-
[JsonInclude, JsonPropertyName("completion_time_in_millis")]
59201
public long? CompletionTimeInMillis { get; init; }
60202

61203
/// <summary>
62204
/// <para>
63205
/// Indicates when the async search will expire.
64206
/// </para>
65207
/// </summary>
66-
[JsonInclude, JsonPropertyName("expiration_time")]
67208
public DateTimeOffset? ExpirationTime { get; init; }
68-
[JsonInclude, JsonPropertyName("expiration_time_in_millis")]
69209
public long ExpirationTimeInMillis { get; init; }
70-
[JsonInclude, JsonPropertyName("id")]
71210
public string? Id { get; init; }
72211

73212
/// <summary>
@@ -76,7 +215,6 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
76215
/// While the query is running, <c>is_partial</c> is always set to <c>true</c>.
77216
/// </para>
78217
/// </summary>
79-
[JsonInclude, JsonPropertyName("is_partial")]
80218
public bool IsPartial { get; init; }
81219

82220
/// <summary>
@@ -85,18 +223,14 @@ public sealed partial class AsyncSearchStatusResponse : ElasticsearchResponse
85223
/// NOTE: If the search failed after some shards returned their results or the node that is coordinating the async search dies, results may be partial even though <c>is_running</c> is <c>false</c>.
86224
/// </para>
87225
/// </summary>
88-
[JsonInclude, JsonPropertyName("is_running")]
89226
public bool IsRunning { get; init; }
90227

91228
/// <summary>
92229
/// <para>
93230
/// Indicates how many shards have run the query so far.
94231
/// </para>
95232
/// </summary>
96-
[JsonInclude, JsonPropertyName("_shards")]
97233
public Elastic.Clients.Elasticsearch.ShardStatistics Shards { get; init; }
98-
[JsonInclude, JsonPropertyName("start_time")]
99234
public DateTimeOffset? StartTime { get; init; }
100-
[JsonInclude, JsonPropertyName("start_time_in_millis")]
101235
public long StartTimeInMillis { get; init; }
102236
}

src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchRequest.g.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public DeleteAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r =>
5757
internal override bool SupportsBody => false;
5858

5959
internal override string OperationName => "async_search.delete";
60+
61+
/// <summary>
62+
/// <para>
63+
/// A unique identifier for the async search.
64+
/// </para>
65+
/// </summary>
66+
[JsonIgnore]
67+
public Elastic.Clients.Elasticsearch.Id Id { get => P<Elastic.Clients.Elasticsearch.Id>("id"); set => PR("id", value); }
6068
}
6169

6270
/// <summary>

src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/DeleteAsyncSearchResponse.g.cs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,52 @@
2222
using Elastic.Transport.Products.Elasticsearch;
2323
using System;
2424
using System.Collections.Generic;
25+
using System.Linq.Expressions;
26+
using System.Text.Json;
2527
using System.Text.Json.Serialization;
2628

2729
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
2830

31+
internal sealed partial class DeleteAsyncSearchResponseConverter : System.Text.Json.Serialization.JsonConverter<DeleteAsyncSearchResponse>
32+
{
33+
private static readonly System.Text.Json.JsonEncodedText PropAcknowledged = System.Text.Json.JsonEncodedText.Encode("acknowledged");
34+
35+
public override DeleteAsyncSearchResponse Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
36+
{
37+
reader.ValidateToken(System.Text.Json.JsonTokenType.StartObject);
38+
LocalJsonValue<bool> propAcknowledged = default;
39+
while (reader.Read() && reader.TokenType is System.Text.Json.JsonTokenType.PropertyName)
40+
{
41+
if (propAcknowledged.TryRead(ref reader, options, PropAcknowledged))
42+
{
43+
continue;
44+
}
45+
46+
throw new System.Text.Json.JsonException($"Unknown JSON property '{reader.GetString()}' for type '{typeToConvert.Name}'.");
47+
}
48+
49+
reader.ValidateToken(System.Text.Json.JsonTokenType.EndObject);
50+
return new DeleteAsyncSearchResponse
51+
{
52+
Acknowledged = propAcknowledged.Value
53+
};
54+
}
55+
56+
public override void Write(System.Text.Json.Utf8JsonWriter writer, DeleteAsyncSearchResponse value, System.Text.Json.JsonSerializerOptions options)
57+
{
58+
writer.WriteStartObject();
59+
writer.WriteProperty(options, PropAcknowledged, value.Acknowledged);
60+
writer.WriteEndObject();
61+
}
62+
}
63+
64+
[JsonConverter(typeof(DeleteAsyncSearchResponseConverter))]
2965
public sealed partial class DeleteAsyncSearchResponse : ElasticsearchResponse
3066
{
3167
/// <summary>
3268
/// <para>
3369
/// For a successful response, this value is always true. On failure, an exception is returned instead.
3470
/// </para>
3571
/// </summary>
36-
[JsonInclude, JsonPropertyName("acknowledged")]
3772
public bool Acknowledged { get; init; }
3873
}

src/Elastic.Clients.Elasticsearch/_Generated/Api/AsyncSearch/GetAsyncSearchRequest.g.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ public GetAsyncSearchRequest(Elastic.Clients.Elasticsearch.Id id) : base(r => r.
8383

8484
internal override string OperationName => "async_search.get";
8585

86+
/// <summary>
87+
/// <para>
88+
/// A unique identifier for the async search.
89+
/// </para>
90+
/// </summary>
91+
[JsonIgnore]
92+
public Elastic.Clients.Elasticsearch.Id Id { get => P<Elastic.Clients.Elasticsearch.Id>("id"); set => PR("id", value); }
93+
8694
/// <summary>
8795
/// <para>
8896
/// Specifies how long the async search should be available in the cluster.

0 commit comments

Comments
 (0)