Skip to content

Commit 7c364be

Browse files
committed
fixed most stylistic errors and made sure UTF8Json folder stylistic deviations are not flagged as editors in the editor
1 parent 0fca6d0 commit 7c364be

File tree

20 files changed

+121
-167
lines changed

20 files changed

+121
-167
lines changed

.editorconfig

Lines changed: 47 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,85 @@
1-
root=true
2-
3-
[*.cs]
4-
trim_trailing_whitespace=true
5-
insert_final_newline=true
6-
7-
[*]
8-
indent_style = tab
9-
indent_size = 4
10-
11-
[*.cshtml]
12-
indent_style = tab
13-
indent_size = 4
14-
15-
[*.{fs,fsx,yml}]
16-
indent_style = space
17-
indent_size = 4
18-
19-
[*.{md,markdown,json,js,csproj,fsproj,targets,targets,props}]
20-
indent_style = space
21-
indent_size = 2
22-
231
# Dotnet code style settings:
242
[*.{cs,vb}]
253

26-
# ---
27-
# naming conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-naming-conventions
28-
# currently not supported in Rider/Resharper so not using these for now
29-
# ---
30-
31-
# ---
32-
# langugage conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#language-conventions
33-
344
# Sort using and Import directives with System.* appearing first
355
dotnet_sort_system_directives_first = true
366

377
# Prefer this.X except for _fields
388
# TODO can we force _ for private fields?
399
# TODO elevate severity after code cleanup to warning minimum
4010
# TODO use language latest
41-
dotnet_style_qualification_for_field = false:error
42-
dotnet_style_qualification_for_property = false:error
43-
dotnet_style_qualification_for_method = false:error
44-
dotnet_style_qualification_for_event = false:error
11+
dotnet_style_qualification_for_field = false:suggestion
12+
dotnet_style_qualification_for_property = false:suggestion
13+
dotnet_style_qualification_for_method = false:suggestion
14+
dotnet_style_qualification_for_event = false:suggestion
4515

4616
# Use language keywords instead of framework type names for type references
47-
dotnet_style_predefined_type_for_locals_parameters_members = true:error
48-
dotnet_style_predefined_type_for_member_access = true:error
17+
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
18+
dotnet_style_predefined_type_for_member_access = true:suggestion
4919

5020
# Suggest more modern language features when available
51-
dotnet_style_object_initializer = true:error
52-
dotnet_style_collection_initializer = true:error
53-
dotnet_style_explicit_tuple_names = true:error
54-
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
55-
dotnet_style_prefer_inferred_tuple_names = true:error
56-
dotnet_style_coalesce_expression = true:error
57-
dotnet_style_null_propagation = true:error
21+
dotnet_style_object_initializer = true:suggestion
22+
dotnet_style_collection_initializer = true:suggestion
23+
dotnet_style_explicit_tuple_names = true:suggestion
24+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
25+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
26+
dotnet_style_coalesce_expression = true:suggestion
27+
dotnet_style_null_propagation = true:suggestion
5828

59-
dotnet_style_require_accessibility_modifiers = for_non_interface_members:error
60-
dotnet_style_readonly_field = true:error
29+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
30+
dotnet_style_readonly_field = true:suggestion
6131

6232
# CSharp code style settings:
6333
[*.cs]
6434
# Prefer "var" everywhere
65-
csharp_style_var_for_built_in_types = true:error
66-
csharp_style_var_when_type_is_apparent = true:error
67-
csharp_style_var_elsewhere = true:error
35+
csharp_style_var_for_built_in_types = true:suggestion
36+
csharp_style_var_when_type_is_apparent = true:suggestion
37+
csharp_style_var_elsewhere = true:suggestion
6838

