Skip to content

Commit 7a75117

Browse files
authored
Merge branch 'main' into runtimeconfig-json-fix-publish
2 parents d1afe25 + c6810ca commit 7a75117

File tree

12 files changed

+56
-61
lines changed

12 files changed

+56
-61
lines changed

src/Meilisearch/Extensions/ObjectExtensions.cs

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Globalization;
43
using System.Linq;
54
using System.Reflection;
65

@@ -43,31 +42,25 @@ internal static string ToQueryString(this object source, BindingFlags bindingAtt
4342

4443
if (value != null)
4544
{
46-
var type = value.GetType();
47-
48-
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
45+
if (value is List<string> stringValue)
46+
{
47+
values.Add(key + "=" + string.Join(",", stringValue));
48+
}
49+
else if (value is List<int> intValue)
50+
{
51+
values.Add(key + "=" + string.Join(",", intValue));
52+
}
53+
else if (value is List<TaskInfoStatus> taskInfoStatusValue)
54+
{
55+
values.Add(key + "=" + string.Join(",", taskInfoStatusValue.Select(x => x.ToString())));
56+
}
57+
else if (value is List<TaskInfoType> taskInfoTypeValue)
4958
{
50-
var itemType = type.GetGenericArguments()[0];
51-
if (itemType == typeof(string))
52-
{
53-
values.Add(key + "=" + string.Join(",", (List<string>)value));
54-
}
55-
else if (itemType == typeof(int))
56-
{
57-
values.Add(key + "=" + string.Join(",", (List<int>)value));
58-
}
59-
else if (itemType == typeof(TaskInfoStatus))
60-
{
61-
values.Add(key + "=" + string.Join(",", ((List<TaskInfoStatus>)value).Select(x => x.ToString())));
62-
}
63-
else if (itemType == typeof(TaskInfoType))
64-
{
65-
values.Add(key + "=" + string.Join(",", ((List<TaskInfoType>)value).Select(x => x.ToString())));
66-
}
59+
values.Add(key + "=" + string.Join(",", taskInfoTypeValue.Select(x => x.ToString())));
6760
}
68-
else if (value is DateTime)
61+
else if (value is DateTime datetimeValue)
6962
{
70-
values.Add(key + "=" + Uri.EscapeDataString(((DateTime)value).ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz")));
63+
values.Add(key + "=" + Uri.EscapeDataString(datetimeValue.ToString("yyyy-MM-dd'T'HH:mm:ss.fffzzz")));
7164
}
7265
else
7366
{

tests/Meilisearch.Tests/DocumentTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public async Task BasicDocumentAdditionFromCsvStringInBatches()
162162

163163
var csvDocuments = await File.ReadAllTextAsync(Datasets.SongsCsvPath);
164164
var tasks = (await index.AddDocumentsCsvInBatchesAsync(csvDocuments, 250)).ToList();
165-
Assert.Equal(2, tasks.Count());
165+
Assert.Equal(2, tasks.Count);
166166
foreach (var u in tasks)
167167
{
168168
u.TaskUid.Should().BeGreaterOrEqualTo(0);
@@ -190,7 +190,7 @@ public async Task BasicDocumentAdditionFromCsvWithDelimiterInBatches()
190190

191191
var csvDocuments = await File.ReadAllTextAsync(Datasets.SongsCsvCustomDelimiterPath);
192192
var tasks = (await index.AddDocumentsCsvInBatchesAsync(csvDocuments, 15, csvDelimiter: ';')).ToList();
193-
Assert.Equal(2, tasks.Count());
193+
Assert.Equal(2, tasks.Count);
194194
foreach (var u in tasks)
195195
{
196196
u.TaskUid.Should().BeGreaterOrEqualTo(0);
@@ -218,7 +218,7 @@ public async Task BasicDocumentAdditionFromNdjsonStringInBatches()
218218

219219
var ndjsonDocuments = await File.ReadAllTextAsync(Datasets.SongsNdjsonPath);
220220
var tasks = (await index.AddDocumentsNdjsonInBatchesAsync(ndjsonDocuments, 150)).ToList();
221-
Assert.Equal(2, tasks.Count());
221+
Assert.Equal(2, tasks.Count);
222222
foreach (var u in tasks)
223223
{
224224
u.TaskUid.Should().BeGreaterOrEqualTo(0);
@@ -469,7 +469,7 @@ public async Task BasicDocumentUpdateFromCsvStringInBatches()
469469

470470
var csvDocuments = await File.ReadAllTextAsync(Datasets.SongsCsvPath);
471471
var tasks = (await index.UpdateDocumentsCsvInBatchesAsync(csvDocuments, 250)).ToList();
472-
Assert.Equal(2, tasks.Count());
472+
Assert.Equal(2, tasks.Count);
473473
foreach (var u in tasks)
474474
{
475475
u.TaskUid.Should().BeGreaterOrEqualTo(0);
@@ -505,7 +505,7 @@ public async Task BasicDocumentUpdateFromNdjsonStringInBatches()
505505

506506
var ndjsonDocuments = await File.ReadAllTextAsync(Datasets.SongsNdjsonPath);
507507
var tasks = (await index.UpdateDocumentsNdjsonInBatchesAsync(ndjsonDocuments, 150)).ToList();
508-
Assert.Equal(2, tasks.Count());
508+
Assert.Equal(2, tasks.Count);
509509
foreach (var u in tasks)
510510
{
511511
u.TaskUid.Should().BeGreaterOrEqualTo(0);

tests/Meilisearch.Tests/IndexSwapTest.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Text.Json;
4-
using System.Text.Json.Serialization;
5-
6-
using Microsoft.AspNetCore.WebUtilities;
73

84
using Xunit;
95

tests/Meilisearch.Tests/Movie.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class FormattedMovie
4646

4747
public string Genre { get; set; }
4848

49-
#pragma warning disable SA1300
49+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Naming convention used to match meilisearch.")]
5050
public Movie _Formatted { get; set; }
5151
}
5252

@@ -57,6 +57,8 @@ public class MovieWithRankingScore
5757
public string Name { get; set; }
5858

5959
public string Genre { get; set; }
60+
61+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Naming convention used to match meilisearch.")]
6062
public double? _RankingScore { get; set; }
6163
}
6264

@@ -67,6 +69,8 @@ public class MovieWithRankingScoreDetails
6769
public string Name { get; set; }
6870

6971
public string Genre { get; set; }
72+
73+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Naming convention used to match meilisearch.")]
7074
public IDictionary<string, JsonElement> _RankingScoreDetails { get; set; }
7175
}
7276
}

tests/Meilisearch.Tests/MultiIndexSearchTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System;
21
using System.Collections.Generic;
32
using System.Linq;
43
using System.Text.Json;

tests/Meilisearch.Tests/ObjectExtensionsTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text.Json.Serialization;
53

6-
using Meilisearch.Converters;
74
using Meilisearch.Extensions;
85
using Meilisearch.QueryParameters;
96

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"profiles": {
3+
"Meilisearch.Tests": {
4+
"commandName": "Project",
5+
"launchBrowser": true,
6+
"environmentVariables": {
7+
"ASPNETCORE_ENVIRONMENT": "Development"
8+
},
9+
"applicationUrl": "https://localhost:52605;http://localhost:52606"
10+
}
11+
}
12+
}

tests/Meilisearch.Tests/SearchTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public async Task CustomSearchWithFilter()
213213
});
214214
movies.Hits.Should().NotBeEmpty();
215215
movies.FacetDistribution.Should().BeNull();
216-
Assert.Equal(2, movies.Hits.Count());
216+
Assert.Equal(2, movies.Hits.Count);
217217
Assert.Equal("12", movies.Hits.First().Id);
218218
Assert.Equal("Star Wars", movies.Hits.First().Name);
219219
Assert.Equal("SF", movies.Hits.First().Genre);
@@ -247,7 +247,7 @@ public async Task CustomSearchWithFilterArray()
247247
});
248248
movies.Hits.Should().NotBeEmpty();
249249
movies.FacetDistribution.Should().BeNull();
250-
Assert.Equal(2, movies.Hits.Count());
250+
Assert.Equal(2, movies.Hits.Count);
251251
Assert.Equal("12", movies.Hits.First().Id);
252252
Assert.Equal("Star Wars", movies.Hits.First().Name);
253253
Assert.Equal("SF", movies.Hits.First().Genre);
@@ -265,7 +265,7 @@ public async Task CustomSearchWithFilterMultipleArray()
265265
});
266266
movies.Hits.Should().NotBeEmpty();
267267
movies.FacetDistribution.Should().BeNull();
268-
Assert.Equal(2, movies.Hits.Count());
268+
Assert.Equal(2, movies.Hits.Count);
269269
Assert.Equal("12", movies.Hits.First().Id);
270270
Assert.Equal("Star Wars", movies.Hits.First().Name);
271271
Assert.Equal("SF", movies.Hits.First().Genre);
@@ -392,7 +392,7 @@ public async Task CustomSearchWithSort()
392392
});
393393
movies.Hits.Should().NotBeEmpty();
394394
movies.FacetDistribution.Should().BeNull();
395-
Assert.Equal(2, movies.Hits.Count());
395+
Assert.Equal(2, movies.Hits.Count);
396396
Assert.Equal("14", movies.Hits.First().Id);
397397
}
398398

