Skip to content

Commit d080c68

Browse files
authored
Refactor to file-scoped namespaces (#6793)
1 parent 8654e98 commit d080c68

File tree

83 files changed

+4102
-4190
lines changed

Some content is hidden

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

83 files changed

+4102
-4190
lines changed

src/Elastic.Clients.Elasticsearch.JsonNetSerializer/ConnectionSettingsAwareSerializerBase.Customization.cs

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,70 +7,68 @@
77
using System.Text;
88
using System.Threading;
99
using System.Threading.Tasks;
10-
using Elastic.Clients.Elasticsearch;
1110
using Elastic.Transport;
1211
using Newtonsoft.Json;
1312

14-
namespace Elastic.Clients.Elasticsearch.JsonNetSerializer
13+
namespace Elastic.Clients.Elasticsearch.JsonNetSerializer;
14+
15+
public abstract partial class ConnectionSettingsAwareSerializer : Serializer
1516
{
16-
public abstract partial class ConnectionSettingsAwareSerializer : Serializer
17-
{
18-
// Default buffer size of StreamWriter, which is private :(
19-
internal const int DefaultBufferSize = 1024;
17+
// Default buffer size of StreamWriter, which is private :(
18+
internal const int DefaultBufferSize = 1024;
2019

21-
private static readonly Task CompletedTask = Task.CompletedTask;
20+
private static readonly Task CompletedTask = Task.CompletedTask;
2221

23-
internal static readonly Encoding ExpectedEncoding = new UTF8Encoding(false);
24-
private readonly JsonSerializer _collapsedSerializer;
22+
internal static readonly Encoding ExpectedEncoding = new UTF8Encoding(false);
23+
private readonly JsonSerializer _collapsedSerializer;
2524

26-
private readonly JsonSerializer _serializer;
27-
protected virtual int BufferSize => DefaultBufferSize;
25+
private readonly JsonSerializer _serializer;
26+
protected virtual int BufferSize => DefaultBufferSize;
2827

29-
public override T Deserialize<T>(Stream stream)
30-
{
31-
using var streamReader = new StreamReader(stream);
32-
using var jsonTextReader = new JsonTextReader(streamReader);
33-
return _serializer.Deserialize<T>(jsonTextReader);
34-
}
28+
public override T Deserialize<T>(Stream stream)
29+
{
30+
using var streamReader = new StreamReader(stream);
31+
using var jsonTextReader = new JsonTextReader(streamReader);
32+
return _serializer.Deserialize<T>(jsonTextReader);
33+
}
3534

36-
public override object Deserialize(Type type, Stream stream)
37-
{
38-
using var streamReader = new StreamReader(stream);
39-
using var jsonTextReader = new JsonTextReader(streamReader);
40-
return _serializer.Deserialize(jsonTextReader, type);
41-
}
35+
public override object Deserialize(Type type, Stream stream)
36+
{
37+
using var streamReader = new StreamReader(stream);
38+
using var jsonTextReader = new JsonTextReader(streamReader);
39+
return _serializer.Deserialize(jsonTextReader, type);
40+
}
4241

43-
public override async ValueTask<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default)
44-
{
45-
using var streamReader = new StreamReader(stream);
46-
using var jsonTextReader = new JsonTextReader(streamReader);
47-
var token = await jsonTextReader.ReadTokenWithDateParseHandlingNoneAsync(cancellationToken).ConfigureAwait(false);
48-
return token.ToObject<T>(_serializer);
49-
}
42+
public override async ValueTask<T> DeserializeAsync<T>(Stream stream, CancellationToken cancellationToken = default)
43+
{
44+
using var streamReader = new StreamReader(stream);
45+
using var jsonTextReader = new JsonTextReader(streamReader);
46+
var token = await jsonTextReader.ReadTokenWithDateParseHandlingNoneAsync(cancellationToken).ConfigureAwait(false);
47+
return token.ToObject<T>(_serializer);
48+
}
5049

51-
public override async ValueTask<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
52-
{
53-
using var streamReader = new StreamReader(stream);
54-
using var jsonTextReader = new JsonTextReader(streamReader);
55-
var token = await jsonTextReader.ReadTokenWithDateParseHandlingNoneAsync(cancellationToken).ConfigureAwait(false);
56-
return token.ToObject(type, _serializer);
57-
}
50+
public override async ValueTask<object> DeserializeAsync(Type type, Stream stream, CancellationToken cancellationToken = default(CancellationToken))
51+
{
52+
using var streamReader = new StreamReader(stream);
53+
using var jsonTextReader = new JsonTextReader(streamReader);
54+
var token = await jsonTextReader.ReadTokenWithDateParseHandlingNoneAsync(cancellationToken).ConfigureAwait(false);
55+
return token.ToObject(type, _serializer);
56+
}
5857

59-
public override void Serialize<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.None)
60-
{
61-
using var writer = new StreamWriter(stream, ExpectedEncoding, BufferSize, true);
62-
using var jsonWriter = new JsonTextWriter(writer);
63-
var serializer = formatting == SerializationFormatting.Indented ? _serializer : _collapsedSerializer;
64-
serializer.Serialize(jsonWriter, data);
65-
}
58+
public override void Serialize<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.None)
59+
{
60+
using var writer = new StreamWriter(stream, ExpectedEncoding, BufferSize, true);
61+
using var jsonWriter = new JsonTextWriter(writer);
62+
var serializer = formatting == SerializationFormatting.Indented ? _serializer : _collapsedSerializer;
63+
serializer.Serialize(jsonWriter, data);
64+
}
6665