69-
csharp_style_expression_bodied_methods = true:error
70-
csharp_style_expression_bodied_constructors = true:error
71-
csharp_style_expression_bodied_operators = true:error
72-
csharp_style_expression_bodied_properties = true:error
73-
csharp_style_expression_bodied_indexers = true:error
74-
csharp_style_expression_bodied_accessors = true:error
39+
csharp_style_expression_bodied_methods = true:suggestion
40+
csharp_style_expression_bodied_constructors = true:suggestion
41+
csharp_style_expression_bodied_operators = true:suggestion
42+
csharp_style_expression_bodied_properties = true:suggestion
43+
csharp_style_expression_bodied_indexers = true:suggestion
44+
csharp_style_expression_bodied_accessors = true:suggestion
7545

7646
# Suggest more modern language features when available
77-
csharp_style_pattern_matching_over_is_with_cast_check = true:error
78-
csharp_style_pattern_matching_over_as_with_null_check = true:error
79-
csharp_style_inlined_variable_declaration = true:error
80-
csharp_style_deconstructed_variable_declaration = true:error
81-
csharp_style_pattern_local_over_anonymous_function = true:error
82-
csharp_style_throw_expression = true:error
83-
csharp_style_conditional_delegate_call = true:error
47+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
48+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
49+
csharp_style_inlined_variable_declaration = true:suggestion
50+
csharp_style_deconstructed_variable_declaration = true:suggestion
51+
csharp_style_pattern_local_over_anonymous_function = true:suggestion
52+
csharp_style_throw_expression = true:suggestion
53+
csharp_style_conditional_delegate_call = true:suggestion
8454

85-
csharp_prefer_braces = false:warning
86-
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:error
55+
csharp_prefer_braces = false:suggestion
56+
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
8757

8858
# ---
8959
# formatting conventions https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions
9060

9161
# Newline settings (Allman yo!)
92-
csharp_new_line_before_open_brace = all:error
93-
csharp_new_line_before_else = true:error
94-
csharp_new_line_before_catch = true:error
95-
csharp_new_line_before_finally = true:error
62+
csharp_new_line_before_open_brace = all:suggestion
63+
csharp_new_line_before_else = true:suggestion
64+
csharp_new_line_before_catch = true:suggestion
65+
csharp_new_line_before_finally = true:suggestion
9666
csharp_new_line_before_members_in_object_initializers = true
9767
# just a suggestion do to our JSON tests that use anonymous types to
9868
# represent json quite a bit (makes copy paste easier).
9969
csharp_new_line_before_members_in_anonymous_types = true:suggestion
100-
csharp_new_line_between_query_expression_clauses = true:error
70+
csharp_new_line_between_query_expression_clauses = true:suggestion
10171

10272
# Indent
103-
csharp_indent_case_contents = true:error
104-
csharp_indent_switch_labels = true:error
105-
csharp_space_after_cast = false:error
106-
csharp_space_after_keywords_in_control_flow_statements = true:error
107-
csharp_space_between_method_declaration_parameter_list_parentheses = false:error
108-
csharp_space_between_method_call_parameter_list_parentheses = false:error
73+
csharp_indent_case_contents = true:suggestion
74+
csharp_indent_switch_labels = true:suggestion
75+
csharp_space_after_cast = false:suggestion
76+
csharp_space_after_keywords_in_control_flow_statements = true:suggestion
77+
csharp_space_between_method_declaration_parameter_list_parentheses = false:suggestion
78+
csharp_space_between_method_call_parameter_list_parentheses = false:suggestion
10979

11080
#Wrap
111-
csharp_preserve_single_line_statements = false:error
112-
csharp_preserve_single_line_blocks = true:error
81+
csharp_preserve_single_line_statements = false:suggestion
82+
csharp_preserve_single_line_blocks = true:suggestion
11383

11484
# Resharper
11585
resharper_csharp_braces_for_lock=required_for_complex
@@ -123,7 +93,7 @@ resharper_csharp_braces_for_ifelse=required_for_complex
12393
resharper_csharp_accessor_owner_body=expression_body
12494

12595
# Override source included files
126-
[{SimpleJson|SynchronizedCollection}.cs]
96+
[SynchronizedCollection.cs]
12797
csharp_style_var_for_built_in_types = false:none
12898
csharp_style_var_when_type_is_apparent = false:none
12999
csharp_style_var_elsewhere = false:none