@@ -494,7 +494,7 @@ public async Task CustomSearchWithMatchingStrategyLast()
494494
var searchQuery = new SearchQuery() { MatchingStrategy = "last" };
495495
var movies = await _nestedIndex.SearchAsync<MovieWithInfo>("movie about rich", searchQuery);
496496

497-
Assert.True(movies.Hits.Count() > 1);
497+
Assert.True(movies.Hits.Count > 1);
498498
}
499499

500500
[Fact]

tests/Meilisearch.Tests/ServerConfigs/BaseUriServer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public class ConfigFixture : IndexFixture
1313
{
1414
public override string MeilisearchAddress()
1515
{
16-
var env = Environment.GetEnvironmentVariable("MEILISEARCH_URL");
17-
18-
return env == null ? MeilisearchTestAddress : env;
16+
return Environment.GetEnvironmentVariable("MEILISEARCH_URL") ?? MeilisearchTestAddress;
1917
}
2018
}
2119

tests/Meilisearch.Tests/ServerConfigs/ProxiedUriServer.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ public class ConfigFixture : IndexFixture
1313
{
1414
public override string MeilisearchAddress()
1515
{
16-
var env = Environment.GetEnvironmentVariable("PROXIED_MEILISEARCH");
17-
18-
return env == null ? MeilisearchTestAddress : env;
16+
return Environment.GetEnvironmentVariable("PROXIED_MEILISEARCH") ?? MeilisearchTestAddress;
1917
}
2018
}
2119

0 commit comments

Comments
 (0)