67-
public override Task SerializeAsync<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.None,
68-
CancellationToken cancellationToken = default)
69-
{
70-
//This makes no sense now but we need the async method on the interface in 6.x so we can start swapping this out
71-
//for an implementation that does make sense without having to wait for 7.x
72-
Serialize(data, stream, formatting);
73-
return CompletedTask;
74-
}
66+
public override Task SerializeAsync<T>(T data, Stream stream, SerializationFormatting formatting = SerializationFormatting.None,
67+
CancellationToken cancellationToken = default)
68+
{
69+
//This makes no sense now but we need the async method on the interface in 6.x so we can start swapping this out
70+
//for an implementation that does make sense without having to wait for 7.x
71+
Serialize(data, stream, formatting);
72+
return CompletedTask;
7573
}
7674
}

src/Elastic.Clients.Elasticsearch/Api/AsyncSearch/AsyncSearchSubmitRequest.cs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,28 @@
55
using System;
66
using Elastic.Clients.Elasticsearch.QueryDsl;
77

8-
namespace Elastic.Clients.Elasticsearch.AsyncSearch
8+
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
9+
10+
public partial class AsyncSearchSubmitRequest
911
{
10-
public partial class AsyncSearchSubmitRequest
11-
{
12-
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
13-
internal override void BeforeRequest() => TypedKeys = true;
14-
}
12+
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
13+
internal override void BeforeRequest() => TypedKeys = true;
14+
}
1515

16-
public sealed partial class AsyncSearchSubmitRequestDescriptor
17-
{
18-
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
16+
public sealed partial class AsyncSearchSubmitRequestDescriptor
17+
{
18+
public AsyncSearchSubmitRequestDescriptor MatchAll(Action<MatchAllQueryDescriptor>? selector = null) => selector is null ? Query(q => q.MatchAll()) : Query(q => q.MatchAll(selector));
1919

20-
internal override void BeforeRequest() => TypedKeys(true);
21-
}
20+
internal override void BeforeRequest() => TypedKeys(true);
21+
}
2222

23-
public sealed partial class AsyncSearchSubmitRequestDescriptor<TDocument>
23+
public sealed partial class AsyncSearchSubmitRequestDescriptor<TDocument>
24+
{
25+
public AsyncSearchSubmitRequestDescriptor<TDocument> MatchAll()
2426
{
25-
public AsyncSearchSubmitRequestDescriptor<TDocument> MatchAll()
26-
{
27-
Query(new MatchAllQuery());
28-
return Self;
29-
}
30-
31-
internal override void BeforeRequest() => TypedKeys(true);
27+
Query(new MatchAllQuery());
28+
return Self;
3229
}
30+
31+
internal override void BeforeRequest() => TypedKeys(true);
3332
}

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,22 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information.
44

5-
namespace Elastic.Clients.Elasticsearch.AsyncSearch
5+
namespace Elastic.Clients.Elasticsearch.AsyncSearch;
6+
7+
public partial class GetAsyncSearchRequest
68
{
7-
public partial class GetAsyncSearchRequest
8-
{
9-
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
10-
internal override void BeforeRequest() => TypedKeys = true;
11-
}
9+
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
10+
internal override void BeforeRequest() => TypedKeys = true;
11+
}
1212

13-
public sealed partial class GetAsyncSearchRequestDescriptor<TDocument>
14-
{
15-
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
16-
internal override void BeforeRequest() => TypedKeys(true);
17-
}
13+
public sealed partial class GetAsyncSearchRequestDescriptor<TDocument>
14+
{
15+
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
16+
internal override void BeforeRequest() => TypedKeys(true);
17+
}
1818

19-
public sealed partial class GetAsyncSearchRequestDescriptor
20-
{
21-
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
22-
internal override void BeforeRequest() => TypedKeys(true);
23-
}
19+
public sealed partial class GetAsyncSearchRequestDescriptor
20+
{
21+
// Any request may contain aggregations so we force typed_keys in order to successfully deserialise them.
22+
internal override void BeforeRequest() => TypedKeys(true);
2423
}

0 commit comments

Comments
 (0)