src/Elasticsearch.Net/Extensions/Extensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal static string Utf8String(this MemoryStream ms)
2222
if (ms is null)
2323
return null;
2424

25-
if (!ms.TryGetBuffer(out ArraySegment<byte> buffer) || buffer.Array is null)
25+
if (!ms.TryGetBuffer(out var buffer) || buffer.Array is null)
2626
return Encoding.UTF8.GetString(ms.ToArray());
2727

2828
return Encoding.UTF8.GetString(buffer.Array, buffer.Offset, buffer.Count);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Collections.Specialized;
4+
using System.Linq;
5+
using System.Text;
6+
7+
namespace Elasticsearch.Net
8+
{
9+
internal static class NameValueCollectionExtensions
10+
{
11+
internal static string ToQueryString(this NameValueCollection nv)
12+
{
13+
if (nv == null || nv.AllKeys.Length == 0) return string.Empty;
14+
15+
// initialize with capacity for number of key/values with length 5 each
16+
var builder = new StringBuilder("?", nv.AllKeys.Length * 2 * 5);
17+
for (var i = 0; i < nv.AllKeys.Length; i++)
18+
{
19+
if (i != 0)
20+
builder.Append("&");
21+
22+
var key = nv.AllKeys[i];
23+
builder.Append(Uri.EscapeDataString(key));
24+
builder.Append("=");
25+
builder.Append(Uri.EscapeDataString(nv[key]));
26+
}
27+
28+
return builder.ToString();
29+
}
30+
31+
internal static void UpdateFromDictionary(this NameValueCollection queryString, Dictionary<string, object> queryStringUpdates,
32+
ElasticsearchUrlFormatter provider
33+
)
34+
{
35+
if (queryString == null || queryString.Count < 0) return;
36+
if (queryStringUpdates == null || queryStringUpdates.Count < 0) return;
37+
38+
foreach (var kv in queryStringUpdates.Where(kv => !Extensions.IsNullOrEmpty(kv.Key)))
39+
{
40+
if (kv.Value == null)
41+
{
42+
queryString.Remove(kv.Key);
43+
continue;
44+
}
45+
var resolved = provider.CreateString(kv.Value);
46+
if (!resolved.IsNullOrEmpty())
47+
queryString[kv.Key] = resolved;
48+
else
49+
queryString.Remove(kv.Key);
50+
}
51+
}
52+
}
53+
}

src/Elasticsearch.Net/Transport/Pipeline/RequestData.cs

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.IO;
55
using System.Linq;
66
using System.Security.Cryptography.X509Certificates;
7-
using System.Text;
87

98
namespace Elasticsearch.Net
109
{
@@ -142,49 +141,4 @@ private string CreatePathWithQueryStrings(string path, IConnectionConfigurationV
142141
return path;
143142
}
144143
}
145-
146-
internal static class NameValueCollectionExtensions
147-
{
148-
internal static string ToQueryString(this NameValueCollection nv)
149-
{
150-
if (nv == null || nv.AllKeys.Length == 0) return string.Empty;
151-
152-
// initialize with capacity for number of key/values with length 5 each
153-
var builder = new StringBuilder("?", nv.AllKeys.Length * 2 * 5);
154-
for (int i = 0; i < nv.AllKeys.Length; i++)
155-
{
156-
if (i != 0)
157-
builder.Append("&");
158-
159-
var key = nv.AllKeys[i];
160-
builder.Append(Uri.EscapeDataString(key));
161-
builder.Append("=");
162-
builder.Append(Uri.EscapeDataString(nv[key]));
163-
}
164-
165-
return builder.ToString();
166-
}
167-
168-
internal static void UpdateFromDictionary(this NameValueCollection queryString, Dictionary<string, object> queryStringUpdates,
169-
ElasticsearchUrlFormatter provider
170-
)
171-
{
172-
if (queryString == null || queryString.Count < 0) return;
173-
if (queryStringUpdates == null || queryStringUpdates.Count < 0) return;
174-
175-
foreach (var kv in queryStringUpdates.Where(kv => !kv.Key.IsNullOrEmpty()))
176-
{
177-
if (kv.Value == null)
178-
{
179-
queryString.Remove(kv.Key);
180-
continue;
181-
}
182-
var resolved = provider.CreateString(kv.Value);
183-
if (!resolved.IsNullOrEmpty())
184-
queryString[kv.Key] = resolved;
185-
else
186-
queryString.Remove(kv.Key);
187-
}
188-
}
189-
}
190144
}

src/Nest/CommonAbstractions/Infer/Fields/FieldsFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public void Serialize(ref JsonWriter writer, Fields value, IJsonFormatterResolve
3636

3737
var fields = value.ListOfFields;
3838
writer.WriteBeginArray();
39-
for (int i = 0; i < fields.Count; i++)
39+
for (var i = 0; i < fields.Count; i++)
4040
{
4141
if (i > 0)
4242
writer.WriteValueSeparator();

src/Nest/CommonAbstractions/LazyDocument/LazyDocumentFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static void WriteUnindented(ref JsonReader reader, ref JsonWriter write
7878
break;
7979
case JsonToken.Number:
8080
var segment = reader.ReadNumberSegment();
81-
for (int i = 0; i < segment.Count; i++)
81+
for (var i = 0; i < segment.Count; i++)
8282
writer.WriteRawUnsafe(segment.Array[i + segment.Offset]);
8383
break;
8484
case JsonToken.String:

src/Tests/Tests/ClientConcepts/HighLevel/Caching/FieldResolverCacheTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ public class CachePerformance
477477
private FieldResolver _resolver;
478478
private Stopwatch _stopwatch;
479479

480-
public CachePerformance(ITestOutputHelper output) => this._output = output;
480+
public CachePerformance(ITestOutputHelper output) => _output = output;
481481

482482
[U]
483483
public void CachedVsNonCached()

src/Tests/Tests/Document/Multiple/MultiGet/MultiGetApiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected override void ExpectResponse(MultiGetResponse response)
168168
hit.Id.Should().NotBeNullOrWhiteSpace();
169169
hit.Found.Should().BeTrue();
170170
hit.Version.Should().Be(1);
171-
if (base.Cluster.ClusterConfiguration.Version >= "6.8.0")
171+
if (Cluster.ClusterConfiguration.Version >= "6.8.0")
172172
{
173173
hit.PrimaryTerm.Should().BeGreaterOrEqualTo(1);
174174
hit.SequenceNumber.Should().BeGreaterOrEqualTo(0);

src/Tests/Tests/Document/Single/DocumentCrudTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ [I] protected async Task DocumentIsUpdated() => await AssertOnGetAfterUpdate(r =
7878
{
7979
r.Source.Should().NotBeNull();
8080
r.Version.Should().BeGreaterThan(1);
81-
if (base.Cluster.ClusterConfiguration.Version >= "6.8.0")
81+
if (Cluster.ClusterConfiguration.Version >= "6.8.0")
8282
{
8383
r.SequenceNumber.Should().BeGreaterOrEqualTo(1);
8484
r.PrimaryTerm.Should().BeGreaterThan(0);

src/Tests/Tests/Document/Single/Get/GetApiTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ protected override void ExpectResponse(GetResponse<Project> response)
4747
response.SequenceNumber.Should().HaveValue();
4848
response.PrimaryTerm.Should().HaveValue();
4949
response.Source.ShouldAdhereToSourceSerializerWhenSet();
50-
if (base.Cluster.ClusterConfiguration.Version >= "6.8.0")
50+
if (Cluster.ClusterConfiguration.Version >= "6.8.0")
5151
{
5252
response.SequenceNumber.Should().BeGreaterOrEqualTo(0);
5353
response.PrimaryTerm.Should().BeGreaterOrEqualTo(1);

0 commit comments

Comments
 (0)